Lesson 14. Making more-complicated decisions

After reading lesson 14, you’ll be able to

  • Combine many decisions in one conditional statement
  • Make a choice when presented with various options
  • Write code that gets the computer to decide between a few choices

It’s limiting and time-consuming if every decision you make is the result of asking only one question at a time. Say you want to buy a new phone. There are only three phones that you’re considering, but you’re not sure how much money you have in your bank account. Additionally, one other criteria is that the phone is available in green. Using yes or no questions, you could ask the following:

  • Do I have between $400 and $600?
  • Do I have between $200 and $400?
  • Do I have between $0 and $100? ...

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.