Mid Exam – Python Important Questions (6 Marks Each)
1. Keywords and Data Types
Keywords are reserved words in Python which have special meaning. Examples: if, else, for, while,
def, return.
Data types specify the type of data stored in a variable.
Examples: int, float, string, list, tuple, set, dictionary, boolean.
2. Factorial and Palindrome
Factorial of a number n is n × (n−1) × ... × 1.
A palindrome number reads the same forward and backward.
3. Operators
Operators are symbols used to perform operations.
Types: Arithmetic, Relational, Logical, Assignment, Membership, Identity.
4. Prime Numbers between 100 and 200
A prime number has only two factors: 1 and itself. Numbers between 100 and 200 are checked
using loops and conditions.
5. Sum of Odd Numbers (1 to 100)
Odd numbers are not divisible by 2. Using a loop, odd numbers are added to find the sum.
6. Dictionary Programs
A dictionary stores data in key-value pairs. It is mutable and unordered.
7. Number of Occurrences in a String
This program counts how many times a character appears in a given string using a loop.
8. Function Arguments
Arguments are values passed to functions. Types include positional, keyword, default and variable
length arguments.
9. List Methods
Lists are ordered and mutable. Common methods are append, insert, remove, pop, sort, reverse.
10. Tuple Methods
Tuples are ordered and immutable. Methods include count() and index().