Write A Python Program To Get Input From The User Using A While Loop And Print If It Is An Even Number Or Not Until 0 Is Not Pressed.
Answers
Answered by
1
Answer:
DJ vfjfjdjshjsobdjq so nsn to n sbbobcoabcwc
Answered by
0
Answer:
Following is a Python Program To Get Input From The User Using A While Loop And Print If It Is An Even Number Or Not Until 0 Is Not Pressed.
num = int(input())
check =True
while(check):
num = int(input())
if(num%2==0):
print("This is an even number")
check = int(input("Press 0 to exit otherwise press any other number"))
if(check==0):
check=False
Explanation:
Let's understand the code above:
- First, we create a check variable and initialize it with a True value.
- Now inside our while loop, we take the input of the user for checking whether the number is even or odd.
- If the number is divided by 2 that means it is even otherwise not.
- Then we ask the user to enter 0 to exit else press any other number.
- If the user enters 0 then we terminate our program.
- Else we again take the input.
#SPJ3
Similar questions
Math,
5 months ago
Science,
5 months ago
Hindi,
5 months ago
Computer Science,
10 months ago
Computer Science,
10 months ago
Math,
1 year ago
English,
1 year ago
Math,
1 year ago