Question: This is python programming question. Please follow the restrictions. This is python programming question. Please follow the restrictions. This is python programming question. Please follow
This is python programming question. Please follow the restrictions. This is python programming question. Please follow the restrictions.
This is python programming question. Please follow the restrictions. This is python programming question. Please follow the restrictions.
This is python programming question. Please follow the restrictions. This is python programming question. Please follow the restrictions.



Untitled document a Share A Share File Edit View Insert Format Tools Add-ons Help Last edit was seconds ago A 100% Normal text Arial 11.5 + BIU A 2 1 TF1 1 2 3 1 4 5. 6 il 7 8 9 | 10 | 11 | 12 1.13 | 14 | 15 | 16 | 17 | 18 | RESTRICTIONS Only allowed: variables, if statements, while loops. Functions: len(), int(), float(), type (), isinstance (), abs (). String methods: format(), isalpha (). List operators and methods: create [ ], list(), append(). Keywords: elif, else, return, break, continue, def, self, None, try, raise, except, finally, is, import sys. Any exception handling. Remember: Do NOT use for loops or the in keyword. Do NOT use min() /max(), enumerate ()/zip() or sorted(). Do NOT use negative indexing (e.g. 1s[-1]) or slicing (e.g. [1:]). Do NOT use any other list operations or string methods. Write a program numbers.py that continuously asks for user input via standard input until the user enters o or presses Enter without typing any input. Any non-integer entries should be ignored. Furthermore, any negative integer should also be ignored. After each valid number, the program should output the message An even chance! if the number is even. Otherwise, it should output the message what are the odds?. At the end, the program should print the total number of valid entries and also the sum of all the numbers which were multiples of 3. Note that if the user enters o to quit the program, the o does not count as an entry. Please refer to the example below for the formatting of the expected output. Example: User exits by entering o: $ python3 numbers.py Enter a number: 10 An even chance! Enter a number: -1 Enter a number: six Enter a number: 6 An even chance! Enter a number: 3 What are the odds? Enter a number: 0 You entered 3 numbers. The sum of all the multiples of 3 is 9. User exits by pressing the Enter key: $ python3 numbers.py Enter a number: 10 An even chance! Enter a number: 5 What are the odds? Enter a number: 5 What are the odds? Enter a number: 5.0 Enter a number: 4 An even chance! Enter a number: You entered 4 numbers. The sum of all the multiples of 3 is 0. Notes All output should be printed to stdout and should not contain any unexpected data. Use stderr for any debugging print you may have planned. sys.stderr.write() Write all your entire program in the single file. You may create helper functions, but cannot import from other files
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
