Worksheets › Class 11 › Getting Started with Python › Cheat sheet

Class 11 Getting Started with Python: cheat sheet

CBSE Computer Science. Python’s identifiers and keywords, data types, operators and their precedence, type conversion, input and print, and syntax, runtime and logical errors.

Open the printable cheat sheetPractice worksheet

Key ideas

Remember

// and %17 // 5 = 3, 17 % 5 = 2; −17 // 5 = −4, −17 % 5 = 3
They always fita = b × (a // b) + a % b
Precedence5 + 3 * 2 = 11; 2 ** 3 ** 2 = 512; −3 ** 2 = −9
Floats10 / 5 = 2.0; 7 // 2.0 = 3.0; 4 + 1.0 = 5.0; True + 4 = 5
round()a tie goes to the even neighbour: round(2.5) = 2, round(3.5) = 4
Conversionint('12') + 3 = 15; str(4) + str(2) = '42'; int(7.9) = 7
and, or5 and 9 gives 9; 0 and 9 gives 0; 5 or 9 gives 5; 0 or 9 gives 9
print()print(1, 2, sep='-') prints 1-2; end='' stops the new line

Watch out

Worked example

What does this program print? Give (a) the first line (b) the second. a = 23 b = 1 - 23 print(a // b) print(a % b)

Working: a = 23, b = −22: // rounds down (towards minus infinity), and a = b × (a // b) + a % b

Answer: (a) −2; (b) −21

Practise Getting Started with Python

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

Coming soon for Android and iPhone.