The answersDownload the PDF
Worksheet

0.2 Numbers and names

Python quick start · Robot club · about 10 min

BugBotLab
NameClassDate

What this lesson is about

Variables, arithmetic, and driving an exact distance instead of counting seconds.

Questions 7 marks in all

  1. [1 mark]What does this program print?

    speed = 60
    seconds = 1.5
    print("drove at", speed, "for", seconds, "seconds")
  2. [1 mark]What does this program print?

    cm_per_second = 18
    seconds = 2
    print("that should be about", cm_per_second * seconds, "cm")
  3. [1 mark]What does this program print?

    speed = 60
    speed = 25
    print("speed is", speed)
  4. [1 mark]What does distance=20 mean in forward(50, distance=20)?

    1. ADrive 20 cm, then stop
    2. BDrive for 20 seconds
    3. CDrive at speed 20
    4. DDrive 50 cm, 20 times
  5. [1 mark]Do you need a wait() after forward(50, distance=20)?

    1. ANo, the command waits until the robot has gone that far
    2. BYes, wait(20), or the robot never goes anywhere
    3. CYes, otherwise it never stops
    4. DOnly when the speed is over 50
  6. [1 mark]What does this program print?

    travelled_cm = 85
    print("that is", travelled_cm / 100, "metres")
  7. [1 mark]The robot covers 18 cm every second. How many centimetres does it cover in 2.5 seconds? Give the exact number.

The task: two legs

Drive 40 cm forward, then 45 cm to the right, and stop in the green zone. Use distance= rather than counting seconds, and give the two distances names at the top.

from bugbot import *
connect()

first = 40
# your second distance here

forward(50, distance=first)
stop()

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/start-2-numbers/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Do the same journey with the two legs the other way round. Does it end up in the same place?
  2. Make a variable slow = 25 and run the journey at that speed. Is it closer to the middle of the zone?
  3. Print the distance travelled in metres, not centimetres, using / 100.