Skip to content
Computer ScienceISC Class 11 · Introduction to Python

Python Basics: Data Types, Operators and Type Conversion (ISC Class 11)

Updated 17 October 2026 · Fact-checked

Python is an interpreted, dynamically typed language. A program is made of tokens (keywords, identifiers, literals, operators, punctuators). Variables hold references to objects whose type comes from the value. Numbers, strings and tuples are immutable; lists and dictionaries are mutable. Operators follow precedence (** highest, then * / // %, then + -, then comparisons, then not, and, or); / always gives a float, // floors the result and % takes the sign of the divisor.

Operators higher on the ladder run first; equal levels go left to right, except ** which goes right to left.

Illustration drawn for QuestionBuddy.

Understand Python: Tokens, Variables, Data Types, Operators, Precedence and Type Conversion

Tokens. Keywords (if, else, for, while, True, None), identifiers (names: letters, digits and underscore; not starting with a digit; not a keyword; case-sensitive), literals (constants such as 25, 3.5, 'text', True), operators and punctuators. Comments start with #.

Variables. A variable is a name bound to an object; no declaration is needed: x = 10 then x = 'ten' is allowed (dynamic typing). The *l-value* is the name on the left of =, the *r-value* is the expression on the right. type(x) gives the type.

Data types. int (any size), float, complex, bool (True, False), str, list, tuple, dict, NoneType.

  • *Immutable* (cannot change in place): int, float, bool, str, tuple.
  • *Mutable:* list, dict, set.
a = [1, 2, 3]
b = a            # same object
b.append(4)
print(a)         # [1, 2, 3, 4]

Input and output. print(a, b, sep=' ', end='\n'); input(prompt) returns a string, so convert: n = int(input('n: ')).

Operators. Arithmetic: + - * / (float division) // (floor division, rounds down) % (remainder, sign of the divisor) (power, right-associative). Relational: < <= > >= == != (can be chained: 1 < x < 5). Logical: and, or, not (and/or return one of the operands: 0 and 5 gives 0; 7 or 0 gives 7). Assignment and augmented: = += -= *= //= %= =. Membership: in, not in. Identity: is, is not.

Precedence (high to low). ( ) ; ; unary - ; * / // % ; + - ; comparisons; not; and; or. Operators of the same level go left to right, except .

Type conversion. *Implicit:* int op float gives float; True counts as 1. *Explicit:* int(3.9) is 3 (truncates), float(7) is 7.0, str(5) is '5', int('12') is 12, bool(0) is False.

Python: Tokens, Variables, Data Types, Operators, Precedence and Type Conversion: key facts

Division operators
  • a / b: float
  • a // b: floor of the quotient
  • a % b = a - b x (a // b)
Check the sign.
Precedence
  • Power first
  • multiply, divide, floor-divide, remainder
  • add, subtract
  • comparisons
  • not
  • and
  • or
Left to right at the same level; power goes right to left.
Conversions
  • int(3.9) = 3
  • float(7) = 7.0
  • str(5) = '5'
  • bool(0) = False
Explicit casting.

How to answer Python: Tokens, Variables, Data Types, Operators, Precedence and Type Conversion questions

Evaluate by precedence, step by step, writing the type of each result.

  1. 1Mark the operators and their precedence.
  2. 2Evaluate the highest first; at the same level go left to right (power right to left).
  3. 3Track the type: int, float, str, bool.
  4. 4For lists, track aliases (two names for one object).

Python: Tokens, Variables, Data Types, Operators, Precedence and Type Conversion in real life

The idea, met in an everyday situation. Answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.

Aliases

Suppose a teacher keeps a list of marks marks = [60, 70] and a helper makes backup = marks so that she can "save" the original, and then appends 80 to backup.

What does marks contain?

Try it first, then show the solutionSolution
  1. backup = marks makes both names refer to one list.
  2. The append through backup changes that list: marks is [60, 70, 80].

Answer: [60, 70, 80]: no real backup was made; use marks.copy() or marks[:].

Memory hook: Assignment of a list copies the name, not the list.

Tricks to remember Python: Tokens, Variables, Data Types, Operators, Precedence and Type Conversion

Short memory aids. Say each one aloud once, then use it on a question the same day.

  • Floor goes down

    -17 // 5 is -4, not -3.

    Use it when: //.

  • Remainder takes the divisor's sign

    -17 % 5 is 3; 17 % -5 is -3.

    Use it when: %.

  • Power from the right

    2 3 2 is 2 ** 9 = 512.

    Use it when: **.

Python: Tokens, Variables, Data Types, Operators, Precedence and Type Conversion: solved examples

Ordered from board level to HOTS. Try each one before you open the solution.

Example 1: Mutable type · 1 mark · MCQBoard level

Which of the following is a mutable data type in Python?
(a) tuple (b) str (c) list (d) int

Try it first, then show the solutionSolution
  1. Lists can be changed in place.

Answer: (c) list

Example 2: Operators · 2 marks · Short answerBoard level

Give the output: a = 17; b = 5; print(a // b, a % b, a / b, a ** 2) (2 marks)

Try it first, then show the solutionSolution
  1. 17 // 5 = 3; 17 % 5 = 2; 17 / 5 = 3.4; 17 ** 2 = 289.

Answer: 3 2 3.4 289

Example 3: Negative numbers and precedence · 6 marks · Short answerHarder board level

Evaluate: (a) -17 // 5 (b) -17 % 5 (c) 17 // -5 (d) 17 % -5 (e) 2 + 3 * 4 2 // 5 (f) 2 3 ** 2. (6 marks)

Try it first, then show the solutionSolution
  1. (a) floor of -3.4 = -4. (b) -17 - 5 x (-4) = 3.
  2. (c) floor of -3.4 = -4. (d) 17 - (-5)(-4) = 17 - 20 = -3.
  3. (e) 4 ** 2 = 16; 3 * 16 = 48; 48 // 5 = 9; 2 + 9 = 11.
  4. (f) power is right-associative: 3 2 = 9; 2 9 = 512.

Answer: (a) -4; (b) 3; (c) -4; (d) -3; (e) 11; (f) 512

Example 4: Type conversion and logical operators · 4 marks · Short answerHarder board level

Give the output: print(int(3.9), float(7), str(5) + '3', '5' * 3, 1 + True, bool(0), 0 and 5, 7 or 0, int('12') + 3) (4 marks)

Try it first, then show the solutionSolution
  1. int(3.9) = 3; float(7) = 7.0; str(5) + '3' = '53' (printed 53); '5' * 3 = 555.
  2. 1 + True = 2; bool(0) = False.
  3. 0 and 5 returns 0; 7 or 0 returns 7; int('12') + 3 = 15.

Answer: 3 7.0 53 555 2 False 0 7 15

Example 5: Aliases and immutability · 5 marks · Long answerHOTS / competency

Give the output and explain: s = 'abc'; t = s; t = t + 'd'; print(s, t); x = [1, 2]; y = x; y.append(3); z = x + [4]; print(x, y, z). What happens with s[0] = 'z'? (5 marks)

Try it first, then show the solutionSolution
  1. Strings are immutable: t + 'd' makes a new string; s stays 'abc', t is 'abcd'.
  2. Lists are mutable: y is the same list as x; after append, x and y are [1, 2, 3]; x + [4] creates a new list z = [1, 2, 3, 4].
  3. s[0] = 'z' raises TypeError because a string does not support item assignment.

Answer: abc abcd
[1, 2, 3] [1, 2, 3] [1, 2, 3, 4]
s[0] = 'z' raises TypeError (strings are immutable).

Where students lose marks in Python: Tokens, Variables, Data Types, Operators, Precedence and Type Conversion

The slips examiners see most often, and what to write instead.

  • Mistake: Truncating instead of flooring negative numbers

    C habit.

    Wrong working

    -17 // 5 = -3

    Right working

    -4

    Do this: // floors.

    Usually costs: 1-2 marks.

  • Mistake: Reading input() as a number

    Forgetting conversion.

    Wrong working

    n = input(); n * 2 with n = 7 gives 14

    Right working

    n = '7'; n * 2 = '77'

    Do this: Use int(input()).

    Usually costs: 2 marks.

  • Mistake: Left-to-right power

    Same level rule.

    Wrong working

    2 3 2 = 64

    Right working

    512

    Do this: ** is right-associative.

    Usually costs: 1-2 marks.

Exam tips

  • Write each evaluation step in tracing questions.
  • Show the type of the result for / and //.
  • State that a list assignment copies the reference.

Practice questions on Python: Tokens, Variables, Data Types, Operators, Precedence and Type Conversion

Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.

  1. Q1 · 1 mark · MCQBoard level

    The data type of the result of 7 / 2 in Python 3 is:
    (a) int (b) float (c) str (d) bool

    Hint

    True division.

    Answer

    (b) float (the value is 3.5)

  2. Q2 · 2 marks · Short answerBoard level

    Give the output: x = 14; y = 4; print(x // y, x % y, x / y, x ** 2 % 10) (2 marks)

    Hint

    196 % 10.

    Answer

    3 2 3.5 6

  3. Q3 · 6 marks · Long answerHarder board level

    Evaluate and show steps: (a) 10 - 4 * 2 ** 2 // 3 (b) not 3 > 5 or 2 == 2 and 1 > 3 (c) 7 // 2 * 2 + 7 % 2 (d) -9 // 4 + -9 % 4. (6 marks)

    Hint

    Precedence.

    Answer

    (a) 2 ** 2 = 4; 4 * 4 = 16; 16 // 3 = 5; 10 - 5 = 5. (b) 3 > 5 is False; not False is True; the right part: 2 == 2 is True and 1 > 3 is False gives False; True or False = True. (c) 7 // 2 = 3; 3 * 2 = 6; 7 % 2 = 1; 6 + 1 = 7. (d) -9 // 4 = -3; -9 % 4 = 3; sum 0.

  4. Q4 · 4 marks · Short answerHarder board level

    A program reads two numbers as strings: a = input() and b = input() with the user typing 12 and 30. Give the output of print(a + b), print(int(a) + int(b)) and print(a * 2), and fix the first to give 42. (4 marks)

    Hint

    String concatenation.

    Answer

    1230; 42; 1212. To get 42, convert: print(int(a) + int(b)).

  5. Q5 · 3 marks · Short answerHOTS / competency

    A student writes: scores = [40, 50]; copy = scores; copy[0] = 99; print(scores). She expected [40, 50]. Give the output, the reason, and two ways to make a true copy. (3 marks)

    Hint

    Alias.

    Answer

    Output: [99, 50]. copy = scores binds a second name to the same list. A true copy: copy = scores.copy() or copy = scores[:] (also list(scores)).

Test your recall

Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.

  1. 1./ always gives?Show answer

    float.

  2. 2.// rounds?Show answer

    Down (floor).

  3. 3.Mutable types?Show answer

    list, dict, set.

  4. 4.input() returns?Show answer

    A string.

  5. 5.Power associativity?Show answer

    Right to left.

Python: Tokens, Variables, Data Types, Operators, Precedence and Type Conversion: frequently asked questions

Is Python case-sensitive?

Yes.

Do I declare variables?

No, assignment creates them.

What does type() do?

Returns the type of a value.

What is a keyword?

A reserved word like if.