Python Classroom
  • Introduction
  • About Python Classroom
  • Python Cloud Options
    • CS50 IDE
      • CS50 IDE Overview
      • CS50 IDE and Python
      • CS50 IDE Debugging
      • CS50 IDE Shortcuts
      • Linux Bash Shell
      • Vim Mode
        • Vim Tutorial
    • CS50 Sandbox
    • PythonAnywhere
    • Repl.it
  • Python Curriculum Map
    • Pedagogy
      • Python Professional Development
      • Teaching Tips
      • Assessment Tips
      • Rubrics
      • Activities
        • Picture Activity
        • Map Activity
        • Crossing the Bridge
        • NIM
        • Mastermind
        • Cards
          • Card Deck Algorithms
          • Sorting Cards
        • River Crossing
          • Jealous Boyfriends
          • Cannibals and Priests
          • Family
          • Police and the Thief
          • Humans and Monkeys
          • Moving Money
        • Crossing the River
        • Traveling Salesperson
        • Logic Problems
        • CIA Crack the Code
        • IQ Test
        • Puzzles
    • AP Computer Science Principles Framework
  • Python Philosphy
    • How to Practice Python
  • microbit
  • Turtle Graphics
    • Turtle Examples
    • Turtle Activities
    • Turtle Maze Problems
    • Turtle Graphics with loops
    • Turtle Snake
    • Turtle Graphics with Conditionals
  • Output
    • Output Examples
    • Output Mistakes
  • Variables
    • Variable Data Type Examples
    • Variable Role Examples
    • Variables Mistakes
    • Variables Problems
  • Math
    • Math Examples
    • Math Mistakes
    • Math Problems
    • Math Self Check
  • Input
    • Input Examples
    • Input Mistakes
    • Input Problems
  • Decisions
    • if
      • if Examples
      • if Mistakes
      • if Problems
    • if else
      • if else Examples
      • if else Problems
      • if / if else Problems
    • if elif else
      • if elif else Examples
      • if elif else Problems
    • nested if
      • nested if Examples
      • nested if Problems
    • Logical Operators
      • Logical Operators Examples
    • Adventure Game Project
  • Loops
    • while loop - count up
      • Examples
      • Problems
    • while loop - countdown
      • Examples
      • Problems
    • while loop - sentinel value
      • Problems
    • while loop - sentinel menu
      • Problems
    • for loop - range (one argument)
      • Examples
      • Problems
    • for loop - range (two arguments)
      • Problems
    • for loop - range (three arguments)
      • Problems
  • Lists
    • Lists - Numbers
      • Problems
    • Lists - Strings
      • Problems
      • Shopping Project
  • Dictionaries
  • String Methods
  • Functions
    • Variable Scope
    • Functions - no parameters
    • Functions - one parameter
    • Functions - return
    • Functions - lists
  • Files
  • Classes
    • Inheritance
  • Python Projects
    • Adventure Game
    • Restaurant Project
    • Trivia Game
    • Family Tree Project
  • Raspberry Pi
    • Raspberry Pi Models
    • Raspberry Pi Setup
  • Roblox
  • Glossary
Powered by GitBook
On this page
  • Problem 1
  • Problem 2
  • Problem 3
  • Problem 4
  • Problem 5
  • Problem 6
  • Problem 7
  • Problem 8
  • Problem 9
  • Problem 10
  • Problem 11

Was this helpful?

  1. Decisions
  2. if else

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.

Previousif else ExamplesNextif / if else Problems

Last updated 5 years ago

Was this helpful?