Lesson 13. Introducing decisions in programs

After reading lesson 13, you’ll be able to

  • Understand how the Python interpreter makes decisions
  • Understand which lines of code get executed when a decision is made
  • Write code that automatically decides which lines to execute depending on user input

When you write a program, you write lines of code. Each line of code is called a statement. You’ve been writing linear code, which means that when you run your program, every line of code is executed in the order that you wrote it; none of the lines are executed more than once, and none of the lines are skipped. This is equivalent to going through life without being allowed to make any decisions; this would be a constraining way to experience the world. ...

Get Get Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.