Common Computer Science References
At the end of this lesson, you will be able to:
understand and create your own function that has return value
functions with parameters
go over Return Values , Computer Based Problem Solving
now that we know how to use a return statement, we will no longer print out results in a function (like we have in the last few units) we will always return the value
NOTE: we have also added in "type hints", to help coders using your function
nil
create a program and a function that takes the grade level character (4, 3, 2, 1, R - see Ontario section here) and returns the middle percentage mark (just as an integer, no "%" on the return value)
accept a character (in python a single length string) type (ex. 4 or R) as a level and return an integer as the percentage
if "invalid" input is passed to the function, then return a "-1"
"-1" is commonly used as a return value that means there has been an error
recreate the same above program in C
use CS50's get_char
NOTE: You can turn on "Closed Captions" to see a printout of what is being said by selecting the "CC" button.
You can also have it translate the closed captions by going to "Settings, Subtitles/CC, Auto-translate" and then pick your prefered language.