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
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
23 | 24 | 25 | 26 | 27 | 28 | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 1 | 2 | 3 | 4 | 5 |
Get Free Quote!
357 Experts Online