Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.
- Structured Programming
- Selection Control Structures
- Code Blocks
- Condition Examples: Temperature Conversion Pseudocode
- Condition Examples: Python Code
- Structured Quiz 5 questions
- If and If-else Statement
- If and If-else Quiz 5 questions
- Chained Decisions
- Chained Decisions Quiz 5 questions
- Nested Decision
- Nested Decision Quiz 5 questions
- Conditional Expressions
- Conditional Expressions Quiz 5 questions
Well done!
You have completed (UPI) Chapter 6: Decision-Making in Python!
Instruction
Nested Decision
Nested Decision Statements
Suppose a programmer is writing a program that reads in a game ID and player count and prints whether the user has the right number of players for the game.
The programmer may start with:
if game == 1 and players < 2:
print("Not enough players")
if game == 1 and players > 4:
print("Too many players")
if game == 1 and (2 <= players <= 4):
...