☰ Year plan · Communication Technology

Algorithms and Python (1)

Week 11 · Chapter 12 Programming (1): algorithms and flowcharts, Python basics: variables, arithmetic, input, loops and branching · 3 lessons
Answers are for parents and teachers.
1
What does this program print? Trace the variable first.
Python
1total = 0
2for i in range(1, 4):
3    total = total + i * 2
4print(total)
2
A program has x = 10 and prints x / 4, x // 4 and x % 4. Write the three outputs.
3
Write a Python program that prints the numbers 5, 4, 3, 2, 1 with a while loop.
4
Spot the mistake in this program and write the corrected line: age = 15, then if age = 18: print("adult").
5
Draw the flowchart of a program that reads a mark and shows “pass” if the mark is at least 50, otherwise “fail”. Which structure is it?