AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Contents · Computing

Final review and test

Lessons 55 · 1 lessons · M. R. Fayziyeva, D. M. Sayfurov, N. S. Xaytullayeva. Informatics and Information Technologies, Grade 9. “Nashriyot uyi Tasvir”, Tashkent, 2020
55

Final test

Textbook: pp. 108–109
GoalReviews the main topics of the course – logic, kinds of algorithms, Python basics, conditions, loops, functions, modules and a graphical interface – and solves final tasks independently.
New words
kinds of algorithms: linear, branching (if) and repeating (for, while) · algoritm turlaricondition and loop: if/elif/else choose a path; for and while repeat commands · shart va siklfunction: def name(parameters), the result is returned with return · funksiyamodule: ready code loaded with import, for example random, math, tkinter · modul
Explanation

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.

LogicAlgorithm andmodelPythonControlParts of thecourse
💡 Where will I use this?
In real life

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.

Who uses it

Project leaders, programmers and team members split big work into parts, check each one and then combine them.

Try it today

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.

Worked examples
Python
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))
Output
84
A function and a loop – code above. The sum of the squares of 1, 3, 5, 7: 1 + 9 + 25 + 49 = 84.
Python
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])
Output
8
TSKN
The largest digit – the first program above. If 5826 is typed, the digits are checked one by one from the end and 8 is printed. A slice with a step – the second program above. It takes the letters with indexes 0, 2, 4, 6: TSKN.
Class activity

“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.

Practice
1
What is the result of a program that finds the sum 3 + 6 + 9 + … + 60?
2
Write a single print() that prints every second letter (starting from index 0) of the string "SAMARQAND" using a slice. What is the result?
3
For the following function, what is f(6)?
Python
1def f(n):
2    if n < 2:
3        return n
4    return f(n - 1) + f(n - 2)
4
When is for chosen and when while? Explain with examples.
Story of the Week · The Khwarizmi WayThe end of the year and a summer planClose the week: all of this week’s subjects in one storyRead →