Class XI Question based if else in Python programming worksheet No 2


 Class XI Question based if else in Python programming


These questions cover various applications of if and else statements and will help students understand conditional logic in Python. Encourage students to test their code with different values to ensure their programs work correctly.

Question1: Write a Python program that checks if a number is positive or negative. The program should print "Positive" if the number is greater than 0, and "Negative" if it is less than 0. Test your program with the number -5

Question2: Write a Python program that determines if a given number is even or odd. Print "Even" if the number is divisible by 2, and "Odd" if it is not. Test your program with the number 7.


Question3: Create a program that suggests clothing based on the temperature. If the temperature is below 50°F, print "Wear a jacket". If the temperature is between 50°F and 75°F, print "Wear a sweater". If the temperature is above 75°F, print "Wear shorts". Test your program with the temperature 60°F.

Question4: Write a Python program that assigns a letter grade based on a numeric score. Use the following criteria:

  • 90 and above: "A"
  • 80 to 89: "B"
  • 70 to 79: "C"
  • 60 to 69: "D"
  • Below 60: "F"

Test your program with the score 85.


Question5: Write a program that classifies a person based on their age. The classifications are:

  • Less than 13: "Child"
  • 13 to 19: "Teenager"
  • 20 to 64: "Adult"
  • 65 and above: "Senior"

Test your program with the age 45.


Question6: Create a program that checks if a number is divisible by both 3 and 5. Print "Divisible by 3 and 5" if it is, otherwise print "Not divisible by 3 and 5". Test your program with the number 15.


Question7: Write a program to check if a person is eligible to vote. A person must be at least 18 years old to vote. Print "Eligible to vote" if the person is 18 or older, and "Not eligible to vote" otherwise. Test your program with the age 17.


Question8: Write a Python program to determine whether an account balance is sufficient for a withdrawal. If the balance is greater than or equal to the withdrawal amount, print "Sufficient funds", otherwise print "Insufficient funds". Test your program with a balance of 1000 and a withdrawal amount of 750.


Question9: Write a program that applies a discount based on the purchase amount. If the amount is greater than or equal to $100, apply a 10% discount. Otherwise, apply no discount. Print the discounted amount. Test your program with a purchase amount of 120.


Question10: Create a program that checks if a year is a leap year. A year is a leap year if it is divisible by 4, but not divisible by 100, except for years that are divisible by 400. Print "Leap year" if it is, otherwise print "Not a leap year". Test your program with the year 2000.



Post a Comment

1 Comments

Please do note create link post in comment section