Every question in the paper gets a full exam-length answer in the app — organised by marks, the way a topper writes it.
8 marks Long answer
Write a Python program to print all prime numbers between 1 and 50 using a for loop, and explain the logic step by step.
Show answer outline
Program: for num in range(2, 51): if all(num % i != 0 for i in range(2, int(num**0.5)+1)): print(num); Logic: check divisibility.
The full exam-length answer is in the app.
8 marks Long answer
Explain the logical operators (and, or, not) in Python with suitable examples. Also write a Python program to check whether a person is eligible to vote, given their age and citizenship status, using logical operators.
Show answer outline
Operators: 'and': both true, 'or': at least one true, 'not': negates. Program: if age >= 18 and citizenship == 'Yes': print('Eligible') ...
The full exam-length answer is in the app.
8 marks Long answer
Write a Python program to accept a string from the user and use a for loop to count and display the number of vowels, consonants, digits and spaces present in it. Also explain the logic used.
Show answer outline
Program: for char in string: if char in 'aeiou': count_vowels += 1; Logic: check each character type.
The full exam-length answer is in the app.
8 marks Long answer
Explain lists and dictionaries in Python with suitable examples. Also write a Python program to create a dictionary containing student names and marks, and display the names of students who scored more than 60 marks.
Show answer outline
Lists: ordered, e.g., [1, 2]; Dictionaries: key-value, e.g., {'Alice': 70}; Program: for name, mark in dict.items(): if mark > 60: print(name) ...
The full exam-length answer is in the app.
8 marks Long answer
Explain Python basic data types and operators with suitable examples. Also write a Python program to design a basic calculator that supports addition, subtraction, multiplication and division.
Show answer outline
Data types: int, float, str; Operators: +, -, *, /. Program: num1 = float(input()), num2 = float(input()), result = num1 + num2 ...
The full exam-length answer is in the app.
4 marks Medium answer
Differentiate between the '/' (true division) and '//' (floor division) operators in Python. Also write a Python program to accept the marks obtained by a student (out of 100) and print the grade using if-elif-else based on: ≥90 A, ≥75 B, ≥60 C, ≥40 D, otherwise Fail.
Show answer outline
'/': returns float, '//': returns integer. Program: marks = int(input()), if marks >= 90: print('A') ...
The full exam-length answer is in the app.
4 marks Medium answer
Differentiate between if-elif-else and nested if statements, with a suitable example for each. Also write a Python program using nested for loops to print the multiplication tables from 1 to 5 (each table from 1 to 10).
Show answer outline
if-elif-else: checks multiple conditions; nested if: checks conditions within conditions. Program: for i in range(1, 6): for j in range(1, 11): print(i*j) ...
The full exam-length answer is in the app.
4 marks Medium answer
Explain the difference between a simple for loop (iterating directly over a sequence) and a for loop using the range() function. Also write a Python program to create a list of numbers and use a for loop to display the largest, smallest and sum of its elements.
Show answer outline
Simple for: iterates over elements; range(): iterates over indices. Program: nums = [1, 2, 3]; print(max(nums), min(nums), sum(nums)) ...
The full exam-length answer is in the app.
2 marks Short answer
Define a variable in Python. Give one valid and one invalid variable name.
Show answer outline
A variable in Python is a name that refers to a value. Valid: var1, Invalid: 1var.
The full exam-length answer is in the app.
2 marks Short answer
Predict the output of the following code: x = 17, y = 5, print(x % y, x // y)
Show answer outline
Output: 2 3
The full exam-length answer is in the app.
2 marks Short answer
Differentiate between a list and a dictionary in Python. Give one example of each.
Show answer outline
List: ordered collection, e.g., [1, 2, 3]; Dictionary: key-value pairs, e.g., {'a': 1, 'b': 2}.
The full exam-length answer is in the app.
2 marks Short answer
Explain the role of indentation in defining a Python block. Identify the error in: if 3 > 1: print("Yes")
Show answer outline
Indentation defines code blocks; error: 'print' must be indented.
The full exam-length answer is in the app.
2 marks Short answer
Trace and write the output of the following code: for i in range(2, 10, 3): print(i)
Show answer outline
Output: 2 5 8
The full exam-length answer is in the app.