Write a program that takes an integer as input and prints whether the number is even or odd.
number = int(input("Enter a number: "))
if number % 2 == 0:
print("The number is even.")
else:
print("The number is odd.")These test cases have been created with AI, cross check anything important.
4```
#### Expected output
The number is even.```
7```
#### Expected output
The number is odd.```
0```
#### Expected output
The number is even.```
This explanation has been created with AI, cross check anything important.
This line prompts the user to enter a number. input() reads the user's input as text. int() then converts that text into a whole number, which is stored in the variable number.
number = int(input("Enter a number: "))This line checks if the number is even or odd. The % operator calculates the remainder after division by 2. If the remainder is 0, the number is even.
if number % 2 == 0:If the condition number % 2 == 0 is true (meaning the number is even), this line prints "The number is even."
print("The number is even.")If the condition number % 2 == 0 is false (meaning the number is odd), the code inside the else block is executed.
else:This line prints "The number is odd." when the number is not even.
print("The number is odd.")These exercises have been created with AI, cross check anything important.
similarWrite a program that asks the user for their age. If the age is greater than or equal to 18, print 'You are an adult.' Otherwise, print 'You are a minor.'moderateWrite a program that takes two numbers as input. Determine which number is larger and print 'The larger number is: [number]' or if they are equal print 'The numbers are equal.'challengeWrite a program that asks the user for a year. Determine if the year is a leap year and print 'Leap year' or 'Not a leap year'. (A leap year is divisible by 4, but not divisible by 100 unless it is also divisible by 400).challengeWrite a program that takes an integer as input. Determine if the number is a prime number. Print 'Prime' if it is and 'Not prime' if it is not. (A prime number is only divisible by 1 and itself.)