Write a program using a while loop with the continue command (and break command if you need it) that counts the multiples of 5 between 0 and 125, inclusive, but does not print numbers that are multiples of 7. The numbers should display on one line with a space between each. (10 points) Name the program fives_no_sevens.py NOTE: Since 0 is a multiple of 7 (0X7=0), it SHOULD NOT be printed!
Example output:
5 10 15 20 25 30 40 45 50 55 60 65 75 80 85 90 95 100 110 115 120 125

Press enter to exit
Re-write Program 1 using a for loop that counts the multiples of 5 between 0 and 125, inclusive, but does not print numbers that are multiples of 7. The numbers should display on one line with a space between each. Use the continue and or break commands if you need them. (10 points) Name the program for_fives_no_sevens.py NOTE: Since 0 is a multiple of 7 (0X7=0), it SHOULD NOT be printed!
Example output:
5 10 15 20 25 30 40 45 50 55 60 65 75 80 85 90 95 100 110 115 120 125

Press enter to exit
Rewrite program 1 or program 2 (use while or for, your choice) to allow the user to enter the starting and ending values (instead of 0 and 125). Make sure to ONLY PRINT MULTIPLES OF 5 regardless of what numbers the user entered. (For example, if the user enters 12 and 42, you should print: 15 20 25 30 40. Note that 35 is a multiple of 7, so it should not print.) Also be sure to make sure the ENDING number is GREATER THAN the STARTING number - if it is not, print an error. (10 points) Name the program new_ fives_no_sevens.py
Example output:

Enter a starting number: 12
Enter an ending number: 42
15 20 25 30 40

Press enter to exit

Enter a starting number: 50
Enter an ending number: 25
Error - ending number must be less than starting

Press enter to exit
Rewrite program 3 to ask the user if they want to run the program again. Allow only "y" or "Y" to rerun, or "n" or "N" to stop. If they type something else, print an error message and force them to enter again. Use a while loop to check for a correctly inputted value. (10 points) Name the program newest_ fives_no_sevens.py
Example output:
Enter a starting number: 12
Enter an ending number: 42
15 20 25 30 35 40
Do you want to start again? (enter Y or N) y

Enter a starting number: 40
Enter an ending number: 3
Error - ending number must be greater than starting

Do you want to start again? (enter Y or N) y

Enter a starting number: 6
Enter an ending number: 88
10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85
Do you want to start again? (enter Y or N) n

Press enter to exit

Write a program using a while loop with the continue command and break command if you need it that counts the multiples of 5 between 0 and 125 inclusive but doe class=

Respuesta :

Each solution is a bit lengthy. In order to conserve space, they have been added to the answer as screenshot images as follows;

  • solution1 (list all multiples of fives that are not multiples of seven from 0 to 125 using a while loop)
  • solution2 (list all multiples of fives that are not multiples of seven from 0 to 125 using a for loop)
  • solution3 (allow the user to enter starting and ending values, then list all multiples of fives that are not multiples of seven in that range using a for loop)
  • solution4 (give the user the choice to rerun the program)

Each program uses a loop to generate multiples of five. However, in order to avoid printing numbers that are multiples of both five and seven, an if statement is used to check if the current multiple of five is also a multiple of seven. If so, the loop continues with the next iteration without trying to print anything.

Each successful multiple of five is added to a list called output multiples. Then to print out the list using space as the delimiter, and without the square brackets, add an asterisk to the list as shown in the code.

See another python program on loops in the link: https://brainly.com/question/12736327

Ver imagen batolisis
Ver imagen batolisis
Ver imagen batolisis
Ver imagen batolisis
ACCESS MORE