UNIT 1 — Python Basics (Variables, Data
Types, Operators)
1. Write a program to print your name, age, and city using variables.
2. Write a program to swap two numbers without using a third variable.
3. Write a program to take two numbers as input and perform all arithmetic
operations.
4. Write a program to check the data type of user input.
5. Write a program to show the difference between == and is.
6. Write a program to demonstrate mutable vs immutable objects using
id().
7. Write a program to input a string and print its memory address using
id().
8. Write a program to assign the same value to multiple variables and print
their ids.
9. Write a program to check if an identifier name is valid or not.
[Link] a program that gives NameError by using an undefined variable.
UNIT 2 — Control Flow (if, elif, loops,
break, continue)
(Based on PDF Unit-2 topics)
1. Write a program to check whether a number is even or odd.
2. Write a program to find the largest of three numbers using if-elif-else.
3. Write a program to calculate grade using marks (A/B/C/Fail).
4. Write a program to check eligibility for voting using nested if.
5. Write a program to print numbers from 1 to 100 using a while loop.
6. Write a program to print multiplication table of any number.
7. Write a program to count digits in a number using a loop.
8. Write a program to find the sum of digits of a number.
9. Write a program that uses break to stop a loop when a number is found.
[Link] a program to find the LCM of two numbers.
[Link] a program that skips all odd numbers using continue.
UNIT 3 — Strings, Lists, Tuples,
Dictionaries
String-based Questions
1. Write a program to count vowels in a string.
2. Write a program to reverse a string without using reverse().
3. Write a program to check whether a substring exists using in.
4. Write a program to print characters with their index.
5. Write a program to count how many times a character appears using
count().
6. Write a program to find ASCII value of a character using ord().
7. Write a program to extract a substring using slicing.
8. Write a program to concatenate and replicate strings.
9. Write a program to join list elements into a string using join().
[Link] a program to input a list and find max, min, sum without using
built-ins.
List-based Questions
[Link] a program to merge two lists without using + operator.
[Link] a program to remove duplicates from a list.
[Link] a program to sort a list without using sort().
Dictionary-Based Questions
1. Write a program to create a dictionary and print all keys and values.
2. Write a program to add a new key–value pair to an existing dictionary.
3. Write a program to update the value of a key in a dictionary.
4. Write a program to check whether a key exists in a dictionary.
5. Write a program to count the frequency of each character in a string
using a dictionary.
6. Write a program to merge two dictionaries without using the update()
function.
7. Write a program to find the key with the maximum value in a dictionary.
8. Write a program to delete a key from a dictionary.
9. Write a program to create a dictionary from two lists (keys list and values
list).
[Link] a program to find the sum of all values in a dictionary.
[Link] a Python Program to find the sum of all the items in a dictionary.
For example if d= {'A':100,'B':540,'C':239} then output should be 879
UNIT 4 — File Handling
(open(), read(), write(), readline(), readlines(), with-statement)
1. Write a program to read a file and print its content.
2. Write a program to count lines, words, and characters in a file.
3. Write a program to copy content from one file to another.
4. Write a program to append data to an existing file.
5. Write a program to read a file using readline() in a loop.
6. Write a program to write 5 student names to a file using writelines().
7. Write a program to show use of with open() for reading files.
8. Write a program to move the file pointer using seek() and show its
position using tell().
9. Write a program to handle FileNotFoundError using try-except.
[Link] a program to remove extra spaces from each line of a file and save
it to a new file.
UNIT 5 — Python Packages (NumPy,
Pandas, Matplotlib)
(Based on arrays, operations, slicing, reshape, Series, DataFrames)
NumPy Coding Questions
1. Create a 1D and 2D NumPy array and display its shape, size, and dtype.
2. Write a program to perform element-wise addition, multiplication,
exponent using NumPy.
3. Write a program to generate numbers from 0 to 20 with step 2 using
arange().
4. Write a program to reshape a 1D array into a 3×4 array.
5. Write a program to split an array into two equal parts.
6. Write a program to calculate mean, max, min, std of a NumPy array.