Final test
For the final test recall the four parts of the course. Logic: and, or, not, implication and equivalence, truth tables. Algorithm and model: the stages of solving a task, linear, branching and repeating algorithms, the flowchart. Python: variables and types, input() returning a string, arithmetic operations (// and % are especially important), strings and slices, the sep and end arguments of print(). Control: if/elif/else, for with range(), while with a condition, break and continue, functions (def, return, parameters), local and global variables, import and modules (random, math), tkinter windows. When solving a task first find the input and output data, work out 1–2 examples by hand, then write the code and test it with the same examples. Read an error message from the end. When writing code pay attention to every indent and colon.
At the end of the course a team planned a project on paper: logic, algorithm, loop, function. They checked each part separately and then joined them. Thanks to the plan, everyone knew their role.
Project leaders, programmers and team members split big work into parts, check each one and then combine them.
Pick one small project, such as a daily schedule, split it into five parts and write the plan on paper. Nothing needs to be downloaded.
1def kvadratlar(n): 2 s = 0 3 for i in range(1, n + 1, 2): 4 s += i ** 2 5 return s 6print(kvadratlar(7))
84
1x = int(input()) 2m = 0 3while x > 0: 4 if x % 10 > m: 5 m = x % 10 6 x //= 10 7print(m) 8 9print("TOSHKENT"[::2])
8 TSKN
“Self-assessment”: each pupil marks a list of 12 course topics with “I know”, “partly” or “I will revise”; pairs make each other one task from each “partly” topic.
1def f(n): 2 if n < 2: 3 return n 4 return f(n - 1) + f(n - 2)