UNSOLVED QUESTIONS
1. What are the advantages of Python programming language?
2. In how many different ways can you work in Python?
3. What are the advantages/disadvantages of working in interactive mode in Python?
4. Write Python statement for the following in interactive mode:
i. To display sum of 3, 8.0, 6*12
ii. To print sum of 16, 5.0, 44.0
5. Write a Python program that accepts a string and counts the number of upper and lower case letters in
a dictionary.
Sample String: 'Cricket World Cup 2023 in India'
Expected Output: {"LOWER","UPPER", 18}
6. Write a Python program that takes a list and returns a new list with distinct elements from the first list.
Sample List: [1,2,3,3,3,3,4,2,5]
Unique List: [1, 2, 3, 4, 5]
7. Write the Python statement for each of the following tasks using built-in functions/methods only
i. To sort a numeric List object L1 in descending order.
ii. To delete marks of Sumit from a dictionary Marks where names are keys and marks are values
8. Predict the output of the Python code given below:
s='Computer@Science'
n=len (s)
m=' '
for i in range (0, n):
if(s[i]>='a' and s[i]<='m'):
m=m+s[i].upper()
elif (s[i]>='n' and s[i]<='z'):
m=m+s[i-1]
elif (s[i].isupper()):
m=m+s[i].lower()
else:
m=m+'$$'
print (m)
9. Write the output of the following:
i. for i in '123':
print ("CPU", i)
ii. for i in (100, 200, 300):
print (i)
iii. for j in range (10,6,-2):
print (j*2)
iv. for x in range (1,6):
for y in range (1,x+1):
print (x,' ',y)
v. for x in range (10,20):
if (x==15):
break
print (x)
vi. for x in range (10,20):
if (x%2==0):
continue
print (x)
10. Write the output of the following program on execution if x = 50:
x=50
if x>10:
if x>25:
print ("ok")
if x>60:
print ("good")
elif x>40:
print ("average")
else:
print ("no output")
11. What are the various ways of creating a list?
12. What are the similarities between strings and lists?
13. Why are lists called a mutable data type?
14. What is the difference between insert() and append() methods of a list?
15. Write a program to calculate the mean of a given list of numbers.
16. Write a program to calculate the minimum element of a given list of numbers.
17. Write a code to calculate and display total marks and percentage of a student from a given list storing
the marks of a student.
18. Write a program to multiply an element by 2 if it is an odd index for a given list containing both
numbers and strings.
19. Write a program to count the frequency of an element in a list.
20. Write a program to shift elements of a list so that the first element moves to the second index and
second index moves to the third index, and so on, and the last element shifts to the first position.
Suppose the list is [10, 20, 30, 40]
After shifting, it should look like: [40, 10, 20, 30]
21. A list Num contains the elements: 3, 25, 13, 6, 35, 8, 14, 45 Write a program to swap the content with
the next value divisible by 5 so that the resultant list will look like: 25, 3, 13, 35, 6, 8, 45, 14
22. Write a program to accept values from a user in a tuple. Add a tuple to it and display its elements one
by one. Also display its maximum and minimum value.
23. Write a program to input any values for two tuples. Print it, interchange it and then compare them.
24. Write a Python program to input 'n' classes and names of class teachers to store them in a dictionary
and display the same. Also accept a particular class from the user and display the name of the class
teacher of that class.
25. Write a program to store student names and their percentage in a dictionary and delete a particular
student name from the dictionary. Also display the dictionary after deletion.
26. Write a Python program to input names of 'n' customers and their details like items bought, cost and
phone number, etc., store them in a dictionary and display all the details in a tabular form.
27. Write a Python program to capitalize first and last letters of each word of a given string.
28. Write a Python program to remove duplicate characters of a given string.
29. Write a Python program to compute sum of digits of a given number.
30. Write a Python program to find the second most repeated word in a given string.
31. Write a Python program to change a given string to a new string where the first and last characters
have been exchanged.
32. Write a Python program to multiply all the items in a list.
33. Write a Python program to get the smallest number from a list.
34. Write a Python program to append a list to the second list.
35. Write a Python program to generate and print a list of first and last 5 elements where the values are
square of numbers between 1 and 30 (both included).
36. Write a Python program to get unique values from a list.
37. Write a Python program to convert a string to a list.
38. Write a Python script to concatenate the following dictionaries to create a new one:
d1={'A':1,'B':2,'C':3}
d2={'D':4}
Output should be:
{'A': 1, 'B': 2, 'C': 3, 'D': 4}
39. Write a Python script to check if a given key already exists in a dictionary.
40. Write a Python script to print a dictionary where the keys are numbers between 1 and 15 (both
included) and the values are square of keys.
Sample Dictionary:
{1:1, 2:4, 39, 4: 16, 5:25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14: 196, 15:
225}
41. Write a Python script to merge two Python dictionaries.
42. Write a Python program to sort a dictionary by key.
43. Write a Python program to combine two dictionaries adding values for common keys.
di-('a't 100, 'b': 200, 'e': 3001
d2-('a': 300, 'b': 200, 'd':400)
Sample output: Counter ({'a': 400, 'b': 400, 'c': 300, 'd': 400})
44. Write a Python program to find the three highest values in a dictionary.
45. Write a Python program to sort a list alphabetically in a dictionary.
46. Write a Python program to count number of items in a dictionary value that is a list.
47. Consider the following unsorted list: 105, 99, 10, 43, 62, 8. Write the passes of bubble sort for sorting
the list in ascending order till the 3rd iteration.
48. What will be the status of the following list after the First, Second and Third pass of the insertion sort
method used for arranging the following elements in descending order?
28, 44, 97, 34, 50, 87
Note: Show the status of all the elements after each pass very clearly underlining the changes.
49. Evaluate the following expressions: (CBSE Sample Paper 2020-
21)
i. 6*3+4 -2//5-8
ii. 10>5 and 7>12 or not 18>3
50. What are comments in Python? How is a comment different from indentation?