Introduction to Python: ISC Class 11 Computer Science Notes
Updated 15 October 2026 · Fact-checked
Python is a high-level, interpreted language with simple syntax that uses indentation to group statements. ISC Class 11 Computer Science covers installing Python and its IDEs, interactive and script modes, tokens and variables, data types including mutable and immutable ones, operators and expressions, errors, and flow of control with if-elif-else, for, range() and while.
What Introduction to Python is about
After Java, Python shows a different style of programming: no type declarations, no braces, no semicolons, and an interpreter that runs code line by line. It is widely used for data science, automation and teaching.
The CISCE 2028 syllabus (Section C, topic 12) asks for: (a) installation and IDE (python.org; IDLE, PyCharm, VS Code, Spyder, Jupyter); (b) fundamentals: features, interactive and script modes, character set, tokens (keyword, identifier, literal, operator, punctuator), variables, l-value and r-value, comments; (c) data types: number (integer, floating point, complex), boolean, sequence (string, list, tuple), None, mapping (dictionary); mutable and immutable types; (d) data processing: console input and output; syntax, logical and run-time errors; (e) operators and expressions: arithmetic (+, −, *, , /, //, %), relational, logical (and, or, not), assignment and augmented assignment, identity (is, is not), membership (in, not in); evaluation, precedence, explicit and implicit type conversion; (f) flow of control: indentation; sequential, conditional (if, if-else, if-elif-else) and iterative flow (for loop, range(), while loop), break and continue, nested loops. The syllabus specifies Python 3.13 and above**.
The three programs on this page were run with Python 3.13, the version the syllabus specifies, and their outputs are shown exactly.
Weightage: Introduction to Python is topic 12 of the ISC Class XI Computer Science syllabus, in Section C - Python and Conceptual aspects. CISCE weights Section C at 15 of the 70 marks in Paper I (Theory). Class XI is examined by the school, so your school sets the paper within this weightage.Source: CISCE ISC Computer Science syllabus, examination year 2028, Class XI unit weightage
Key concepts
- Python: features, installation, IDEs and modes
Features of Python:
1. High-level and easy to read: English-like syntax; indentation instead of braces.
2. Interpreted: there is no separate compile step for the programmer; the interpreter runs the program statement by statement, so a run-time error appears only when the faulty line is reached.
3. Dynamically typed: a variable's type is decided by the value it holds; no declarations.
4. Free and open source; cross-platform (Windows, Linux, macOS).
5. Large standard library and many extra packages.
6. Supports procedural and object oriented styles.Installation: download from python.org and install (version 3.13 or above for the syllabus). The installer includes IDLE, Python's own simple IDE.
IDEs and editors: IDLE (simple, built in), PyCharm (full-featured), VS Code (editor with a Python extension), Spyder (scientific, variable explorer), Jupyter (notebooks: code and output in cells, popular for data analysis).
Modes:
- Interactive mode: type a statement at the >>> prompt and see the result immediately; good for testing small ideas; work is not saved.
- Script mode: write a program in a .py file, save it and run the whole file; used for real programs.
Worked example
State one advantage each of interactive and script mode. [2 marks]
Try it first, then show the solutionSolution
- Interactive: immediate result of each statement; useful for testing and learning.
- Script: the program is saved in a .py file and can be edited and run again.
Answer: Interactive mode gives instant feedback; script mode saves complete programs for reuse.
- Character set, tokens, variables, l-value and r-value, comments
Character set: letters (A-Z, a-z), digits (0-9), special symbols (+ − * / ( ) [ ] { } : , . ' " # etc.), whitespace, and any Unicode character (Python 3 source is UTF-8).
Tokens (smallest units of a program):
1. Keywords: reserved words with special meaning: if, elif, else, for, while, break, continue, True, False, None, and, or, not, in, is, def, return, import.
2. Identifiers: names of variables and functions: letters, digits and underscore; cannot start with a digit; not a keyword; case-sensitive (Marks ≠ marks).
3. Literals: fixed values: 25, 3.14, 3+4j, 'Riya', True, None.
4. Operators: + − * / // % ** == != and or not in is ...
5. Punctuators: ( ) [ ] { } , : . ' " # = and so on.Variables: names that refer to objects; created by assignment (marks = 87); the type comes from the value and can change (marks = 'A' later is allowed).
l-value and r-value: in x = x + 1, the r-value (right side) is evaluated to a value; the l-value (left side) must be a name (or element) that can receive a value. 5 = x is an error.
Multiple assignment: a, b = 17, 5; swapping: a, b = b, a.
Comments: # starts a single-line comment; triple-quoted strings are often used for multi-line notes (docstrings).
Worked example
Which of these are valid identifiers: total_2, 2total, for, _count, Total? [1 mark]
Try it first, then show the solutionSolution
- 2total starts with a digit; for is a keyword.
Answer: Valid: total_2, _count and Total.
- Data types; mutable and immutable types
Category Type Example Number int (any size) 16, −3, 10**20 float 1.62, 2.5e3 complex 3 + 4j (z.real, z.imag) Boolean bool True, False Sequence str 'Riya' list [78, 85, 92] tuple (3, 4) None NoneType None (no value) Mapping dict {'name': 'Riya', 'class': 11} type(x) tells the type of a value.
Mutable types can be changed in place after creation: list, dict (and set).
Immutable types cannot be changed in place; an 'update' creates a new object: int, float, complex, bool, str, tuple (and None).
marks[0] = 80 works on a list; name[0] = 'P' on a string raises TypeError.
# Data types, mutability and type conversion in Python age = 16 # int height = 1.62 # float z = 3 + 4j # complex ok = True # bool name = "Riya" # str (immutable sequence) marks = [78, 85, 92] # list (mutable sequence) point = (3, 4) # tuple (immutable sequence) info = {"name": "Riya", "class": 11} # dict (mapping) nothing = None # NoneType for v in (age, height, z, ok, name, marks, point, info, nothing): print(type(v).__name__, v) print("abs(z) =", abs(z), " z.real =", z.real, " z.imag =", z.imag) marks[0] = 80 # lists can be changed in place print("marks after change:", marks) try: name[0] = "P" # strings cannot except TypeError as e: print("TypeError:", e) print(int("42") + 8, float("2.5") * 2, str(7) + "7", int(9.99), round(2.675, 2)) print(3 + 2.5, type(3 + 2.5).__name__, True + 1) # implicit conversionOutput:
int 16 float 1.62 complex (3+4j) bool True str Riya list [78, 85, 92] tuple (3, 4) dict {'name': 'Riya', 'class': 11} NoneType None abs(z) = 5.0 z.real = 3.0 z.imag = 4.0 marks after change: [80, 85, 92] TypeError: 'str' object does not support item assignment 50 5.0 77 9 2.67 5.5 float 2(The TypeError is caught here only so that the program can show the message and continue.)
Worked example
After a = [5, 6]; b = a; b.append(7), what are a and b? Would the same happen with a tuple? [2 marks]
Try it first, then show the solutionSolution
- b refers to the same list as a; append changes that list in place: both show [5, 6, 7].
- A tuple is immutable and has no append; it cannot be changed in place.
Answer: a = b = [5, 6, 7]; a tuple could not be changed this way because it is immutable.
- Console input and output; errors
Output: print(value1, value2, ..., sep=' ', end='\n'). sep sets the separator (default a space); end sets what follows (default a new line): print(x, end=' ') keeps output on one line.
Input: input(prompt) always returns a string; convert it: n = int(input('Enter a number: ')); r = float(input()).
Errors:
1. Syntax errors: the code breaks Python's grammar (missing colon after if, wrong indentation, unmatched brackets); the program does not start running.
2. Run-time errors (exceptions): occur while running: ZeroDivisionError (10 / 0), ValueError (int('abc')), TypeError ('5' + 5), NameError (using an undefined name), IndexError (list index out of range).
3. Logical errors: the program runs but gives wrong results (using / instead of //, wrong condition); found only by testing.Worked example
Classify: (i) if x > 5 print(x); (ii) print(int('12a')); (iii) avg = a + b / 2 meant as an average. [2 marks]
Try it first, then show the solutionSolution
- (i) Missing colon: syntax error.
- (ii) ValueError at run time; (iii) runs but divides only b: logical error (should be (a + b) / 2).
Answer: (i) Syntax; (ii) run-time (ValueError); (iii) logical.
- Operators, expressions, precedence and type conversion
Arithmetic: + − * (power) / (true division, always float) // (floor division, rounds down**) % (remainder, sign of the divisor).
Relational: < <= > >= == !=. Logical: and, or, not (they short-circuit and actually return one of the operands: 0 and 5 gives 0; 7 or 0 gives 7).
Assignment: =; augmented: += −= *= /= //= %= **=.
Identity: is, is not: same object? Membership: in, not in: is the value present in a sequence?
Unary (−x, not x), binary (a + b) and ternary (x if condition else y) operators.
Precedence (high to low): → unary −, + → * / // % → + − → relational and identity and membership → not → and → or. is right-associative (2 3 2 = 2 ** 9 = 512); most others are left to right.
Type conversion: implicit (int + float gives float; True counts as 1) and explicit with int(), float(), str(), bool(): int(9.99) = 9 (truncates); int('42') = 42.
# Operators and expressions in Python a, b = 17, 5 print(a + b, a - b, a * b, a / b, a // b, a % b, a ** 2) print(-17 // 5, -17 % 5) # floor division rounds down print(2 ** 3 ** 2) # ** is right-associative: 2 ** 9 print(10 - 4 - 3, 2 + 3 * 4) # left to right; * before + x = 10 x += 5; x *= 2; x //= 4 # augmented assignment print("x =", x) print(a > b and b > 0, a < b or b == 5, not a == 17) print(0 and 5, 7 or 0, "" or "default") # and/or return an operand L1 = [1, 2] L2 = [1, 2] L3 = L1 print(L1 == L2, L1 is L2, L1 is L3) # equality vs identity print(3 in L1, "y" in "Python", 9 not in L1) big = 50 if a > 10 else 0 # conditional (ternary) expression print("big =", big)Output:
22 12 85 3.4 3 2 289 -4 3 512 3 14 x = 7 True True False 0 7 default True False True False True True big = 50Worked example
Evaluate: 7 // 2, 7 / 2, 7 % 2, 2 ** −1 and −7 // 2. [2 marks]
Try it first, then show the solutionSolution
- 7 // 2 = 3; 7 / 2 = 3.5; 7 % 2 = 1; 2 ** −1 = 0.5.
- −7 // 2 = −4 (floor of −3.5 rounds down).
Answer: 3, 3.5, 1, 0.5, −4.
- Flow of control: indentation, if-elif-else, for, range(), while
Indentation (usually 4 spaces) marks a block: every statement in a block must be indented equally; a colon (:) ends the line that starts a block (if, elif, else, for, while). Wrong indentation is a syntax error (IndentationError).
Sequential flow: statements run one after another.
Conditional flow: if; if-else; if-elif-else (the first true condition's block runs).
Iterative flow:
- for variable in sequence: repeats for each item: for ch in 'Python', for x in [3, 5].
- range(stop), range(start, stop), range(start, stop, step): numbers from start up to but not including stop: range(2, 11, 3) gives 2, 5, 8.
- while condition: repeats while the condition is true.
- break exits the loop; continue skips to the next iteration.
- Nested loops: a loop inside a loop; print(x, end=' ') keeps a row on one line.
# Flow of control: input, if-elif-else, for with range(), while, break, continue, nested loops n = int(input("Enter marks: ")) print() if n >= 90: grade = "A" elif n >= 75: grade = "B" elif n >= 40: grade = "C" else: grade = "Fail" print("Grade:", grade) print(list(range(5)), list(range(2, 11, 3)), list(range(10, 0, -4))) total = 0 for i in range(1, 11): if i % 3 == 0: continue # skip multiples of 3 total += i print("sum of 1..10 without multiples of 3 =", total) num, digits = 90817, 0 while num > 0: digits += 1 num //= 10 print("digits =", digits) for k in range(101, 200): if k % 7 == 0 and k % 9 == 0: print("first above 100 divisible by 7 and 9:", k) break for row in range(1, 4): # nested loops for col in range(1, row + 1): print(col, end=" ") print()Output (input 82):
Enter marks: Grade: B [0, 1, 2, 3, 4] [2, 5, 8] [10, 6, 2] sum of 1..10 without multiples of 3 = 37 digits = 5 first above 100 divisible by 7 and 9: 126 1 1 2 1 2 3Worked example
What does list(range(10, 0, −4)) give, and how many times does for i in range(1, 20, 4) run? [2 marks]
Try it first, then show the solutionSolution
- range(10, 0, −4): 10, 6, 2 (stops before 0).
- range(1, 20, 4): 1, 5, 9, 13, 17 → 5 times.
Answer: [10, 6, 2]; 5 times.
Introduction to 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.
Interactive mode as a calculator
Suppose you need to check 2 to the power 64 quickly while studying number systems.
How can Python's interactive mode help, and what is special about the result?
Try it first, then show the solutionSolution
- Type 2 ** 64 at the >>> prompt and press Enter.
- Python ints have no fixed size, so it prints the exact value 18446744073709551616.
Answer: Interactive mode gives the exact result immediately; Python integers grow as large as needed.
Memory hook: >>> is a calculator that never overflows integers.
Input is always text
Imagine a program asks for your age and then adds 1, but crashes with a TypeError.
What went wrong and how is it fixed?
Try it first, then show the solutionSolution
- input() returned the string '16'; '16' + 1 mixes str and int.
- Convert first: age = int(input('Age: ')); then age + 1 = 17.
Answer: input() gives a string; convert it with int() before arithmetic.
Memory hook: Input is text until you convert it.
Indentation matters
Suppose a loop is meant to print 'Done' once after printing 1 to 3, but 'Done' appears three times.
What is the likely cause?
Try it first, then show the solutionSolution
- print('Done') is indented inside the for loop's block.
- Remove the indentation so that it runs after the loop.
Answer: Wrong indentation: the statement belongs to the loop body; un-indent it to run once.
Memory hook: Indentation is the block.
Topics in this chapter
Introduction to Python: syntax and key facts
- Division operators
- / true division (float); // floor division (rounds down); % remainder; a == (a // b) * b + a % b
- range()
- range(start, stop, step): start, start + step, ... up to but not including stop
- Conditional expression
- value_if_true if condition else value_if_false
- Precedence (short)
- ** > unary − > * / // % > + − > comparisons, in, is > not > and > or
- Conversions
- int(x), float(x), str(x), bool(x), complex(a, b); input() returns str
Introduction to Python: diagrams to practise
Practise each one on paper: draw it from the checklist, then tick off every label.
Python data types tree
Classify Python data types.
Draw
- Root: Data types. Branches: Numbers (int, float, complex), Boolean (bool), Sequences (str, list, tuple), None, Mapping (dict).
- Colour mutable types (list, dict) differently from immutable ones (int, float, complex, bool, str, tuple).
Label
- numbers
- sequences
- mapping
- mutable
- immutable
Watch out: Mark mutability on the tree: it answers two questions at once.
Indentation blocks
Explain indentation in Python.
Draw
- Write an if-elif-else with each block indented by four spaces, and a for loop with a nested loop indented by eight.
- Draw vertical bars beside each block to show where it starts and ends.
Label
- colon
- indented block
- nested block
Watch out: Point out the colon at the end of each header line.
How the school exam asks Introduction to Python
The question patterns to expect, and the method that works for each.
| Question type | How it is asked | Method |
|---|---|---|
| Theory (1-2 marks) | Features of Python; interactive vs script mode; tokens; mutable vs immutable; types of errors. | Definition with a short Python example. |
| Output (1-5 marks) | Evaluate expressions with //, %, **, and/or, is/in; predict output of loops with range, break and continue. | Apply precedence; list range values; trace loop variables. |
| Programs (5-10 marks) | Short programs with input(), if-elif-else and loops: grades, digit problems, patterns, factorials. | Convert input; correct indentation; choose for (known count) or while (condition). |
Tricks to remember Introduction to Python
Short memory aids. Say each one aloud once, then use it on a question the same day.
Slash vs double slash
/ always gives a float; // floors down to the integer below.
Use it when: Division operators.
Mutable: list and dict change; the rest stay
'Lists and dictionaries are diaries: you can rewrite them.'
Use it when: Mutability.
range stops short
range(1, 5) is 1, 2, 3, 4: the stop value is never included.
Use it when: Loops.
is = same object; == = same value
Twins look the same (==) but are different people (is).
Use it when: Identity vs equality.
Introduction to Python: exam-level solved questions
Ordered from exam level to HOTS. Cover the solution, write your own, then compare step by step.
Example 1: Immutable type · 1 mark · MCQExam 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
- Lists can be changed in place; the others cannot.
Answer: (c) list.
Example 2: Floor division · 1 mark · Assertion-reasonHarder exam level
Assertion: In Python, −17 // 5 evaluates to −4.
Reason: The // operator truncates the result towards zero.
(a) Both Assertion and Reason are true and Reason is the correct explanation of Assertion.
(b) Both Assertion and Reason are true but Reason is not the correct explanation of Assertion.
(c) Assertion is true but Reason is false.
(d) Both Assertion and Reason are false.
Try it first, then show the solutionSolution
- −17 / 5 = −3.4; // rounds down (floor) to −4 (Assertion true, as the program printed). Truncation towards zero would give −3 (Reason false).
Answer: (c)
Example 3: Expression evaluation · 2 marks · Short answerExam level
Evaluate 10 + 5 * 2 2 // 3 and 2 3 ** 2, showing the order.
Try it first, then show the solutionSolution
- 2 ** 2 = 4; 5 * 4 = 20; 20 // 3 = 6; 10 + 6 = 16.
- is right-associative: 3 2 = 9; 2 ** 9 = 512.
Answer: 16 and 512.
Example 4: Loop tracing · 5 marks · Short answerHarder exam level
Give the output of the following and explain: (i) s = 0; for i in range(1, 20, 4): s += i; print(s). (ii) n = 1; while n < 100: n *= 3; print(n). (iii) count = 0; for x in range(3): for y in range(4): count += 1; print(count).
Try it first, then show the solutionSolution
- (i) i takes 1, 5, 9, 13, 17; s = 45.
- (ii) n: 1 → 3 → 9 → 27 → 81 → 243; stops when n ≥ 100: prints 243.
- (iii) Inner loop runs 4 times for each of 3 outer iterations: 12.
- Run results: 45, 243, 12.
Answer: (i) 45; (ii) 243; (iii) 12.
Example 5: Identity and membership · 5 marks · Short answerHOTS / competency
For L1 = [1, 2], L2 = [1, 2], L3 = L1, give the values of L1 == L2, L1 is L2, L1 is L3, 3 in L1, 'y' in 'Python' and 9 not in L1, and explain the difference between == and is.
Try it first, then show the solutionSolution
- L1 == L2: True (same contents).
- L1 is L2: False (two separate list objects).
- L1 is L3: True (L3 refers to the same object).
- 3 in L1: False; 'y' in 'Python': True; 9 not in L1: True.
- == compares values; is compares identity (same object in memory).
Answer: True, False, True, False, True, True (as the operators program printed); == checks equal values, is checks the same object.
Example 6: Grade and statistics program · 10 marks · Long answerHOTS / competency
Write a Python program that reads marks (an integer), prints the grade (A for 90 and above, B for 75-89, C for 40-74, Fail otherwise), and then demonstrates range(), continue, a while loop counting the digits of 90817, a for loop with break finding the first number above 100 divisible by 7 and 9, and a nested-loop number triangle.
Try it first, then show the solutionSolution
- n = int(input('Enter marks: ')) converts the text input.
- if n >= 90 ... elif n >= 75 ... elif n >= 40 ... else ...: the first true branch sets grade.
- for i in range(1, 11) with if i % 3 == 0: continue sums the remaining numbers: 37.
- while num > 0: digits += 1; num //= 10 counts 5 digits.
- for k in range(101, 200) with break at the first k divisible by 7 and 9: 126.
- Nested for loops with print(col, end=' ') and print() print the triangle. For input 82 the grade is B.
Answer: See the flow program in the flow-of-control section; for input 82 it prints Grade: B, the range lists, 37, 5, 126 and the triangle.
Case-study practice (Section D style)
Read the situation, then answer every part. In a school exam set on the board pattern this is a 5-mark question split into 2 + 2 + 1 marks.
Canteen bill in Python
Suppose a student writes a Python program for a canteen: it asks how many samosas (₹15 each) and juices (₹30 each) are bought, adds 5% GST, and prints the total. The first version is: s = input('Samosas: '); j = input('Juices: '); total = s * 15 + j * 30; print(total * 1.05). For the inputs 2 and 1 it stops with a TypeError instead of printing a bill.
(i) · 2 marks
Explain the bug and correct the input lines.
Answer
Answer: input() returns strings: '2' * 15 repeats the text 15 times and + joins the two strings, so total is a long string; multiplying a string by 1.05 then raises a TypeError. Correct: s = int(input('Samosas: ')); j = int(input('Juices: ')).
1 mark cause, 1 mark fix.
(ii) · 2 marks
For 2 samosas and 1 juice, what is the corrected total?
Answer
Answer: 2 × 15 + 1 × 30 = 60; with 5% GST: 60 × 1.05 = 63.0.
1 mark subtotal, 1 mark total.
(iii) · 1 mark
What type of error was the original bug?
Answer
Answer: A logical error leading to a run-time TypeError (string arithmetic instead of numbers); it is not a syntax error because the code is grammatically correct.
1 mark.
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.
Expression evaluation (2 marks) (2 marks)
| Step | Marks |
|---|---|
| First expression with correct order | 1 |
| Right-associative power | 1 |
Loop tracing (5 marks) (5 marks)
| Step | Marks |
|---|---|
| range values and sum | 2 |
| while loop final value | 2 |
| Nested loop count | 1 |
Grade and loops program (10 marks) (10 marks)
| Step | Marks |
|---|---|
| Input converted with int() | 1 |
| if-elif-else grading | 2 |
| for with continue | 2 |
| while digit count | 2 |
| break and nested loops with correct indentation | 3 |
Where students lose marks in Introduction to Python
The slips examiners see most often, and what to write instead.
Mistake: Forgetting that input() returns a string
Arithmetic on strings repeats or joins text, or raises TypeError.
Do this: Wrap with int() or float().
Usually costs: 1 mark.
Mistake: Expecting range(1, 5) to include 5
The stop value is excluded.
Do this: Use range(1, 6) for 1 to 5.
Usually costs: 1 mark.
Mistake: Treating // as truncation for negatives
// is floor division: −7 // 2 = −4.
Do this: Round down, not towards zero.
Usually costs: 1 mark.
Mistake: Missing colons or inconsistent indentation
Both are syntax errors in Python.
Do this: End headers with a colon; indent each block consistently (4 spaces).
Usually costs: 1-2 marks.
Practice questions on Introduction to Python
Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.
Q1 · 1 mark · MCQExam level
Which operator gives the floor quotient in Python?
(a) /
(b) //
(c) %
(d) **Hint
Double slash.
Answer
(b) //.
Q2 · 1 mark · Very short answerExam level
Name two IDEs for Python.
Hint
Built in or popular.
Answer
IDLE and PyCharm (also VS Code, Spyder, Jupyter).
Q3 · 2 marks · Short answerExam level
List the five kinds of tokens in Python with one example each.
Hint
Keyword, identifier, literal, operator, punctuator.
Answer
Keyword (while), identifier (total), literal (3.14), operator (//), punctuator (:).
Q4 · 2 marks · Short answerHarder exam level
Give the output: print(7 // 2, 7 / 2, 7 % 2, 2 ** -1, -7 // 2)
Hint
Floor for negatives.
Answer
3 3.5 1 0.5 -4
Q5 · 2 marks · Short answerHarder exam level
Give the output of print('ab' * 3, 'x' in 'xyz', [1, 2] + [3]) and of print(type(10 / 2).__name__, type(10 // 2).__name__).
Hint
Repetition, membership, concatenation.
Answer
ababab True [1, 2, 3]; float int.
Q6 · 2 marks · Short answerHOTS / competency
What are the values of not 0, bool('') and bool('False')? Explain the last one.
Hint
Empty vs non-empty.
Answer
True, False, True. Any non-empty string is truthy, so bool('False') is True; only the empty string is False.
Q7 · 5 marks · Short answerHarder exam level
Write a Python program to find the factorial of a number entered by the user using a for loop, and give the output for 5.
Hint
range(1, n + 1).
Answer
n = int(input('Enter n: '))
fact = 1
for k in range(1, n + 1):
fact *= k
print('Factorial =', fact)
For 5: 1 × 2 × 3 × 4 × 5 = 120.Q8 · 5 marks · Short answerHarder exam level
Distinguish between mutable and immutable data types with two examples each, and explain what happens on a = [5, 6]; b = a; b.append(7).
Hint
In-place change; shared reference.
Answer
Mutable types can be changed in place (list, dict); immutable types cannot (str, tuple, also int, float). In the example, b refers to the same list object as a, so after b.append(7) both a and b are [5, 6, 7].
Q9 · 10 marks · Long answerHOTS / competency
Write a Python program that checks whether a number is an Armstrong number (sum of cubes of digits for three-digit numbers) using a while loop, and test it with 371.
Hint
% 10 and // 10.
Answer
num = int(input('Enter a 3-digit number: '))
t = num
s = 0
while t > 0:
d = t % 10
s += d ** 3
t //= 10
if s == num:
print(num, 'is an Armstrong number')
else:
print(num, 'is not an Armstrong number')
For 371: 1 + 343 + 27 = 371, so it is an Armstrong number.Q10 · 2 marks · Short answerHOTS / competency
Why does round(2.675, 2) give 2.67 in Python, not 2.68?
Hint
Binary floating point.
Answer
2.675 cannot be stored exactly in binary; the stored value is slightly less than 2.675 (about 2.67499999...), so rounding to two places gives 2.67, as the data-types program printed.
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.Python file extension?Show answer
.py.
2.Two modes of Python?Show answer
Interactive and script mode.
3.Type returned by input()?Show answer
str.
4.Mutable types?Show answer
list and dict.
5.Membership operators?Show answer
in, not in.
6.range(2, 11, 3) gives?Show answer
2, 5, 8.
Best order to study it
- Features, installation, IDEs, modes.
- Character set, tokens, variables, l-value and r-value, comments.
- Data types; mutable and immutable.
- Input, output and errors.
- Operators, precedence and type conversion.
- Indentation, if-elif-else, for with range, while, break, continue, nested loops.
Quick revision checklist
The night before the exam: can you do each of these without looking?
- Python: interpreted, dynamically typed, indentation-based, open source; IDLE, PyCharm, VS Code, Spyder, Jupyter.
- Tokens: keywords, identifiers, literals, operators, punctuators.
- Types: int, float, complex, bool, str, list, tuple, None, dict; list and dict mutable.
- input() → str; print(sep, end); errors: syntax, run-time, logical.
- / float, // floor, % remainder, ** power (right-assoc.); is identity; in membership.
- if-elif-else; for x in range(start, stop, step); while; break; continue.
Introduction to Python: frequently asked questions
Which Python version should I use?
The syllabus specifies Python 3.13 and above, available from python.org. The basic features in this chapter work the same way in other recent Python 3 versions.
Why does Python not need int or double declarations like Java?
Python is dynamically typed: a variable is just a name for an object, and the object carries its own type. The same name can later refer to an object of another type.
Is the ternary operator in the syllabus?
Yes: the syllabus lists unary, binary and ternary operators. Python's ternary form is the conditional expression x if condition else y.
Based on: CISCE ISC 2028 Computer Science syllabus (Classes XI and XII); CISCE Regulations for the ISC Examination Year 2028 (Class XI internal examination)