0% found this document useful (0 votes)
2 views3 pages

Python Test 1 Answer

Uploaded by

afsal meeran
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)
2 views3 pages

Python Test 1 Answer

Uploaded by

afsal meeran
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

Class Test 1: Python Basics

Topics: Variables, Data Types, Operators, Conditionals, Loops

🟩 Section A – 1 Mark Each (5 Questions × 1 = 5 Marks)


1. What is the output of the following code?
x=5
print(type(x))

✅ Answer: <class 'int'>


2. Write one difference between = and == in Python.
Answer: = is an assignment operator, == is a comparison operator.


3. Which data type will be used to store the value "True"?
Answer: str (string)

4. Predict the output:


print(3 + 4.0)

✅ Answer: 7.0 (int + float = float)

5. Write the output of:


print(10 // 3)

✅ Answer: 3

🟧 Section B – 2 Marks Each (3 Questions × 2 = 6 Marks)


6. Correct the code:
a=5
if a = 10
print("Ten")
✅ Answer (Corrected Code):

a=5
if a == 10:
print("Ten")

7. Check whether a number is even or odd: ✅ Answer:


num = int(input("Enter a number: "))
if num % 2 == 0:
print("Even")
else:
print("Odd")

8. Predict the output:


a=7
if a > 5:
print("A")
else:
print("B")

✅ Answer: A

🟨 Section C – 3 Marks Each (3 Questions × 3 = 9 Marks)

9. Find the largest of three numbers: ✅ Answer:


a = int(input("Enter first: "))
b = int(input("Enter second: "))
c = int(input("Enter third: "))

if a >= b and a >= c:


print("Largest is", a)
elif b >= a and b >= c:
print("Largest is", b)
else:
print("Largest is", c)
[Link] between and, or, and not with examples: ✅ Answer:
• and: Returns True if both conditions are True
→ 5 > 3 and 10 > 5 → True
• or: Returns True if at least one condition is True
→ 5 < 3 or 10 > 5 → True
• not: Reverses the result
→ not(5 > 3) → False

[Link] of even numbers from 1 to 50: ✅ Answer:


total = 0
for i in range(1, 51):
if i % 2 == 0:
total += i
print("Sum =", total)

🟦 Section D – 4 Marks Each (2 Questions × 4 = 8 Marks)

[Link] table of a number: ✅ Answer:


num = int(input("Enter a number: "))
for i in range(1, 11):
print(num, "x", i, "=", num * I)

[Link] of 5 positive numbers: ✅ Answer:


count = 0
total = 0
for i in range(5):
num = int(input("Enter number: "))
if num > 0:
total += num
count += 1
if count > 0:
print("Average =", total / count)
else:
print("No positive numbers")

You might also like