8.39 Lab 8d: Even Entry Loop
This program will ask the user to enter an even number and continue to do so until they enter the given QUIT condition.
The prompt for the user to enter a number is written as follows: "Enter an even number or [QUIT] to quit:" The quitting condition in this case will be the number 999.
If the number they entered was an even number, output the message "Good job!" Otherwise, output the message "[number] is not an even number." Then, prompt the user to enter another number or the quitting condition again.
Example output:
Enter an even number or 999 to quit: 2 Good job! Enter an even number or 999 to quit: 3 3 is not an even number. Enter an even number or 999 to quit: 999
source code:
while(True):
n=int(input("Enter even number or 999 to quit : "))
if(n%2==0):
print("Good job!")
elif(n==999):
break
else:
print(n," is not a even number")
Get Answers For Free
Most questions answered within 1 hours.