Exercises 1, 2, and 3 are embedded in the Functions page so you must go there and find them if you did not do them while reading it. The work for those exercises as well as the answers for exercises 4 and 5 below need to be in the markdown file named 'Ex04.md' inside your Ex04 folder. Be sure you label your work in the markdown file. See the pages linked on the More page for help with formatting your markdown file.
What is the purpose of the "def" keyword in Python?
a) It is slang that means "the following code is really cool"
b) It indicates the start of a function
c) It indicates that the following indented section of code is to be stored for later
d) b and c are both true
e) None of the above
What will the following Python program print out?
def fred(): print("Zap")def jane(): print("ABC")jane()fred()jane()a) Zap ABC jane fred jane
b) Zap ABC Zap
c) ABC Zap jane
d) ABC Zap ABC
e) Zap Zap Zap
Rewrite your pay computation with time-and-a-half for overtime and create a function called computepay which takes two parameters (hours and rate) and returns the pay.
Enter Hours: 45Enter Rate: 10Pay: 475.0Submit the program file with the name '4-6.py' once the program is thoroughly tested.
Rewrite the grade program from the previous chapter using a function called computegrade that takes a score as its parameter and returns a grade as a string.
Score Grade>= 0.9 A>= 0.8 B>= 0.7 C>= 0.6 D < 0.6 FExamples:
Enter score: 0.95AEnter score: perfectBad scoreEnter score: 10.0Bad scoreEnter score: 0.75CEnter score: 0.5FRun the program repeatedly as shown above to test the various different values for input.
Submit the program file using the name '4-7.py' once testing is complete.