Python Practice Worksheet — Class XI
COMPUTER SCIENCE / COMPUTER APPLICATION
PYTHON PROGRAMMING — PRACTICE WORKSHEET
Class XI | WBCHSE Syllabus
Topics: Data Types • Operators • Input/Output • Mathematical & Logical Expressions • if-else Constructs
Name: ______________________ Class & Section: ________ Roll No: ________
Section A — Basic Data Types
Answer the following questions on Python's built-in data types.
Q1. Name the four basic built-in data types in Python used to store numbers, text, and truth values.
Q2. State the data type of the result produced by each of the following expressions:
Expression Data Type
25 ________________
25.0 ________________
"Hello" ________________
True ________________
25 + 5.5 ________________
10 / 2 ________________
10 // 2 ________________
'5' + '5' ________________
Q3. What will be the output of type(10), type(10.5), type('A'), and type(True)? Write your answers.
Q4. Fill in the blanks:
• The keyword used to check the data type of a variable is _______________.
• Python variable names cannot start with a _______________.
• The data type used to represent whole numbers is called _______________.
• The data type used to represent True/False values is called _______________.
Section B — Operators in Python
Evaluate the following expressions and predict their output.
Page 1 of 6
Python Practice Worksheet — Class XI
Q1. Evaluate the following arithmetic expressions (assume a = 15, b = 4):
Expression Result
a + b ________________
a - b ________________
a * b ________________
a / b ________________
a // b ________________
a % b ________________
a ** 2 ________________
Q2. Evaluate the following relational (comparison) expressions (assume x = 10, y = 20):
Expression Result (True/False)
x == y ________________
x != y ________________
x < y ________________
x >= y ________________
x <= y ________________
Q3. Evaluate the following logical expressions (assume p = True, q = False):
Expression Result
p and q ________________
p or q ________________
not p ________________
not q ________________
(p and q) or (not q) ________________
Q4. Write the output of the following assignment operator statements:
x = 5
x += 3 # x becomes ?
x -= 2 # x becomes ?
x *= 4 # x becomes ?
x //= 3 # x becomes ?
Page 2 of 6
Python Practice Worksheet — Class XI
Section C — Input and Output Statements
Study each code snippet and answer the questions that follow.
Q1. Write a Python program that takes the user's name and age as input and prints a greeting message using
both values.
Q2. Predict the output of the following code (assume the user enters 10):
num = input("Enter a number: ")
print(type(num))
print(num + num)
(Hint: input() always returns a value of a particular data type — what happens when you use '+' on it?)
Q3. Rewrite the program below so that it correctly adds two numbers entered by the user (currently it joins
them as text):
a = input("Enter first number: ")
b = input("Enter second number: ")
print("Sum =", a + b)
Q4. Write a program to take the radius of a circle as input from the user and print its area and circumference.
(Use π = 3.14)
Page 3 of 6
Python Practice Worksheet — Class XI
Section D — Mathematical Expression Problems
Write Python code / expressions to solve the following problems.
Q1. Write a single Python expression to convert temperature from Celsius (C) to Fahrenheit using the formula F
= (C × 9/5) + 32.
Q2. Write a Python program to calculate the simple interest given Principal (P), Rate (R), and Time (T), using SI =
(P × R × T) / 100.
Q3. Write a Python program to swap the values of two variables a and b without using a third variable.
Q4. Write a Python program to find the average of three numbers entered by the user.
Q5. What is the output of the following code snippet?
a = 17
b = 5
print("Quotient:", a // b)
print("Remainder:", a % b)
Page 4 of 6
Python Practice Worksheet — Class XI
Section E — Logical Problems using if–else
Trace through each program and write the output, or write new programs as instructed.
Q1. Predict the output of the following program (assume num = 8):
num = 8
if num % 2 == 0:
print("Even Number")
else:
print("Odd Number")
Q2. Write a Python program to check whether a number entered by the user is positive, negative, or zero (use
if–elif–else).
Q3. Write a Python program to find the largest of three numbers a, b, and c entered by the user.
Q4. Write a Python program that takes a student's marks as input and prints the grade according to the table
below, using if–elif–else:
Marks Range Grade
90 and above A+
75 – 89 A
60 – 74 B
Page 5 of 6
Python Practice Worksheet — Class XI
Marks Range Grade
40 – 59 C
Below 40 Fail
Q5. Trace the following nested if–else program and write its output for age = 15 and has_ticket = True:
age = 15
has_ticket = True
if has_ticket:
if age < 12:
print("Child fare applies")
else:
print("Full fare applies")
else:
print("Cannot board without a ticket")
Q6. Write a program using if–else to check whether a given year is a leap year or not. (A year is a leap year if it is
divisible by 4, but century years must also be divisible by 400.)
Page 6 of 6