Week 8

Make a Decision

Aim: Make the program choose between different actions.

New coding words

  1. condition
  2. if
  3. else
  4. compare
  5. lower

What the coding words mean

  1. condition: A check that can be true or false.
  2. if: Runs a group of commands when a condition is true.
  3. else: Runs a different group of commands when the condition is false.
  4. compare: To check whether two values are the same or different.
  5. lower: Changes text to lowercase so answers are easier to compare.
Code along

Choose for the weather

Use if and else to choose advice for sunny or rainy weather.

Python coding spaceReady to run
.py

Tab indents. Esc then Tab leaves the editor. Ctrl/⌘ + Enter runs your code.

Output (Shell)What your program does
Select Run my code to try this program.
Opening your coding space…Each activity has its own saved code.
Mini project

Secret Treasure Door

Ask for a secret word and decide whether the treasure door opens.

Python coding spaceReady to run
.py

Tab indents. Esc then Tab leaves the editor. Ctrl/⌘ + Enter runs your code.

Output (Shell)What your program does
Select Run my code to try this program.
Opening your coding space…Each activity has its own saved code.

Your mini-project to-do list

0 of 4 completed

Complete these activities in the mini-project editor above. After each change, select Run my code to check your program’s output or drawing.

Save your finished mini project

Select Download my work and save the file as week_8_secret_treasure_door.py. The .py ending tells us that the file contains Python code. Keep this file as a copy of your finished program.

Debugging detective

Chi Opara, your course guide

Knowledge check

Question 1

Which symbol compares two values?

Choose one answer
Question 2

When does the code underneath else run?

Your answers are checked in this browser and are not submitted.

How are you getting on so far?

My checklist

Finished Week 8?

This progress is saved only in this browser.