Question for DAY 1 :
Write a Python program that accepts a number from the user and determines whether it is even or odd :
n=int(input("Enter the number"))
if n%2 == 0:
print("Number is Even")
else :
print("Number is ODD")
Output :
Enter the number 2
2
Number is Even
This is a Python code that takes input from the user and checks whether the number is even or odd. If the number is even, it prints "Number is Even", otherwise it prints "Number is ODD".
The first line of code uses the input() function to prompt the user to enter a number. The value entered by the user is stored as an integer in the variable n.
The second line of code checks if the remainder of n divided by 2 is zero, which means n is even. If this condition is true, the code inside the if block will be executed.
The third line of code prints "Number is Even" to the console.
If the condition in line 2 is false, which means n is odd, the code inside the else block will be executed.
The fifth line of code prints "Number is ODD" to the console.
So, for example, if the user enters the number 4, the code will output "Number is Even". If the user enters the number 5, the code will output "Number is ODD".
If you are a beginner and want to know more about python programming, you can read my basics of python blogs (From part 1 to part 15).
Happy Learning !!!