The working folio The courtyard
What is Python coding?
Writing plain-English instructions that a machine carries out in front of your eyes.
Python coding is everyday English written strictly enough for a computer to perform. Change any terracotta word below and press Run – no setup, no account.
Exercise: Try changing "cobalt" to "jade" and press Run.
Hint
The word in quotes after == decides which pieces stay in the tray.
Solution
pieces = ["cobalt", "amber", "coral", "cobalt", "jade"]
kept = []
for item in pieces:
if item == "jade":
kept.append(item)
print(kept) Exercise: Light all eight bays and change the weather to rain.
Hint
range(1, 6) stops just before 6. Which end number reaches bay 8? Words like "rain" and "night" are allowed too.
Solution
sky = "dusk"
weather = "rain"
welcome = "Start from zero"
for bay in range(1, 9):
light_bay(bay) kept