O'Reilly logo

Python Projects for Kids by Jessica Ingrassellino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Conditional statements – if, elif, else

There are three language constructs that are used frequently in Python to control the outcome of a program. These constructs are if, elif, and else:

  • The if statement tells the program that if the user does this, then execute this part of the program.
  • The else statement is used to catch anything that the user does and is not in the program. For example, you can use if and else together: if the user chooses add, do addition, else do another action.

    Note

    The elif stands for else if, which means that if the first thing does not happen, then do the next thing in the list of possibilities until the user choice matches the possibility.

  • elif is used when you want to give the program more than two choices. You can use ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required