What would be the python code for the task - user input a number to identify if its odd or even
Answers
Answered by
0
a = int(input('Enter any number: '))
if a % 2 == 0:
print("Even Number")
else:
print("Odd Number")
if a % 2 == 0:
print("Even Number")
else:
print("Odd Number")
Answered by
0
We can know if a number is even or odd if the remainder of the number divided by 2 is 0 or something else.
So, to write the program, we will look for the remainder of the number provided.
def even_odd(num):
return 'Even' if num%2 == 0 else 'Odd'
even_odd(int(input('Enter your number:')))
Similar questions
English,
8 months ago
Social Sciences,
8 months ago
English,
1 year ago
Math,
1 year ago
Environmental Sciences,
1 year ago
History,
1 year ago
Environmental Sciences,
1 year ago