0% found this document useful (0 votes)
8 views9 pages

Python Model Answers

The document provides a comprehensive revision pack for Python, covering data types, variables, input/output, operations, conditions, if statements, and loops. It includes multiple choice questions, fill in the blanks, true or false statements, practical coding examples, error tracing, and programming exercises. Each section aims to reinforce understanding of Python concepts through various question formats and coding tasks.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views9 pages

Python Model Answers

The document provides a comprehensive revision pack for Python, covering data types, variables, input/output, operations, conditions, if statements, and loops. It includes multiple choice questions, fill in the blanks, true or false statements, practical coding examples, error tracing, and programming exercises. Each section aims to reinforce understanding of Python concepts through various question formats and coding tasks.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python

Revision Pack Model Answers

Section 1 — Data Types


Multiple Choice
1. Which data type represents text?
Answer: c) string
2. Which of the following is a float?
Answer: b) 4.5
3. Which data type only has two values?
Answer: d) boolean

Fill in the blanks


1. A string stores text in Python.
2. A float stores numbers with decimals.
3. The Boolean values are True and False.

True or False
1. Strings must be written inside quotation marks.
True
2. 10.5 is an integer.
False
3. Boolean values can only be True or False.
True
Match the Following
Column A Column B
Integer Whole number
String Text
Boolean True / False

Practical – What will be the output?


1.
age = 12
print(age)
Output:
12

2.
name = "Sara"
print(name)
Output:
Sara

Trace the Error


name = Ahmed
print(name)
Answer:
Ahmed should be inside quotation marks.
Correct code:
name = "Ahmed"
print(name)
Continue the Code
score = 15
print(score)

Write a Program
Example answer:
name = "Ali"
print(name)
(or)
name = input("Enter your name: ")
print(name)

Section 2 — Variables / Input / Output


Multiple Choice
1. What does the print() function do?
Answer: b) Displays data
2. Which function allows the user to enter information?
Answer: a) input()

Fill in the blanks


1. A variable stores data in a program.
2. The print() function shows output on the screen.
3. The input() function allows the user to type information.

True or False
1. Variables store information in memory.
True
2. print() collects data from the user.
False
3. input() allows the user to type data.
True

Practical – What will be the output?


name = "Ali"
print("Hello", name)
Output:
Hello Ali

Trace the Error


name = input("Enter your name")
print Hello name
Errors:
1. Missing parentheses in print()
2. Incorrect print syntax
Correct code:
name = input("Enter your name")
print("Hello", name)

Continue the Code


name = input("Enter your name: ")
print("Hello", name)

Write a Program
Example answer:
color = input("Enter your favorite color: ")
print("Your favorite color is", color)
Section 3 — Operations and Conditions
Multiple Choice
1. Which operator finds the remainder?
Answer: b) %
2. Which operator means equal to?
Answer: b) ==

True or False
1. % returns the remainder of a division.
True
2. ** is used for multiplication.
False
3. // rounds the result down.
True

Match the Following


Operator Meaning
% Remainder
** Power
// Floor division

Practical – What will be the output?


1.
print(10 + 5)
Output:
15

2.
print(10 % 3)
Output:
1

3.
print(2 ** 3)
Output:
8

Trace the Error


print(10 + )
Answer:
The second number is missing.
Correct example:
print(10 + 5)

Continue the Code


print(8 * 3)

Write a Program
Example answer:
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))

print("Sum =", num1 + num2)

Section 4 — If Statements
Multiple Choice
1. What does an IF statement do?
Answer: b) Makes decisions

True or False
1. If statements check conditions.
True
2. IF statements always run both blocks of code.
False

Practical – What will be the output?


age = 15

if age >= 13:


print("Teenager")
Output:
Teenager

Trace the Error


age = 12

if age > 10
print("Older than 10")
Errors:
1. Missing colon :
2. Indentation error
Correct code:
age = 12

if age > 10:


print("Older than 10")
Continue the Code
age = int(input("Enter your age: "))

if age >= 18:


print("Adult")
else:
print("Minor")

Write a Program
Example answer:
num = int(input("Enter a number: "))

if num > 10:


print("Big number")

Section 5 — Loops
Multiple Choice
1. Which loop repeats a fixed number of times?
Answer: b) for

Fill in the blanks


1. A while loop repeats code while a condition is True.
2. A for loop repeats a fixed number of times.

True or False
1. Loops are used to repeat instructions.
True
2. A while loop always runs forever.
False
3. A for loop can repeat multiple times.
True

Explain the Following


1. What is a loop?
Answer:
A loop is a programming structure that repeats a set of instructions automatically.

2. What is the difference between a for loop and a while loop?


Answer:
 A for loop repeats code a fixed number of times.
 A while loop repeats code as long as a condition is True.

You might also like