if else Problems

Problem 1

Write Python code that asks a user for two numbers. Print the number that is the greatest. Print the number that is the least.

Problem 2

Write Python code that asks a user for their password. If the user enters “1234567890”, print “that password is really easy to guess”.

Else print “good enough, I guess”.

Problem 3

Write Python code that asks a user for their temperature. If the temperature is 100.4 or more, print “you have a fever”.

Else print “normal temperature”

Problem 4

Write Python code that asks a user how many degrees is it in the Building. If the temperature is less than or equal to 70, print “feels chilly”.

Else print “comfy”.

Problem 5

The USEPA developed the Air Quality Index (AQI) to report daily air quality to the public. The AQI tells you how clean your local air is, and what associated health effects might be a concern in your area. Think of the AQI as a yardstick that runs from 0 to 300. The higher the AQI value, the greater the level of air pollution and the greater the health concern.

Write Python code that asks a user what the AQI is today. If the user enters, 50 or less, print “Air Quality is Good”. Else print, “Air Quality is Moderate or Unhealthy”.

Problem 6

Write Python code that asks a user how many pizza slices they want. The pizzeria charges $1.25 a slice if you order 10 slices or less and $1 a slice if you order more than 10 slices.

Print the total price depending on how many slices you order.

(Note: do not use the $ when assigning the price in your Python code)

Problem 7

Write Python code that asks a user how many Youtube videos they watch per day. The average video is 7 minutes. If the user enters 5 or more, print “you watch a lot of videos”.

Else print “get more sleep”.

Print the total number of minutes the user watches videos.

Problem 8

Write Python code that asks a user do you have a ShopRite card? Next, ask how many Apple or Pumpkin pies do they want to buy.

If the user enters “yes”, the user is charged 2.99 per pie. Else, the user is charged 4.99 per pie.

Print the total price.

Problem 9

Write Python code asks the user for a number. If the number is divisible by 5, print the number if it is divisible by 5. Else print the number is not divisible by 5.

Problem 10

Write Python code that asks a user for a number. Determine if the number is even or odd.

Problem 11

Write Python code that asks a user for three numbers. Print the number that is the greatest. Print the number that is the least.

Last updated