Worksheets › Class 9 › Python Basics › Cheat sheet

Class 9 Python Basics: cheat sheet

CBSE Computational Thinking and AI. Python stores values in variables, works them out with operators in a fixed order, and has four basic types: int, float, str and bool.

Open the printable cheat sheetPractice worksheet

Key ideas

Remember

Precedence5 + 3 * 2 = 11; (5 + 3) * 2 = 16; 2 ** 3 = 8
// and %17 // 5 = 3; 17 % 5 = 2 (17 = 5 × 3 + 2)
/ is a float10 / 5 gives 2.0
Last digit; drop itx % 10 and x // 10: 4923 → 3 and 492
Text and numbersint('12') + 3 = 15; str(4) + str(2) = '42'; 'ab' * 3 = 'ababab'
Tracingx = 7 x += 3 print(x // 4, x % 4) # 2 2

Watch out

Worked example

For x = 4923, what is (a) x % 10 (b) x // 10?

Working: % 10 gives the last digit; // 10 removes it

Answer: (a) 3; (b) 492

Practise Python Basics

Revise with this page, then practise: every Python Basics sheet in the app is new, with an answer key and working.

Coming soon for Android and iPhone.