☰ Year plan · Communication Technology

Formulas, comparisons and loops

Week 3 · Unit 1, Lesson 1 Computational Thinking and Problem Solving (3) · 3 lessons
Answers are for parents and teachers.
1
Write the perimeter line for a rectangle with length 7 and width 2 and say the result.
2
Change the larger-of-two program so that it shows the smaller number. Which line changes, and what does it show for 12 and 5?
Python
1a = int(input("First number: "))
2b = int(input("Second number: "))
3if a > b:
4    print(a)
5else:
6    print(b)
3
Fill the trace table for total = 0 and for i in range(1, 4): total += i. How many rows are there, and what is the final total?
AB
1itotal after adding
21
32
43
4
Mona’s marks are 45, 60 and 52. The rule is: pass if the average is at least 50. What does the idea of the program show, and who decided the rule?
5
A friend writes for i in range(1, 5) to add the numbers 1 to 5. What goes wrong and how do you fix it?