Programming fundamentals›Making decisions
Tutorial 2 of 13 · Programming fundamentals · Values and flow · BeginnerMaking decisions
Let a program ask a question and take a different path depending on the answer.
5 lessons, the last is a challenge · 55 min · Python and Java
Before you startYou finished "Your first program": you can use values, variables, arithmetic and print.
What you’ll be able to do
- 1Write a comparison such as score >= 70 and say whether its answer is True or False (true or false in Java).
- 2Use if and else so that a program runs one of two paths, and say which path runs for a given value.
- 3Build a chain of cases in the right order, so that each value lands on the branch meant for it.
- 4Combine two questions into one (and, or, not in Python; &&, ||, ! in Java) and say when the combined answer is yes.
Lessons
Next in this path
Next: 3 · Repeating · 6 lessons · 1 h 05 min
Do something again and again without writing it out each time, and know when to stop.
Playground
Try the same model with your own values. No checks, nothing recorded.
Open the playground