Skip to content
Computer ScienceCBSE Class 11 · Chapter 5

Getting Started with Python Class 11: Tokens, Data Types, Operators and Errors

Updated 14 October 2026 · Fact-checked

Getting Started with Python is the first programming chapter of CBSE Class 11 Computer Science. It covers Python's features and execution modes, tokens, variables, comments, the data types and which are mutable, all operator groups with precedence, expressions, type conversion, input() and print(), and the three kinds of errors: syntax, logical and run-time.

What Getting Started with Python is about

This chapter is the base of Unit II, Computational Thinking and Programming - 1, which carries 45 of the 70 theory marks in the school annual exam together with the other programming chapters. Questions ask you to name tokens, find valid identifiers, evaluate expressions, predict output, find and correct errors and write short programs.

The 2026-27 syllabus lists: introduction and features of Python, a "hello world" program, interactive and script modes, the character set, tokens (keyword, identifier, literal, operator, punctuator), variables, l-value and r-value, comments; data types Number (int, float, complex), boolean, sequence (string, list, tuple), None, mapping (dictionary), mutable and immutable types; arithmetic, relational, logical, assignment, augmented assignment, identity and membership operators; precedence, expressions and their evaluation, explicit and implicit type conversion, input and output; and syntax, logical and run-time errors.

Every program on this page has been run in Python 3 and the outputs shown are the real ones. Practise by typing each into IDLE before reading the answer.

Weightage: This chapter is part of Unit II, Computational Thinking and Programming - 1, which carries 45 of the 70 theory marks in the school annual exam together with Introduction to Problem Solving, Flow of Control, Strings, Lists, Tuples and Dictionaries and Introduction to Python Modules.Source: CBSE Computer Science (083) syllabus 2026-27, Class XI distribution of marks, Unit II Computational Thinking and Programming - 1

Key concepts

Python, its features and execution modes
NCERT section NCERT 5.1

A program is an ordered set of instructions for a computer; Python is the language used for programs in this course. Its main features:

  • high-level, free and open source
  • interpreted: the Python interpreter (also called the Python shell) runs the program statement by statement
  • simple, clearly defined syntax, so programs are easy to read
  • case-sensitive: NUMBER and number are different names
  • portable (platform independent): the same program runs on Windows, Linux or macOS
  • a large standard library of ready-made functions and modules
  • uses indentation to mark blocks, as in if statements and loops

There are two execution modes:

  • Interactive mode: type one statement at the >>> prompt and its result appears at once. Good for testing small pieces; the statements are not saved.
  • Script mode: write many statements in a file saved with the extension .py and run the whole file (in IDLE: Run > Run Module, or F5). Good for full programs that you want to keep.

The first program: print('Hello World').

Worked example

Which mode would you use, and why: (a) quickly checking the value of 17 // 5; (b) writing a 30-line program to prepare a class result that will be run every term?

Try it first, then show the solutionSolution
  1. A one-line check needs an instant answer and need not be saved: interactive mode.
  2. A long program that must be kept and run again: script mode, saved as a .py file.

Answer: (a) Interactive mode (it shows 3 at once). (b) Script mode.

Character set and tokens
NCERT section NCERT 5.2, 5.3 and the CBSE syllabus (character set, tokens)

The character set is the set of characters Python recognises: letters A-Z and a-z, digits 0-9, special symbols such as + - * / ( ) [ ] { } = , : ' " # and whitespace (space, tab, newline). Python 3 also accepts Unicode characters inside strings.

The smallest meaningful unit of a program is a token. Python has five kinds:

  • Keywords: reserved words with a fixed meaning, such as if, else, for, while, True, False, None, and, or, not, in, is, import. They are case-sensitive and cannot be used as names.
  • Identifiers: names given to variables, functions and other objects.
  • Literals: fixed values written directly, such as 25, 3.14, 2+3j, 'Delhi', True, None.
  • Operators: symbols or words that act on values, such as +, **, ==, and, in.
  • Punctuators (delimiters): symbols that organise code, such as ( ) [ ] { } , : ; . and the # that starts a comment.

Rules for identifiers: start with a letter or an underscore; then any letters, digits or underscores; no spaces or other special symbols (@, %, -, !); cannot be a keyword; case-sensitive; any length.

Worked example

Which identifiers are valid? total_marks, 2ndTerm, _count, roll-no, For, for, my name, Amount@

Try it first, then show the solutionSolution
  1. total_marks and _count follow the rules.
  2. For is valid (keywords are lowercase; For is a different word).
  3. 2ndTerm starts with a digit; roll-no has a hyphen; my name has a space; Amount@ has @; for is a keyword.

Answer: Valid: total_marks, _count, For. Invalid: 2ndTerm, roll-no, for, my name, Amount@.

Variables, l-value and r-value, and comments
NCERT section NCERT 5.4, 5.5, 5.6; CBSE syllabus (l-value and r-value)

A variable is a name that refers to an object (a value) stored in memory. It is created by an assignment statement: price = 45. A variable need not be declared first and its type comes from the value it refers to, so the same name can later refer to a value of another type. A variable must be assigned before it is used.

In an assignment, the l-value is what can appear on the left of =: something that can be assigned to, such as a variable name. The r-value is the expression on the right, which is evaluated to give a value. So x = y + 2 is valid, but y + 2 = x and 5 = x are errors, because an expression or literal cannot be an l-value.

Python allows multiple assignment: a = b = 0 and x, y = 10, 20; x, y = y, x swaps two values. Every object has a unique identity returned by id(), which stays the same for the object's lifetime.

Comments are notes for people; the interpreter ignores them. A single-line comment starts with #. A string in triple quotes on its own line is often used as a multi-line note (docstring). Good comments explain why the code does something.

Worked example

Find the output:

a, b = 5, 9
a, b = b, a + b
print(a, b)
Try it first, then show the solutionSolution
  1. The right side is evaluated first using the old values: (9, 5 + 9) = (9, 14).
  2. Then a = 9 and b = 14.

Answer: 9 14

Data types
NCERT section NCERT 5.7

Every value has a data type, which decides what values it can hold and what operations work on it. type(x) tells the type.

  • Number: int (whole numbers of any size, e.g. -12, 0, 125), float (numbers with a decimal point, e.g. 4.0, -2.04, 1.5e3) and complex (a + bj, e.g. 3+4j, where j is the square root of -1).
  • Boolean (bool): only True and False; they behave as 1 and 0 in arithmetic.
  • Sequence: ordered, indexed collections. String (str): characters in single, double or triple quotes, 'Hello'. List: items of any types in square brackets, [10, 'a', 2.5]. Tuple: items in round brackets, (10, 'a', 2.5).
  • None (NoneType): the single value None, meaning no value; it is not the same as 0, False or ''.
  • Mapping: dictionary (dict): key: value pairs in curly brackets, {'roll': 7, 'name': 'Asha'}; keys must be unique and of an immutable type.

(NCERT also mentions sets: unordered collections with no duplicates, in curly brackets.)

Use a list for data that changes often, a tuple for fixed data (months of the year), and a dictionary for fast lookup by a key.

Worked example

Give the output:

print(type(7), type(7.0), type('7'), type(7 > 3))
print(type(None), type([7]), type((7,)), type({7: 'seven'}))
Try it first, then show the solutionSolution
  1. 7 is int, 7.0 is float, '7' is str, 7 > 3 gives True, a bool.
  2. None is NoneType; [7] is a list; (7,) is a one-item tuple (the comma makes it a tuple); {7: 'seven'} is a dict.

Answer: <class 'int'> <class 'float'> <class 'str'> <class 'bool'>
<class 'NoneType'> <class 'list'> <class 'tuple'> <class 'dict'>

Mutable and immutable types
NCERT section NCERT 5.7.6

A mutable object can be changed in place after it is created; an immutable object cannot.

  • Immutable: int, float, complex, bool, str, tuple (and None).
  • Mutable: list, dictionary (and set).

When you 'change' an immutable value, Python actually makes a new object and the variable now refers to it, so its id() changes. Changing a list in place keeps the same object and the same id(). Trying to change one character of a string or one item of a tuple gives a TypeError.

Worked example

Predict the output:

L = [1, 2, 3]
old = id(L)
L[0] = 10
print(L, id(L) == old)
n = 5
old = id(n)
n = n + 1
print(n, id(n) == old)
Try it first, then show the solutionSolution
  1. L[0] = 10 changes the same list object in place: same id.
  2. n + 1 creates a new int object 6; n now refers to it: different id.

Answer: [10, 2, 3] True
6 False

Arithmetic, relational and logical operators
NCERT section NCERT 5.8.1, 5.8.2, 5.8.4

Arithmetic: +, -, *, / (true division, always gives a float: 7 / 2 = 3.5), // (floor division: the quotient rounded down, 7 // 2 = 3 and -7 // 2 = -4), % (remainder: 7 % 2 = 1), ** (power: 2 ** 3 = 8). + also joins strings and * repeats them: 'ab' * 3 = 'ababab'.

Relational: ==, !=, >, <, >=, <=; they give True or False. Strings are compared character by character by their codes, so 'Apple' < 'apple' (65 < 97).

Logical: and, or, not. Every value is either truthy or falsy: None, False, 0, 0.0 and empty collections ('', [], (), {}) are false; everything else is true. and and or short-circuit: x and y gives x if x is false, otherwise y; x or y gives x if x is true, otherwise y. So 0 and 5 gives 0, and 0 or 5 gives 5.

Worked example

Evaluate: (a) 17 // 5, 17 % 5, -17 // 5, -17 % 5 (b) 'cat' < 'Cat' (c) 3 and 0 (d) '' or 'none'

Try it first, then show the solutionSolution
  1. (a) 17 = 5 × 3 + 2 → 3 and 2. -17 / 5 = -3.4, rounded down → -4; -17 = 5 × (-4) + 3 → remainder 3.
  2. (b) 'c' (99) < 'C' (67) is False.
  3. (c) 3 is true, so and gives the second value, 0.
  4. (d) '' is false, so or gives the second value, 'none'.

Answer: (a) 3, 2, -4, 3 (b) False (c) 0 (d) 'none'

Assignment, augmented assignment, identity and membership operators
NCERT section NCERT 5.8.3, 5.8.5, 5.8.6

Assignment = stores the value of the right side in the name on the left. Augmented assignment combines an operation with assignment: x += 3 means x = x + 3; likewise -=, *=, /=, //=, %=, **=.

Identity operators is and is not check whether two names refer to the same object (same id()), not just equal values. == checks equal values. Use is mainly with None: if x is None:.

Membership operators in and not in check whether a value is present in a sequence or a dictionary's keys: 'a' in 'cat' is True; 3 in [1, 2, 3] is True; 'roll' in {'roll': 5} is True (keys are checked, not values).

Worked example

Predict the output:

A = [1, 2]
B = A
C = [1, 2]
print(A == C, A is C, A is B)
x = 10
x //= 3
x **= 2
print(x, 2 in A, 'b' not in 'abc')
Try it first, then show the solutionSolution
  1. A and C have equal values but are different objects; B refers to the same object as A.
  2. x //= 3 gives 3; x **= 2 gives 9.
  3. 2 is in A; 'b' is in 'abc', so not in gives False.

Answer: True False True
9 True False

Expressions, statements and precedence
NCERT section NCERT 5.9, 5.10, Table 5.9

An expression is a combination of values, variables and operators that evaluates to a value (a single value or variable is also an expression). A statement is a unit of code that Python can execute, such as an assignment or a print() call.

Precedence (highest to lowest):
1. () brackets
2. ** (evaluated right to left: 2 3 2 = 2 ** 9 = 512)
3. unary +, - (so -2 2 = -4, because comes first)
4. *, /, //, %
5. binary +, -
6. relational <, <=, >, >=, ==, !=
7. identity is, is not and membership in, not in
8. not, then and, then or
Operators of equal precedence are evaluated left to right (except **). The assignment operators come after all of these: the whole right side is evaluated before it is stored.

Worked example

Evaluate step by step: 15 - 4 * 3 ** 2 // 5 + 7 % 3

Try it first, then show the solutionSolution
  1. first: 3 2 = 9.
  2. Then *, //, % left to right: 4 * 9 = 36; 36 // 5 = 7; 7 % 3 = 1.
  3. Then - and + left to right: 15 - 7 = 8; 8 + 1 = 9.

Answer: 9

Type conversion and input/output
NCERT section NCERT 5.11, 5.12

Implicit conversion (coercion) is done by Python automatically when it is safe: in 10 + 2.5 the int is promoted to float, giving 12.5 (a wider type, so no information is lost). Explicit conversion (type casting) is written by the programmer with int(), float(), str(), bool() and others. It may lose information: int(20.67) gives 20 (the fraction is cut off, not rounded). int('25') works but int('2.5') and int('abc') give a ValueError.

input(prompt) shows the prompt and returns whatever the user types as a string. Convert it to do arithmetic: n = int(input('Enter n: ')).

print() displays values separated by a space and ends with a newline. Its options sep and end change these: print(1, 2, 3, sep='-') gives 1-2-3, and end='' keeps the next output on the same line. print('Total: ' + str(70)) needs str(), since a string and an int cannot be joined with + (TypeError).

Worked example

If the user types 12 and then 5, what does this print?

a = input('First: ')
b = input('Second: ')
print(a + b)
print(int(a) + int(b))
print(float(a) / int(b), int(a) // int(b), sep=' | ')
Try it first, then show the solutionSolution
  1. input() returns strings '12' and '5'; + joins them: '125'.
  2. After int(): 12 + 5 = 17.
  3. 12.0 / 5 = 2.4 and 12 // 5 = 2, joined by ' | '. (The prompts 'First: ' and 'Second: ' are also shown, each followed by what the user typed.)

Answer: First: 12
Second: 5
125
17
2.4 | 2

Errors: syntax, logical and run-time
NCERT section NCERT 5.13

Finding and removing errors (bugs) is called debugging.

  • Syntax error: the code breaks Python's grammar rules: a missing colon or bracket, a misspelt keyword, wrong indentation. Python reports it and does not run the program at all.
  • Logical error: the program runs without any message but gives the wrong output because the logic is wrong, e.g. average = a + b / 2 instead of (a + b) / 2. It is the hardest to find; dry runs and testing reveal it. It is also called a semantic error.
  • Run-time error: the program starts but stops abnormally while running because a statement cannot be carried out, e.g. division by zero (ZeroDivisionError), int('abc') (ValueError), using a name that was never assigned (NameError), adding a str to an int (TypeError).

Worked example

Name the error in each: (a) print('Hi' (b) area = 3.14 * r * 2 for the area of a circle (c) x = 10 / (5 - 5) (d) if marks > 33 print('Pass')

Try it first, then show the solutionSolution
  1. (a) Missing ) → syntax error.
  2. (b) Runs but computes 2πr, not πr² → logical error.
  3. (c) Division by zero while running → run-time error (ZeroDivisionError).
  4. (d) Missing colon after the condition → syntax error.

Answer: (a) Syntax (b) Logical (c) Run-time (d) Syntax.

Getting Started with Python in real life

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

input() returns a string

Suppose a shop's billing script asks for the quantity with qty = input('Qty: ') and then prints qty * 2 for a buy-one-get-one offer. The cashier types 3.

What is printed, and how should the line be fixed?

Try it first, then show the solutionSolution
  1. qty is the string '3'; '3' * 2 repeats it: '33'.
  2. Fix: qty = int(input('Qty: ')); then qty * 2 = 6.

Answer: It prints 33; converting with int() makes it 6.

Memory hook: input() always hands you text.

Floor division and remainder

Imagine a school trip of 125 students and buses that seat 40 each.

Use // and % to find how many buses are completely full and how many students are left for one more bus.

Try it first, then show the solutionSolution
  1. 125 // 40 = 3 full buses.
  2. 125 % 40 = 5 students left, so a fourth bus is needed.

Answer: 3 full buses and 5 students over: 4 buses in all.

Memory hook: // counts the full groups, % counts the leftovers.

Logical errors

Suppose an app computes the average of three test marks as (m1 + m2 + m3 / 3) and a student scores 60, 70 and 90.

What average does the app show, what should it be, and what kind of error is this?

Try it first, then show the solutionSolution
  1. Division is done first: 60 + 70 + 30.0 = 160.0.
  2. Correct: (60 + 70 + 90) / 3 = 220 / 3 = 73.33...

Answer: It shows 160.0 instead of about 73.33: a logical error.

Memory hook: Runs fine, answer wrong: logic is the bug.

Topics in this chapter

Getting Started with Python: syntax and key facts

Division operators
  1. 1.a / b
  2. 2.float; a // b
  3. 3.floor (rounds down); a % b
  4. 4.remainder with a == b * (a // b) + a % b
-7 // 2 = -4 and -7 % 2 = 1.
Precedence
() > ** > unary +, - > *, /, //, % > +, - > relational > is, in > not > and > or
Equal precedence: left to right, except ** (right to left).
Falsy values
False, None, 0, 0.0, '', [], (), {}
Everything else is truthy.
Short-circuit results
  1. 1.x and y
  2. 2.x if x is falsy else y; x or y
  3. 3.x if x is truthy else y
and/or return one of the operands, not always True/False.
Mutability
Immutable: int, float, complex, bool, str, tuple; mutable: list, dict
Dictionary keys must be immutable.
Conversions
int(), float(), str(), bool(); input() always returns str
int(20.9) = 20 (cuts off the fraction).

How the school exam asks Getting Started with Python

The question patterns to expect, and the method that works for each.

Question typeHow it is askedMethod
Identify tokens and valid identifiers"Identify the keywords, identifiers, literals and operators in ...", "Which of these are valid identifiers?" (1-2 marks).Check each name against the rules; remember keywords are lowercase except True, False and None.
Evaluate expressionsFind the value of an expression with mixed operators, or of and/or with non-Boolean values (1-2 marks).Apply precedence one level at a time; write each intermediate value.
Predict the outputA short program with assignments, type conversion and print() options (2-3 marks).Track each variable in a table; watch sep and end; remember / gives a float.
Find and correct errorsRewrite a program after removing syntax errors and underline the corrections (2-3 marks).Look for missing colons, brackets and quotes, wrong case, str + int, and expressions used as l-values.
Short programsInput values and compute simple interest, area, temperature conversion, swap (2-3 marks).Convert input() with int() or float(); use clear variable names; print with a label.

Tricks to remember Getting Started with Python

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

  • KILOP

    Keywords, Identifiers, Literals, Operators, Punctuators: the five token types.

    Use it when: Listing tokens.

  • Only three capital keywords

    True, False and None start with capitals; every other keyword is lowercase.

    Use it when: Spotting keywords and valid identifiers.

  • LiDi change, STring and TUple stay

    Lists and Dictionaries are mutable; strings and tuples are immutable.

    Use it when: Mutability questions.

  • Power first, from the right

    beats everything except brackets and chains right to left: 2 3 ** 2 = 512.

    Use it when: Precedence traps.

  • S-L-R

    Syntax stops before it starts, Logic gives wrong answers, Run-time crashes midway.

    Use it when: Classifying errors.

Getting Started with Python: exam-level solved questions

Ordered from exam level to HOTS. Cover the solution, write your own, then compare step by step.

Example 1: Precedence with ** and unary minus · 2 marks · Short answerHarder exam level

Evaluate in Python: (a) -3 2 (b) (-3) 2 (c) 2 -1 (d) 100 // 7 2 % 3

Try it first, then show the solutionSolution
  1. (a) ** before unary minus: -(9) = -9.
  2. (b) Brackets first: 9.
  3. (c) 2 ** -1 = 0.5.
  4. (d) 7 ** 2 = 49; 100 // 49 = 2; 2 % 3 = 2.

Answer: (a) -9 (b) 9 (c) 0.5 (d) 2

Example 2: print() with sep and end · 2 marks · Short answerExam level

Give the output:

print('CBSE', 'Class', 11, sep='*', end='#')
print('CS')
print(5, 6, sep='')
Try it first, then show the solutionSolution
  1. Items joined by '*', then '#' instead of a newline.
  2. 'CS' continues on the same line, then a newline.
  3. 5 and 6 with no separator.

Answer: CBSE*Class*11#CS
56

Example 3: Short-circuit evaluation · 2 marks · Short answerHarder exam level

Give the output:

a, b = 0, 7
print(a and b, a or b, not a, b and 'yes', b > 5 or a / 0)
Try it first, then show the solutionSolution
  1. 0 and 7 → 0 (first operand is falsy).
  2. 0 or 7 → 7. not 0 → True. 7 and 'yes' → 'yes'.
  3. b > 5 is True, so or stops: a / 0 is never evaluated and no error occurs.

Answer: 0 7 True yes True

Example 4: Correct the errors · 3 marks · Short answerExam level

Rewrite after correcting the errors and give the output:
num = 25
If num % 5 = 0
print('Multiple of five: ' + num)

Try it first, then show the solutionSolution
  1. If → if (keywords are lowercase).
  2. = → == for comparison, and add a colon at the end of the if line.
  3. '...' + num → '...' + str(num).
  4. num = 25
    if num % 5 == 0:
        print('Multiple of five: ' + str(num))

Answer: Multiple of five: 25

Example 5: Swapping and augmented assignment trace · 3 marks · Short answerHarder exam level

Predict the output:

x, y = 4, 6
x += y
y = x - y
x -= y
print(x, y)
z = 3
z *= 2 + 1
print(z)
Try it first, then show the solutionSolution
  1. x = 10, y = 10 - 6 = 4, x = 10 - 4 = 6: the values are swapped.
  2. z *= 2 + 1 means z = z * (2 + 1) = 9 (the whole right side is evaluated first).

Answer: 6 4
9

Example 6: Identity versus equality · 3 marks · Short answerHOTS / competency

Predict the output and explain:

p = [5, 6]
q = p
r = p[:]
q.append(7)
print(p, r)
print(p is q, p is r, p == r)
Try it first, then show the solutionSolution
  1. q refers to the same list as p; r = p[:] is a new copy.
  2. q.append(7) changes the shared list, so p shows [5, 6, 7]; r is still [5, 6].
  3. p is q True; p is r False; p == r False (values now differ).

Answer: [5, 6, 7] [5, 6]
True False False

Example 7: Seconds to hours, minutes, seconds · 3 marks · Short answerHOTS / competency

Write a program that converts 7384 seconds into hours, minutes and seconds using only // and %, and give its output.

Try it first, then show the solutionSolution
  1. t = 7384
    h = t // 3600
    m = t % 3600 // 60
    s = t % 60
    print(h, 'h', m, 'min', s, 's')
  2. 7384 // 3600 = 2; 7384 % 3600 = 184; 184 // 60 = 3; 7384 % 60 = 4.

Answer: 2 h 3 min 4 s

Example 8: Which error, and when? · 2 marks · Short answerHOTS / competency

A program has print('Start') on line 1, a line x = 5 / 0 on line 2 and print('End' (missing bracket) on line 3. What does Python show when the file is run, and why?

Try it first, then show the solutionSolution
  1. Python first checks the syntax of the whole file before running any line.
  2. The missing bracket on line 3 is a syntax error, so nothing runs: not even 'Start', and the division by zero is never reached.

Answer: Only a SyntaxError for line 3 is shown; no output is printed.

Case-study practice (Section E style)

Read the situation, then answer every part. In a school exam set on the board pattern this is a 4-mark question split into 1 + 1 + 1 + 1 marks.

Canteen bill program

Suppose the school canteen wants a small Python program. The cashier enters the number of samosas (₹15 each) and juices (₹25 each). A 10% discount applies if the bill is ₹200 or more. A first version is:
sam = input('Samosas: ')
juice = input('Juices: ')
bill = sam * 15 + juice * 25
print('Bill: ' + bill)

  1. (i) · 1 mark

    What goes wrong when this runs with inputs 4 and 2?

    Answer

    Answer: sam * 15 repeats the string '4' fifteen times, and adding the strings gives a long text, not a number; then 'Bill: ' + bill works but shows nonsense. The logic is wrong because input() returns strings.

    input() returns str; * repeats and + joins strings.

  2. (ii) · 1 mark

    Correct the input lines.

    Answer

    Answer: sam = int(input('Samosas: '))
    juice = int(input('Juices: '))

    Explicit conversion with int().

  3. (iii) · 1 mark

    Add the discount rule and print the bill for 10 samosas and 3 juices.

    Answer

    Answer:

    sam, juice = 10, 3
    bill = sam * 15 + juice * 25
    if bill >= 200:
        bill = bill - bill * 10 / 100
    print('Bill:', bill)
    Output: Bill: 202.5

    150 + 75 = 225 ≥ 200, so 10% off: 225 - 22.5 = 202.5.

  4. (iv) · 1 mark

    Which data type is bill after the discount, and why?

    Answer

    Answer: float, because / always gives a float and int minus float is promoted to float (implicit conversion).

    Type promotion avoids losing the 0.5.

Where the marks are

How a typical answer is split into step marks. Show every step: a right final answer alone rarely earns full marks.

Differentiate between mutable and immutable data types with one example of each. [2 marks] (2 marks)

StepMarks
Mutable: value can be changed in place after creation, e.g. list1
Immutable: cannot be changed in place; any change creates a new object, e.g. str or tuple1

Explain syntax, logical and run-time errors with one example each. [3 marks] (3 marks)

StepMarks
Syntax error: breaks language rules, program does not run, e.g. missing colon after if1
Logical error: program runs but gives wrong output, e.g. a + b / 2 for an average1
Run-time error: program stops abnormally while running, e.g. division by zero1

Write a program to input the principal, rate and time and print the simple interest and the amount. Explain why each input must be converted, and name the conversion used. [5 marks] (5 marks)

StepMarks
Input with conversion: p = float(input(...)), r = float(input(...)), t = float(input(...))1.5
si = p * r * t / 1001
amount = p + si0.5
Output with labels using print()1
Explanation: input() returns a string; explicit conversion (type casting) with float() is needed for arithmetic1

Where students lose marks in Getting Started with Python

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

  • Mistake: Expecting / to give an integer

    True division always gives a float in Python 3.

    Wrong working

    print(10 / 2) → 5

    Right working

    print(10 / 2) → 5.0; print(10 // 2) → 5

    Do this: Use // when an integer quotient is needed.

    Usually costs: 1 mark

  • Mistake: Rounding a negative floor division towards zero

    // rounds down (towards minus infinity).

    Wrong working

    -7 // 2 = -3

    Right working

    -7 // 2 = -4 and -7 % 2 = 1

    Do this: Find the true quotient (-3.5) and take the next lower integer.

    Usually costs: 1 mark

  • Mistake: Thinking and/or always return True or False

    They return one of the operands.

    Wrong working

    print(0 or 7) → True

    Right working

    print(0 or 7) → 7

    Do this: Apply the short-circuit rule and write the operand that decides.

    Usually costs: 1 mark

  • Mistake: Joining a string and a number with +

    Python does not convert int to str implicitly; it raises a TypeError.

    Wrong working

    print('Total: ' + 70)

    Right working

    print('Total: ' + str(70)) or print('Total:', 70)

    Do this: Use str() or a comma in print().

    Usually costs: 1 mark

  • Mistake: Using == and is as the same thing

    is checks the same object; == checks equal values. Two equal lists made separately are == but not is.

    Wrong working

    [1, 2] is [1, 2] → True

    Right working

    [1, 2] == [1, 2] is True; [1, 2] is [1, 2] is False

    Do this: Use == for values, is for identity (mostly with None).

    Usually costs: 1 mark

NCERT exercise guide: Getting Started with Python

What each exercise in the NCERT chapter tests, how to approach it, and a question of the same kind solved step by step. Questions here are written in our own words.

NCERT Chapter 5 exercise: identifiers, expressions, output and errors

What it tests: Valid identifiers, evaluating expressions, writing small programs (area, conversion, interest), finding errors and predicting output.

How to approach it: Use the identifier rules; evaluate expressions by precedence level; convert input() before arithmetic; classify each error by when it shows up.

Same kind as the 'write a program to convert units' questions

Write a program that converts a temperature of 98.6 °F to Celsius using C = (F - 32) × 5 / 9 and prints it rounded to 2 places.

Show the solutionSolution
  1. F = 98.6
    C = (F - 32) * 5 / 9
    print('Celsius:', round(C, 2))
  2. (98.6 - 32) = 66.6; 66.6 × 5 / 9 = 37.0 (shown as 37.0 after rounding).

Answer: Celsius: 37.0

NCERT Chapter 5 exercise: data types and type conversion

What it tests: Choosing data types, explicit and implicit conversion, and the type of the result of an expression.

How to approach it: Remember type promotion (int with float gives float), / always gives float, and input() gives str.

Same kind as the type-conversion questions

Give the output:

x = '25'
y = 4
print(x * y)
print(int(x) * y)
print(float(x) + y, type(float(x) + y))
print(int(7.99), bool(0.0), bool('0'))
Show the solutionSolution
  1. '25' * 4 repeats the string four times.
  2. 25 * 4 = 100.
  3. 25.0 + 4 = 29.0, a float.
  4. int(7.99) cuts off to 7; 0.0 is falsy; '0' is a non-empty string, so truthy.

Answer: 25252525
100
29.0 <class 'float'>
7 False True

Practice questions on Getting Started with Python

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 · MCQExam level

    Which of these is not a valid identifier? (a) _total (b) Total2 (c) 2total (d) total_2

    Hint

    First character.

    Answer

    (c) 2total

  2. Q2 · 2 marks · Short answerExam level

    Identify the tokens in: area = 3.14 * r ** 2 # circle

    Hint

    Five kinds of token; a comment is not a token.

    Answer

    Identifiers: area, r. Operators: =, *, **. Literals: 3.14, 2. (# circle is a comment, ignored by the interpreter.)

  3. Q3 · 1 mark · Very short answerHarder exam level

    What is the output of print(type(5 / 5), 5 // 2 * 2, 2 2 0)?

    Hint

    2 ** 0 first.

    Answer

    <class 'float'> 4 2

  4. Q4 · 2 marks · Short answerHarder exam level

    Predict the output:

    s = 'ab'
    t = s
    s = s + 'c'
    print(s, t, s is t)
    Hint

    Strings are immutable.

    Answer

    abc ab False

  5. Q5 · 1 mark · MCQHarder exam level

    Assertion (A): 'x' in {'x': 1, 'y': 2} is True but 1 in {'x': 1, 'y': 2} is False. Reason (R): The membership operator checks the keys of a dictionary. Choose (a) both true, R explains A (b) both true, R does not explain A (c) A true, R false (d) A false, R true.

    Hint

    Keys or values?

    Answer

    (a)

  6. Q6 · 2 marks · Short answerHarder exam level

    Evaluate: not 5 > 3 and 4 < 2 or 10 % 4 == 2

    Hint

    Relational first, then not, and, or.

    Answer

    5 > 3 True; not True = False; False and (4 < 2) = False; 10 % 4 == 2 is True; False or True = True.

  7. Q7 · 2 marks · Short answerExam level

    Write a program to input the length of the side of a cube and print its volume and total surface area.

    Hint

    a³ and 6a².

    Answer

    a = float(input('Side: '))
    print('Volume:', a ** 3)
    print('Surface area:', 6 * a ** 2)

  8. Q8 · 1 mark · Very short answerExam level

    A student writes avg = m1 + m2 + m3 / 3. Which type of error is this? Rewrite it correctly.

    Hint

    It runs.

    Answer

    Logical error; avg = (m1 + m2 + m3) / 3.

  9. Q9 · 3 marks · Short answerHOTS / competency

    Predict the output:

    a = 7
    b = a
    a = a * 2
    print(a, b)
    L = [7]
    M = L
    L[0] = L[0] * 2
    print(L, M)
    Hint

    Immutable int versus mutable list.

    Answer

    14 7
    [14] [14]

  10. Q10 · 3 marks · Short answerHOTS / competency

    Give one example each of a statement that causes a ValueError, a TypeError and a NameError, and say which category of error they belong to.

    Hint

    All three appear while the program runs.

    Answer

    int('ten') → ValueError; 'Age ' + 15 → TypeError; print(totl) when totl was never assigned → NameError. All three are run-time errors.

  11. Q11 · 2 marks · Short answerHOTS / competency

    Why is 5 = x invalid while x = 5 is valid? Use the terms l-value and r-value.

    Hint

    What can receive a value?

    Answer

    The left side of = must be an l-value: a name that can be assigned to. 5 is a literal, not a storage location, so it cannot be an l-value. In x = 5, x is the l-value and 5 is the r-value.

  12. Q12 · 2 marks · Short answerHarder exam level

    What is the output of print(int('12') + float('1.5'), str(12) + str(1.5), 15 % 4 ** 2)?

    Hint

    4 ** 2 is evaluated before %.

    Answer

    13.5 121.5 15

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.What extension does a Python script file have?Show answer

    .py

  2. 2.Name the five kinds of tokens.Show answer

    Keywords, identifiers, literals, operators and punctuators.

  3. 3.What is 2 3 2?Show answer

    512.

  4. 4.What type does input() return?Show answer

    A string (str).

  5. 5.Is a tuple mutable?Show answer

    No, it is immutable.

  6. 6.What does id() return?Show answer

    The unique identity of an object, which stays the same for its lifetime.

  7. 7.Which error occurs in int('abc')?Show answer

    A run-time error (ValueError).

  8. 8.What is the value of 7 % -3?Show answer

    -2 (the remainder takes the sign of the divisor, since 7 = -3 × -3 + (-2)).

Best order to study it

  1. Features of Python; interactive and script modes; the hello world program.
  2. Character set, tokens and identifier rules.
  3. Variables, multiple assignment, l-value and r-value, comments, id().
  4. Data types and mutability.
  5. Operators group by group: arithmetic, relational, logical, assignment, identity, membership.
  6. Precedence and evaluating expressions.
  7. Type conversion, input() and print() with sep and end.
  8. Syntax, logical and run-time errors.

Quick revision checklist

The night before the exam: can you do each of these without looking?

  • Python: high-level, interpreted, free and open source, case-sensitive, portable.
  • Modes: interactive (>>>, one statement) and script (.py file).
  • Tokens: keywords, identifiers, literals, operators, punctuators.
  • Identifiers: start with a letter or _, no spaces or symbols, not a keyword.
  • Types: int, float, complex, bool, str, list, tuple, None, dict.
  • Mutable: list, dict. Immutable: numbers, bool, str, tuple.
  • / float, // floor, % remainder, ** power (right to left).
  • and/or short-circuit and return an operand; falsy: 0, '', [], None, False.
  • is = same object; == equal value; in = membership.
  • input() gives str; int() cuts off fractions; errors: syntax, logical, run-time.

Getting Started with Python: frequently asked questions

Are sets in the Class 11 syllabus?

The syllabus data types list Number, boolean, sequence (string, list, tuple), None and mapping (dictionary). NCERT mentions sets briefly; know that a set is unordered with no duplicates, but the syllabus does not list it.

What exactly are l-value and r-value?

In an assignment, the l-value is the target on the left that can receive a value (a variable name); the r-value is the expression on the right that is evaluated. 5 = x or a + b = c is invalid because a literal or an expression cannot be an l-value.

Why does Python give 0.1 + 0.2 as 0.30000000000000004?

Floats are stored in binary, and 0.1 and 0.2 cannot be written exactly in binary (as you saw in number systems). The tiny error shows up when printing. Use round(x, 2) when showing money values.

Is a misspelt variable name a syntax error?

No. A name that has never been assigned is reported only when that line runs, as a NameError, so it is a run-time error. A misspelt keyword such as 'whiel' is usually a syntax error.

Does the NCERT precedence table differ from what Python does?

NCERT Table 5.9 lists the assignment operators in the precedence table. In practice, assignment is a statement: Python evaluates the whole right side first and then stores the result, so the order of the other operators is what matters in answers.

Based on: CBSE Computer Science (083) syllabus, Class XI 2026-27; NCERT Computer Science, Textbook for Class XI, Chapter 5 Getting Started with Python (Reprint 2026-27)