Strings, lists and records · GCSE · OCR J277 2.2.3, AQA 8525 3.2.8, Edexcel 1CP2 6.3.3 · about 15 min
Length, indexing, slicing, searching and joining strings, and f-strings.
[1 mark]What does this program print?
first = "Bug"
second = "Bot"
print("Hello, " + first + second + ".")[1 mark]What happens with print("battery: " + 92)?
[1 mark]What does this program print?
speed = 45
print(f"driving at {speed} and half is {speed / 2}")[1 mark]What does this program print?
word = "BugBot" print(len(word)) print(word.upper())
[1 mark]What does this program print?
print("-" * 5)[1 mark]What does this program print?
print(f"{10 / 3:.2f}")[1 mark]What does this program print?
word = "BugBot" print(word[0], word[3], word[-1])
[1 mark]What does this program print?
word = "BugBot" print(word[1:4])
[1 mark]What does this program print?
message = "wall ahead"
print(message.find("ahead"), message.find("ball"))[1 mark]OCR's name.substring(3, 3) on "BugBot" gives "Bot". What does the second 3 mean?
[1 mark]What is joining two strings together called?
Drive 10 cm, then print one line in exactly this shape (your numbers will differ):
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
forward(50, distance=10)
x, y = position()
print(f"BugBot at x={x} ...")Plan your program here, then type it in and press Run.
-1 walks backwards.)e appears in it, using count.=.