Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My program is supposed to take a negative integer value from the user and determine whether or not that value is evenly divisible by either

My program is supposed to take a negative integer value from the user and determine whether or not that value is evenly divisible by either 5 or 7. In order to end the loop the user should just have to input a positive number or a 0. The program works fine except for when I enter a 0. Instead of ending the loop it just displays the message that 0 is evenly divisible by 5 or 7. I'm not sure how to modify the program in order to end the loop whenever 0 is inputted. end_loop = False num_integers = 0 while not end_loop: negative_integer = int(input("Please enter a negative integer (0 or positive to end): ")) if negative_integer % -5 == 0 or negative_integer % -7 == 0: print("Negative integer is evenly divisible by either 5 or 7.") num_integers += 1 elif negative_integer >= 0: end_loop = True print("Evenly divisible numbers are:", num_integers)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Which if these statements are true regarding the shift cipher?

Answered: 1 week ago