The worksheetDownload the PDF
Answers

F1.1 What a program is

Programming basics · GCSE · OCR J277 2.2.1, AQA 8525 3.2.2, Edexcel 1CP2 6.2.2 · about 10 min

BugBotLab

What this lesson is about

Instructions, one at a time, top to bottom. Running code and reading what comes back.

Questions 7 marks in all

  1. [1 mark]In what order does Python carry out the lines of a program?

    1. ATop to bottom, one at a time
    2. BShortest line first
    3. CAll at the same time
    4. DIn any order it likes
    Answer: A. The computer carries out the first instruction, then the second, then the third. It never skips ahead or goes back on its own.
  2. [1 mark]What does this program print?

    print("start")
    print("end")
    print("middle")
    Answer:
    start
    end
    middle

    The lines run in the order they are written, so the output follows the order of the lines, not the meaning of the words.

  3. [1 mark]What does from bugbot import * do?

    1. ABrings in the robot's commands, such as forward and stop
    2. BConnects to the robot
    3. CMakes the robot start moving
    4. DPrints the word bugbot
    Answer: A. It brings in the commands. connect() is the line that finds the robot and opens the link to it.
  4. [1 mark]A program prints "moving", then calls forward(50), wait(1) and stop(), then prints "stopped". When does "stopped" appear?

    1. AAfter the robot has stopped
    2. BBefore the robot moves
    3. CAt the same time as "moving"
    4. DIt never appears
    Answer: A. One instruction at a time: the drive, the wait and the stop all happen before the last print.
  5. [1 mark]You press Run a second time. Where does the program start?

    1. AFrom the first line again
    2. BFrom where it stopped last time
    3. CFrom the last line
    4. DIt remembers and skips the lines it already ran
    Answer: A. A program does not remember what happened last time. Every run is a fresh start from the top.
  6. [1 mark]Which of these instructions make the robot do something, rather than just print?

    Tick every answer that is true.

    1. Aforward(50)
    2. Bstop()
    3. Cprint("hello")
    4. Dwait(1)
    Answer: A, B, D. print only talks. forward and stop act on the motors, and wait pauses the program while the robot carries on.
  7. [1 mark]What is the difference between an algorithm and a program?

    1. AA program is an algorithm written in a language a computer can run
    2. BThey are two words for exactly the same thing
    3. CAn algorithm always runs faster
    4. DA program is only for robots
    Answer: A. An algorithm is the set of steps that solves a problem. Written in a programming language, it becomes a program.

The task: your first program

Make the robot print three lines. One of them must be exactly I am a BugBot. The robot should not drive.

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

print("...")

The hint students can ask for: Print three lines. One of them must be exactly: I am a BugBot

A solution

from bugbot import *
connect()
print('hello')
print('I am a BugBot')
print('bye')

Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.