Python Programming – Question Paper
Total Marks: 50
Time: 2 Hours
Section A – Very Short Answer (10 × 1 = 10 Marks)
1. Define variable in Python.
2. What is the difference between list and tuple?
3. Write the syntax of an if statement.
4. What is type casting? Give one example.
5. Name any two loop control statements.
6. What is the use of the input() function?
7. How do you access a value from a dictionary?
8. What is the output type of 5 / 2 in Python?
9. What is a function?
10. Write one difference between set and list.
Section B – Short Answer Questions (5 × 4 = 20 Marks)
11. Write a Python program to check whether a number is even or odd.
12. Write a program to reverse a string and count vowels.
13. Print numbers from 1 to 50 divisible by 5 using loop.
14. Store 5 numbers in a list and print largest and smallest.
15. Write a function that returns sum and product of two numbers.
Section C – Long Answer Questions (4 × 5 = 20 Marks)
16. Program to calculate total, percentage and grade of 5 subjects.
17. Accept 10 numbers, print sum, average and remove duplicates.
18. Create dictionary of 5 students and print highest scorer.
19. Write function to check whether number is prime.
Answer Key
Section A Answers
1. A variable stores data in memory.
2. List is mutable, tuple is immutable.
3. if condition:
4. Converting one data type to another. Example: int('5')
5. break, continue.
6. Used to take user input.
7. dictionary_name[key]
8. float
9. Reusable block of code.
10. Set does not allow duplicates.
Section B & C Sample Programs
# Even or Odd
num = int(input())
if num % 2 == 0:
print("Even")
else:
print("Odd")
# Reverse String & Count Vowels
s = input()
print(s[::-1])
vowels = "aeiouAEIOU"
print(sum(1 for ch in s if ch in vowels))
# Divisible by 5
for i in range(1, 51):
if i % 5 == 0:
print(i)
# Largest & Smallest
nums = [int(input()) for _ in range(5)]
print(max(nums), min(nums))
# Sum & Product Function
def calc(a, b):
return a+b, a*b
# Grade Program
marks = [int(input()) for _ in range(5)]
total = sum(marks)
percentage = total / 5
# Remove Duplicates
nums = [int(input()) for _ in range(10)]
print(list(set(nums)))
# Highest Scorer
students = {"A":90,"B":85}
print(max(students, key=[Link]))
# Prime Check
def is_prime(n):
if n <= 1:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True