Programming basics · GCSE · OCR J277 2.2.1, AQA 8525 3.2.3, Edexcel 1CP2 6.5.1 · about 15 min
The seven operators, integer division and remainder, and the order they work in.
[1 mark]What does this program print?
print(20 / 5)
[1 mark]What does this program print?
print(10 // 4) print(10 % 4)
[1 mark]What is the value of 2 + 3 * 4?
[1 mark]What is the value of (2 + 3) * 4?
[1 mark]Which of these is a float?
4.04-3100[1 mark]x % 2 is 0 when x is even. What is it when x is odd?
[1 mark]What does this program print?
print(round(10 / 3, 2))
[1 mark]What is the value of 17 // 5?
[1 mark]What is the value of 17 % 5?
[1 mark]What does this program print?
print(2 * 3 ** 2)
[1 mark]What does this program print?
seconds = 135 print(seconds // 60, seconds % 60)
Using only the numbers 17 and 5 in your calculations, print four lines: divide: 3.4, DIV: 3, MOD: 2 and power: 25 (the power is 5 to the power 2). Work each one out with an operator; do not type the answers. The robot must not drive.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
print("divide:", 17 / 5)Plan your program here, then type it in and press Run.
input and print it as minutes and seconds.-7 // 2 and -7 % 2. The answers surprise most people. Work out the rule Python is using.