CLASS XI if else Question Session 2024-2025
- Write down python code to find out a number from the user and determine if it's positive, negative, or zero.positive, negative, or zero:
number = float(input("Enter a number: "))
# Determine if the number is positive, negative, or zero
if number > 0:
print("The number is positive.")
elif number < 0:
print("The number is negative.")
else:
print("The number is zero.")
2. Write down python code to find out the given year is leap year or not.
# Get the year from the user
year = int(input("Enter a year: "))
# Check if the year is a leap year
if year % 4 == 0:
else:
year = int(input("Enter a year: "))
# Check if the year is a leap year
if year % 4 == 0:
print(year,"is a leap year.")
else:
print(year," is not a leap year.")
number = int(input("Enter an integer: "))
# Check if the number is even or odd
if number % 2 == 0:
else:
3. Write down python code to find an integer input from the user and checks if it is even or odd
# Get an integer input from the usernumber = int(input("Enter an integer: "))
# Check if the number is even or odd
if number % 2 == 0:
print(number," is even.")
else:
print(number," is odd.")
4. Write down python code to find which is largest in given three number (take all three number from the user). largest:
python# Get three numbers from the user
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))
# Determine the largest number
if num1 >= num2 and num1 >= num3:
largest = num1
elif num2 >= num1 and num2 >= num3:
largest = num2
else:
largest = num3
# Output the result
print("The largest number is",largest)
0 Comments
Please do note create link post in comment section