Question: 7. Writi ng short program Using a while loop, write a program to perform the following actions (8 points totall: (a) Create an empty list.
7. Writi ng short program Using a while loop, write a program to perform the following actions (8 points totall: (a) Create an empty list. (b) Ask the user to enter an integer. (c) If the integer is zero, go to step (g) (d) If the integer is divisible by 5, append it to a list (e) Otherwise ignore the integer (f) Return to step (b). (g) Print the sum of the integers on the list. (h) Exit the program. There is no need to validate the user's input, assume the user enters only legal num- bers. You are free to use any builtin function or programming construct we have dis- cussed in class to date. Here is an example of the program's output: Enter a number (or to exit): 15 Enter a number (or to exit): 12 Enter a number (or 0 to exit): -10 Enter a number (or e to exit): 11 Enter a number (or e to exit): 25 Enter a number (or to exit): 25 Enter a number (or to exit): 20 Enter a number (or 0 to exit): Total 75 mer on miege
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
