The answersDownload the PDF
Worksheet

F3.8 Project: survey the room

Strings, lists and records · GCSE · about 25 min

BugBotLab
NameClassDate

What this lesson is about

Look in eight directions, store the survey as records, report on it and head for open space.

Questions 4 marks in all

  1. [1 mark]Why plan what one record looks like before writing the survey loop?

    1. AEvery later loop depends on the fields the records have
    2. BPython needs records declared first
    3. CIt makes the robot turn faster
    4. DRecords cannot be changed later
  2. [1 mark]What does this program print?

    survey = [{"direction": 0, "distance": 31.0}, {"direction": 45, "distance": 42.5}, {"direction": 90, "distance": 51.0}]
    total = 0
    for r in survey:
        total = total + r["distance"]
    print(total / len(survey))
  3. [1 mark]What does this program print?

    survey = [{"direction": 0, "distance": 31.0}, {"direction": 45, "distance": 42.5}, {"direction": 90, "distance": 51.0}]
    open_count = 0
    for r in survey:
        if r["distance"] > 40:
            open_count = open_count + 1
    print(open_count)
  4. [1 mark]Why test the report on a small made-up survey before using the robot's data?

    1. AYou can work the right answers out by hand and compare
    2. BMade-up data is more accurate
    3. CThe robot cannot store records
    4. DIt is required by Python

The task: survey the room

Do the survey from the brief. Print the table, then report lines in exactly this shape (these are the numbers a correct program gets in this room): Then turn to face the farthest direction and play a note.

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

survey = []
for i in range(8):
    turn_right(30, angle=45)

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

QR code
Do it on the robot
www.bugbotlab.com/learn/f3-8-project-survey-the-room/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Add a field open to each record, True or False, and use it for the count.
  2. Round the average to one decimal place, and print the table with a line of dashes under the heading.
  3. Survey in 16 directions instead of 8. What must change, and what can stay the same?