Question 11 mark
What does this program print?
total = 0
for i in range(1, 5):
if i % 2 == 0:
total = total + i
print(total)SL, Paper 2 · Theme B: computational thinking and problem-solving
Questions for SL. · The lesson
What does this program print?
total = 0
for i in range(1, 5):
if i % 2 == 0:
total = total + i
print(total)The values 4, 7 and 9 are pushed onto an empty stack in that order. Two values are then popped. Which value is popped second?
An invented school trip program records, for each student, whether a signed permission form has been returned. Which data type fits this value best?
The program takes a substring of a word and joins a number to it. What does it print?
word = "PROGRAMMING"
part = word[3:7].lower()
print(part + str(len(word)))This code should print the whole-number average of the four marks (integer division: // in Python, / between two ints in Java). The total is 30, so it should print 7, but it prints 6. Which change fixes it?
marks = [6, 8, 7, 9]
total = 0
for i in range(1, len(marks)):
total = total + marks[i]
print(total // len(marks))