Programming basics · GCSE · OCR J277 2.3.1, AQA 8525 3.2.2, Edexcel 1CP2 6.1.4 · about 10 min
Comments, names, blank lines: code a person can read and change.
[1 mark]What does Python do with a line that starts with #?
[1 mark]What does this program print?
print("before")
# print("middle")
print("after")[1 mark]Which comment is the most useful?
led("red") # warn: battery is lowled("red") # set the LED to redled("red") # ledled("red") # a line of code[1 mark]What do blank lines between parts of a program change about how it runs?
[1 mark]Why do programmers comment a line out instead of deleting it?
[1 mark]Which of these make a program easier to maintain?
Tick every answer that is true.
Write a program that turns the LED on, drives forward for a second, stops, turns the LED off and prints done. Put a comment above each part saying what it is for, and a blank line between the parts.
# the two lines every program starts with: the commands, then the robot from bugbot import * connect() # ...
Plan your program here, then type it in and press Run.
stop() in a driving program. What stops the robot in the end?