Book #1: Loops and Conditions (Intro)

Total Exercises: 7

Up till now we copy-pasted forward() command several times whenever we wanted to do several steps. Of course real programs should have more powerful weapon. We are going to learn usage of the new stuff now:

  • detecting if there is an obstacle ahead of tank, or the star under the tank;
  • repeating actions (e.g. forward()) as long as no obstacle is detected;
  • doing some action (e.g. pick() the star) based on some condition (e.g. we see the star below).

This will allow us to create far more whimsical and wonderful programs!

Proceed to the Exercises

Example flowchart for PyTanks game