The worksheetDownload the PDF
Answers

F1.2 Output: print

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

BugBotLab

What this lesson is about

Print text and numbers, several things at once.

Questions 6 marks in all

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

    print("one", "two", "three")
    Answer:
    one two three

    Commas between things in one print put a single space between them.

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

    print("a" "b")
    Answer:
    ab

    Two strings side by side with no comma are glued together into one string, so there is no space.

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

    print("above")
    print()
    print("below")
    Answer:
    above
    
    below

    print() with nothing inside prints an empty line.

  4. [1 mark]What is the difference between 42 and "42"?

    1. A42 is a number and "42" is text that looks like a number
    2. BThere is no difference
    3. C"42" is a bigger number
    4. D42 is text and "42" is a number
    Answer: A. Quotes make text. Numbers do not need quotes, and the difference matters as soon as you do arithmetic.
  5. [1 mark]You want to print: BugBot's LED is green. Which line works?

    1. Aprint("BugBot's LED is green")
    2. Bprint('BugBot's LED is green')
    3. Cprint(BugBot's LED is green)
    4. Dprint("BugBot's LED is green)
    Answer: A. Text containing an apostrophe goes inside double quotes, so the apostrophe does not end the string early. The opening and closing quotes must match.
  6. [1 mark]What does this program print?

    print("the answer is", 6 * 7)
    Answer:
    the answer is 42

    The calculation is worked out first, and print shows the text and the number with a space between them.

The task: say hello

Print exactly three lines: - Hello from BugBot - 1 2 3 (three numbers, one print, commas between them) - BugBot BugBot BugBot (the word three times from one print)

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

print("Hello from BugBot")

The hint students can ask for: Three lines, each from one print: the greeting, the numbers 1 2 3 separated by commas in the print, and the word BugBot three times.

A solution

from bugbot import *
connect()
print('Hello from BugBot')
print(1, 2, 3)
print('BugBot', 'BugBot', 'BugBot')

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