Exercise 1 · Chapter: Many at OnceRequired+50 XP
Three Drops
Draw three raindrops from a list. Nothing moves yet — just get them on screen.
new_game already returns {"drops": [0, 3, 6]}. In draw, paint each one
"aqua", using its position in the list to decide the column:
- drop
0→ column8 - drop
1→ column18 - drop
2→ column28
Three drops, one loop. Add a fourth number to the list later and the drawing code won't need to change at all — that's the point of doing it this way.
Expected output
........A............................... ........................................ ........................................ ..................A..................... ........................................ ........................................ ............................A........... ........................................ ........................................ ........................................ ........................................ ........................................ ........................................ ########################################
Need a hint?
3 available · costs 5 XP each
python
def new_game():
return {"drops": [0, 3, 6]}
def update(state, keys):
return state
def draw(state):
grid = blank_grid()
# Loop over the drops and paint each one aqua at column 8 + i * 10.
return grid