Python If statement Assignment

Python If statement Assignment for Python selection statement. You are advised to check the tutorial on Python if statement first.

Find the output of the following Programs


if 3>5:
   print(' Hello class how are you')


 if True:
    print( ' Are you confuesd?')


if 3:
   print(' I do not know the answer')
   print(' Are you kidding')

Write Python Scripts

You are free to use any python editor and version of Python.

Q1. Write a script to input a number and check whether it is even or odd, and then display an appropriate message.

Q2. Write a script to input a number. If the number is even, print its square, otherwise print its cube

Q3. Write a script that inputs two numbers from the user and checks if the first number is divisible by the second or not. The script should then display an appropriate message.

Q4. Gunjan wants to write a script to input the number of students of a class and perform some processing. She knows that sometimes the user may enter a negative number for the number of students. In such a case, she wants to take the positive value of the number (e.g., if user enters -35, she wants to take 35). Help Gunjan by writing the part of the script which inputs the number of students in a class and converts it into a positive number if it is negative.

Q5. Write a script to input principal, time, and calculate simple interest. If time is more than 10 years, calculate simple interest at the rate of 8% p.a., otherwise calculate it at the rate of 12% p.a.

Q6. Write a script to input four numbers and find the largest of these without using the built-in function max().

Q7. Write a menu-driven script to calculate the total surface area and volume of a cube, cuboid, or sphere depending upon the user’s choice.

Q8. Write a python program to read a year and check if it is leap-year or not.

Q9. Write a program in Python to read a day number from the keyboard and print its equivalent day name.

Print Friendly, PDF & Email

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to See your article appearing on the main page and help other students/teachers.