PYTHON LAB INTERNAL QUESTION PAPER
1. Write a program to swap two numbers without using a temporary
variable.
2. Write a program to create, display, append, insert and reverse the
order of the items in the array.
3. Write a python program to find whether a person is eligible to vote or
not using exception handling.
4. Write a program to define a function using default arguments.
5. Write a program to create tuples (name, age, address, college) for at
least two members and concatenate the tuples and print the
concatenated tuples.
6. You have a file called students.csv that contains student names and
marks in CSV format (e.g., "John,85"). Write a Python program that
reads the file and prints the name of the student with the highest
marks.
7. Write a program to add and multiply complex numbers
8. Write a program to perform any 5 built-in functions by taking any list.
9. You need to create a program that reads the contents of a file
contacts.txt and appends a new contact at the end of the file. The
contact contains a name, phone number, and email.
10. Python program to compute the number of characters, words and lines
in a file.
11. Write a program to check if the substring is present in a given string or
not.
12. Write a program to replace last value of tuples in a list to 100. Sample
list: [(10, 20, 40), (40, 50, 60), (70, 80, 90)] Expected Output: [(10, 20,
100), (40, 50, 100), (70, 80, 100)]
13. Write a program to sort words in a file and put them in another file. The
output file should have only lower-case words, so any upper-case words
from source must be lowered.
14. Write a program to check if a given key exists in a dictionary or not.
15. Given two non-negative values, print true if they have the same last
digit, such as with 27 and 57.
lastDigit(7, 17) → true
lastDigit(6, 17) → false
lastDigit(3, 113) → true
16. Write a program to sum all the items in a given dictionary.
17. Write a program to find the largest element among three Numbers.
18. Write a function to define the difference between sum of even numbers
and odd numbers.
19. Write a program to find the length of the string without using
any library functions.
20. Write a program to add a new key-value pair to an existing dictionary.
21. Write a program to print even numbers between 23 and 57. Each
number should be printed in a separate row.
22. Write a program to print multiplication table of a given number.
23. Write a program to perform the given operations on a list:
i. Addition ii. Insertion iii. Slicing
24. You have a text file called students.txt that contains a list of student
names, one per line. Write a Python program that reads the contents of
this file and prints each student’s name.
25. Write a Program to display all prime numbers within an interval.
26. Write a python program to print each line of a file in reverse order.
27. Given a string, if the first or last character is 'x', return the string
without those 'x' character, else return the string unchanged. If the
input is "xHix", then output is "Hi".
28. Write a program to define a function with multiple return values.
29. Write a program to count the number of vowels in a string (No
control flow allowed).
30. Given: list = [11, 2, 35], tuple = (74, 50), set = {67, 37,67,35}.
Concatenate them into a single list. Perform these operations: Sort the
list. Find the maximum and minimum values.