The following problems are specified in the file homework_5_skel.py. Complete the problems in that file and rename it homework_5.py before uploading it to Moodle.
Remember len(s) returns the length of a string s, and that s[i] returns the ith character of s.
Some of these problems must use while instead of for. Make sure their termination is guaranteed.
A counter
Define a function counter0 which takes no inputs and has the following effect when run: It
repeatedly queries the user, asking for either a numerical input, or the letter ’q’ (to quit). The
user types in a sequence of numbers and finally the letter ’q’. The program then returns
• how many numbers entered
• the sum of the numbers entered
• the maximal number entered
• the average of the numbers entered
Get Free Quote!
399 Experts Online