XI
Computer Science
Python Practical
Q1. Write a Python program that takes two numbers as input from the user. Perform addition,
subtraction, multiplication, division, and modulus operations. Display all results.
Q2. Write a Python program that takes length and breadth as input from the user. Calculate and
display the area and perimeter of a rectangle using arithmetic operators.
Q3. Write a Python program that takes marks of 5 subjects as input from the user. Calculate the
average marks and display the grade using if-else: A (90+), B (80-89), C (70-79), D (60-69), E (50-59),
Fail (<50).
Q4. Write a Python program that takes a number (1-7) as input from the user. Display the
corresponding weekday name using if-else (1-Monday, 2-Tuesday, ..., 7-Sunday).
Q5. Write a Python program that takes a number n as input. Use a for loop to display all even
numbers from 1 to n.
Q6. Write a Python program that takes a number n as input. Use a for loop to display the sum of first
n natural numbers.
Q7. Write a Python program that takes a number n as input. Use a for loop to display the
multiplication table of n (1 to 10).
Q8. Write a Python program that takes a number as input from the user. Check and display whether
the number is prime or not.
Q9. Write a Python program that takes a number as input from the user. Check and display whether
the number is a palindrome or not.
Q10. Write a Python program that takes a number as input from the user. Check and display whether
the number is an Armstrong number or not.
Q11. Write a Python program that takes a number n as input. Use nested for loops to display a right-
angled triangle star pattern (n rows).
Q12. Write a Python program that takes a number n as input. Use a for loop to display the first n
alphabets (A, B, C, ...).
Q13. Write a Python program that takes the size of list and elements as input from the user to create
a list. Swap the first half elements with the second half elements and display the modified list.
Q14. Write a Python program that takes tuple size and elements as input to create a tuple. Search for
a user-input element and display its position (or -1 if not found).
Q15. Write a Python program that takes tuple size and elements as input to create a tuple. Display
the maximum and minimum elements from the tuple.
Q16. Write a Python program that takes a string as input from the user. Count and display the
number of alphabets, capital letters, small letters, digits, and special characters separately.
Q17. Write a Python program that takes number of employees and their details (emp_id,
emp_name, department, salary) as input from the user. Create and display a dictionary with this
information.
Q18. Write a Python program that takes list size, elements, and a search element as input. Display
the occurrence count of each element in the list using a dictionary.
Q19. Write a Python program that creates a student dictionary with structure {sid: [sname, marks]}
by taking input for 5 students. Display details of students whose marks are more than 80%.
Q20. Write a Python program that takes list size and elements as input. Create a dictionary that
counts the frequency of each element and displays it.