0% found this document useful (0 votes)
3 views13 pages

CBSE Python Week1 Practice Que

The document is a comprehensive guide for CBSE Class XI students on Python programming, focusing on foundational concepts such as variables, data types, operators, and input/output methods. It outlines a structured study plan for the first week, including daily practice and debugging techniques. Additionally, it provides practice questions and debugging drills to reinforce learning and prepare for exams.

Uploaded by

mnraashmi5414
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views13 pages

CBSE Python Week1 Practice Que

The document is a comprehensive guide for CBSE Class XI students on Python programming, focusing on foundational concepts such as variables, data types, operators, and input/output methods. It outlines a structured study plan for the first week, including daily practice and debugging techniques. Additionally, it provides practice questions and debugging drills to reinforce learning and prepare for exams.

Uploaded by

mnraashmi5414
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CBSE Class XI Computer Science (083)

Python Mastery Guide


Week 1 — Foundations
Variables · Data Types · Operators · I/O · Tracing Method

Target Class XI students preparing for CBSE annual exam

Duration Week 1 of the 12-week plan (1 hour/day, 6 days)

Daily split 30 min concept study + 30 min paper practice

What you need Notebook, pen, Python 3 installed ([Link])

ugging code (production + diagnosis) are different skills. School


s test production and diagnosis. This guide trains all three.

CBSE Class XI Python — Week 1 Guide Page 1


1 Variables & Data Types

1.1 What is a variable?


A variable is a named label that points to a value stored in memory. In Python, the variable name is just a tag —
the same name can point to an integer now and a string later. This is why Python is called dynamically typed.

Tip: Q1 of the sample paper asks: "In Python, variables act as storage containers — True or False?" Answer:
True (they are references to stored objects in memory).

Naming rules (CBSE tests these)


• Must start with a letter (a–z, A–Z) or underscore (_).
• After the first character, can contain letters, digits, or underscores.
• Cannot be a Python keyword: if, for, while, class, def, return, etc.
• Case-sensitive: Marks and marks are two different variables.

1.2 Data Types — memorise this table


This single table decides the answer to dozens of exam questions. Examiners ask 'what does type(x) return?'
and 'is this type mutable?' every year.

Type Example Mutable? type() returns

int x = 56 No <class 'int'>

float y = 3.14 No <class 'float'>

bool z = True No <class 'bool'>

str s = 'Asha' No <class 'str'>

list L = [1,2,3] YES <class 'list'>

tuple T = (1,2,3) No <class 'tuple'>

dict d={'a':1} YES <class 'dict'>

NoneType x = None — <class 'NoneType'>

Watch out: bool is a subclass of int in Python. True == 1 and False == 0. So type(True) returns bool, but
isinstance(True, int) also returns True. Examiners test this! Also: type([56,78,32,12]) returns — not 'array'.

1.3 Type Conversion


Python does implicit conversion (e.g. int + float gives float). You do explicit conversion when you need to control
the type — especially after input().

# Explicit (you control it)


n = int('56') # '56' --> 56
f = float('3.14') # '3.14' --> 3.14
s = str(99) # 99 --> '99'

# Truthiness — what does bool() do?

CBSE Class XI Python — Week 1 Guide Page 2


bool(0) # False (zero is false)
bool('') # False (empty string is false)
bool([]) # False (empty list is false)
bool(None) # False
bool('ok') # True (non-empty string is TRUE)
bool('False') # True <-- TRAP! 'False' is non-empty string
bool([0]) # True (non-empty list, even if it holds 0)

Watch out: The most common trap: bool('False') is True — because 'False' is a non-empty string. The string
'False' is NOT the boolean False.

CBSE Class XI Python — Week 1 Guide Page 3


2 Operators & Precedence
Python evaluates operators in a strict order (precedence). When two operators have the same precedence, it
evaluates left to right — EXCEPT ** which goes right to left.

Priority Operator(s) Meaning Example Result

1 (highest) ** Exponent (right to left) 2**3**2 512

2 - (unary) Negative sign -5 -5

3 * / // % Multiply, true-div, floor, mod 7//2 3

4 +- Add, subtract 5+3 8

5 == != < > <= >= Comparison (returns bool) 5==5 True

6 not Logical NOT not True False

7 and Logical AND T and F False

8 (lowest) or Logical OR T or F True

2.1 Worked Example — the exact style the exam uses


From the sample paper (Q3): print(2*5 + 8.5//3**2**0 - 2)

print(2*5 + 8.5//3**2**0 - 2)

Step 1: 2**0 = 1 (* ** is right-to-left, rightmost first)


Step 2: 3**1 = 3
Step 3: 8.5 // 3 = 2.0 (* floor div of a FLOAT gives a FLOAT)
Step 4: 2*5 = 10
Step 5: 10 + 2.0 = 12.0
Step 6: 12.0 - 2 = 10.0

Output: 10.0

Tip: Always work step by step on rough paper. Never try to calculate the whole expression in your head. One
wrong step = wrong answer.

2.2 Floor Division & Modulus — the tricky cases


7 // 2 # 3 (positive numbers, straightforward)
-7 // 2 # -4 (NOT -3! floor rounds TOWARD -infinity)
7 % 2 # 1
-7 % 2 # 1 (result has same sign as divisor in Python)
5 / 2 # 2.5 (true division — always float)
5 // 2 # 2 (floor division — int if both operands are int)
8.5 // 3 # 2.0 (floor of float gives float, not int)

Watch out: -7 // 2 = -4, not -3. Python's floor always goes toward negative infinity. This is the single most
common mistake in operator questions.

CBSE Class XI Python — Week 1 Guide Page 4


3 input() and print()

3.1 input() — always returns a string


name = input('Enter name: ') # returns str, e.g. 'Asha'
age = int(input('Age: ')) # convert to int when needed

# Common mistake:
x = input('Number: ') # user types 5, but x is '5' (string)
print(x + 3) # TypeError! Cannot add str and int

# Fix:
x = int(input('Number: '))
print(x + 3) # Now this works: 5 + 3 = 8

3.2 print() — sep and end parameters


print('a', 'b', 'c') # a b c (default sep=' ')
print('a', 'b', sep='-') # a-b
print('a', 'b', sep='') # ab
print('Loading', end='...') # Loading... (no newline)
print('done') # ...done (continues on same line)
print(2 + 3) # 5 (evaluates expression)
print(type(5)) #

3.3 The Tracing Method for Output Questions


This is the most important technique for scoring in Section A and B. For every output question: draw a variable
table on rough paper and update it line by line. Never guess. Never try to hold it in your head.

Step 1 Draw a variable table with one column per variable name.

Step 2 Execute one line at a time. Write the line number you're on.

Step 3 For expressions: resolve operators in precedence order. Write each sub-step.

Step 4 When you hit print(): write exactly what it prints (note sep/end if non-default).

Worked trace example


a = 10
b = 3
z = a // b
a = a % b
b = a + z
print(a, b, z)

Variable table (draw this on rough paper):


Line 1: a=10
Line 2: b=3

CBSE Class XI Python — Week 1 Guide Page 5


Line 3: z = 10//3 = 3 --> z=3
Line 4: a = 10%3 = 1 --> a=1
Line 5: b = 1+3 = 4 --> b=4
Line 6: print(1, 4, 3) --> Output: 1 4 3

CBSE Class XI Python — Week 1 Guide Page 6


4 The Debugging Method
Debugging is her biggest weakness. The reason: she tries to read the code and 'feel' the error. Under exam
pressure, this does not work. The 4-step method below is systematic and catches every type of error CBSE
asks about.

1 Syntax scan Read each line for: missing colons (:) after if/for/while/def, = instead of ==, capital letters (Print not print, Else

2 Check indentation Code inside if/for/while must be indented 4 spaces. Code at the loop's level runs after the loop ends.

3 Trace with data Use tiny inputs (1, 2, 3). Build a variable table. Does the output match what the question intends? If not → log

4 Check data types Is input() being compared to an int without conversion? Is a string method (isdigit) called on an int? Is / produ

4.1 Error Types — know the names


Error type When detected Common CBSE examples

SyntaxError Before the program runs Missing colon, = instead of ==, mismatched brackets

RuntimeError During execution — program


IndexError,
crashes ValueError, TypeError, AttributeError, ZeroDivisionError

LogicError Program runs but output isWrong


wrong operator, off-by-one loop, wrong formula

4.2 Quick error cheat sheet


Wrong code Error type Fix

rawinput() NameError input()

Int() Print() Else: NameError int() print() else:

if x = 5: SyntaxError if x == 5:

for x in range(n) SyntaxError for x in range(n):

[Link]() AttributeError str(1234).isdigit()

[Link](12) TypeError [Link](1,12)

total == total + x LogicError total = total + x

l[5] when len(l)==3 IndexError Check index before access

CBSE Class XI Python — Week 1 Guide Page 7


Practice Sheet — Week 1 (with Answers)
Attempt EVERY question on paper. Write your answers on the blank lines provided. Target: 80% correct before
moving to Week 2. If you get a question wrong, write it in your mistake notebook.

Section A — 1 mark questions

Q1 Data Types 1 mark


What will be the output of the following code?
print(type(5 / 2), type(5 // 2))

Answer:

Q2 Type Conversion — True/False 1 mark


State True or False: bool('False') returns False in Python.

Answer:

Q3 Operators & Precedence 1 mark


What will be the output? (Show each step.)
print(15 % 4 ** 2 // 3 - 1)

Answer:

Q4 Floor Division & Modulus 1 mark


What will be the output?
print(-7 // 2, -7 % 2)

Answer:

Q5 Input / Output 1 mark


A user types 5. The program runs: x = input('Enter: ') then print(x + 3). What error occurs and why? How do
you fix it?

Answer:

CBSE Class XI Python — Week 1 Guide Page 8


Q6 Tracing 1 mark
What will be the output?
a = 10
b = 3
z = a // b
a = a % b
b = a + z
print(a, b, z)

Answer:

Q7 Tracing — variable independence 1 mark


What will be the output?
x = 5
y = x
y = 20
print(x, y)

Answer:

Section B — 2 mark questions

Q8 Operator Precedence — right to left 2 marks


Write the output, showing each calculation step clearly.
a = 2
b = 3
c = a ** b ** 2
print(c)

Answer:

Q9 Data type identification 2 marks


Identify the data types of b and c after this code runs.
a = {'CS':'Sumita Arora', 'Maths':'[Link]'}
b = [Link]('CS')
c = [Link]('Physics', 100)

Answer:

CBSE Class XI Python — Week 1 Guide Page 9


Q10 Writing code 2 marks
Write a Python program that reads a number and prints whether it is positive, negative, or zero.

Answer:

Section C — 3 mark question

Q11 Complex tracing — draw your variable table 3 marks


Find the output of the following code. Show your full variable table.
x = 10
y = 3
z = x // y
x = x % y
y = x + z
print(x, y, z)

Answer:

CBSE Class XI Python — Week 1 Guide Page 10


Debug Drills — Apply the 4-Step Method
For each question: (1) apply the 4-step method, (2) list each error with its type, (3) write the fully corrected code.
Underline every correction as CBSE requires.

Debug Drill 1 3 marks


Find and fix ALL errors. Underline each correction. State the error type.
n = Int(input('Enter number: '))
if n%2 = 0
Print('Even')
Else:
print('Odd')

List each error and its type:

Write the corrected code below:

Debug Drill 2 3 marks


Find ALL errors and state the type of each error.
S = 1234
print([Link]())
name = input('Name: ')
if len(name) = 0:
print('Empty')

List each error and its type:

Write the corrected code below:

CBSE Class XI Python — Week 1 Guide Page 11


Debug Drill 3 3 marks
The program should print the SUM of all ODD numbers from 1 to n. Fix ALL errors.
n = int(input('Enter n: '))
sum = 0
for i in range(0, n+1):
if i%2 = 1:
sum == sum + i
Print(sum)

List each error and its type:

Write the corrected code below:

Debug Drill 4 4 marks


CBSE-paper style (Q30 type). Rewrite after removing ALL syntax and logical errors.
Val = in t(rawinput('Value:'))
Adder == 0
for C in range(1,Val,3)
A dder+=C
if C%2=0:
Print (C*10)
Else:
print (C*)
print (Adder)

List each error and its type:

Write the corrected code below:

CBSE Class XI Python — Week 1 Guide Page 12


Quick Reference Card — Stick in Notebook

Operator Precedence (high to low)


Operator Meaning

** Exponent (right-to-left)

- (unary) Negation

* / // % Multiply / Divide / Floor divide / Modulus

+ - Addition / Subtraction

== != < > <= >= Comparisons

not Logical NOT

and Logical AND

or Logical OR

Common CBSE Error Traps


Wrong thinking Correct fact

rawinput() Use input() in Python 3

Print() Else: Int() All keywords are lowercase: print, else, int

if x = 5: Use == for comparison, = for assignment

for i in range(n) (no colon) Always put : at the end of for/if/while lines

s = 1234; [Link]() isdigit() is a string method → str(1234).isdigit()

a ** b ** 2 read left-to-right ** is right-to-left: solve rightmost first

-7 // 2 = -3 Wrong! Python floors toward -infinity: -7//2 = -4

bool('False') is False Wrong! Non-empty string is always True

input() returns int Wrong! input() ALWAYS returns str

The Tracing Checklist (use for every output question)


• Draw variable table on rough paper before writing the answer.
• Execute one line at a time — never jump ahead.
• For **: go right to left (2**3**2 = 2**9 = 512, NOT 8**2 = 64).
• For // with float: result is float (8.5//3 = 2.0, not 2).
• For -ve floor division: round toward -infinity (-7//2 = -4).
• Check sep and end in print() — default sep=' ', default end='\n'.
• Note what is in memory after each assignment before moving on.

Resources: [Link]/python-programming | [Link]/python | [Link] (free textbook) | [Link] (sample


papers)

CBSE Class XI Python — Week 1 Guide Page 13

You might also like