Test: Python basics
Before the test recall the main rules. A variable name starts with a letter or an underscore, is not a keyword, and capital and small letters differ. input() returns a string: if a number is needed, int() or float() is written. // and % are for whole division and the remainder; the last digit of a number is x % 10 and the tens digit is x // 10 % 10. In conditions do not forget the difference between == (comparison) and = (assignment); and/or/not make compound conditions; after if and else come a colon and an indent of 4 spaces. In the loop for i in range(a, b), b is not included; a sum starts from 0 and a product from 1. If you see an error, read the message from the end and find the line number. Always check the answer by hand on a small example.
Before a test a pupil summarised all topics on one sheet and listed personal mistakes. During revision the pupil gave more time to the topics with the most mistakes.
Students, people preparing for professional exams and programmers write down their mistakes and focus revision on them.
Write the mistakes from your last three exercises on paper and explain in one sentence why each happened.
1x = int(input()) 2print(x // 100 % 10) 3 4ism = input() 5print("Omad,", ism, end="!")
8 Omad, Aziz!
1x = 5 2if x = 5: 3 print(x)
SyntaxError
“Mini test”: pairs write 4 short tasks in each other’s notebook (variable, type, if, for) and hide the answers; the partner solves them and then they check together.