PYTHON SAMPLE QUESTION(LIST, TUPLE, DICTIONARY, STRINGS)
1. Write a program that read
2. s a string and check whether it is palindrome or not.
3. What is tuple? How to define and access the elements of tuple? Explain it with a code.
4. What is the output of the following snippet code?
d=dict()
d[‘left’] = ’>’
d[‘right’] = ‘<’
print(d[‘left’) and d[‘right’] or d[‘left’] and d[‘right’])
print(d[‘left’) and d[‘right’] and d[‘left’] and d[‘right’] and d[‘end’])
5. What is dictionary? How are dictionaries different from list? What are the different ways to
create dictionary?
6. Explain the method of lists with example
i) Extend() ii) insert()
7. Why strings are called immutable?
8. Explain concatenation, repetition and membership operations on string.
9. Explain split and join methods of string with examples.
10. Write a note on indexing and slicing operations on tuples.
11. With example explain how to access and modify key : value pairs in dictionaries.
12. What will be the output of the following code?
t=(1,2,4,3,8,9)
[t[i] for I in range (0, len(t), 2)]
13. Suppose a list1 is [2, 33, 222, 14, 25], what is list1[:-1]?
14. What will be the output of the following code?
My_tuple={1,2,3,4)
My_tuple.apend((5,6,7)
print(len(my_tuple)
15. What will be the output of the following code?
a=[13,56,17]
[Link]([87])
[Link]([45, 67])
print(a)
16. Write a python program of list traversal.
17. What will be the output of the following code?
a=(1,2)
b=(3,4)
c= a+b
print(c)
18. Differentiate between list, tuple and dictionary.
19. Write a program for the given syntax and tabulate the results
1. index(str, beg=0, end=len(string))
2. str.isa1num()
20. With assumed list write a program for the given code Cmp(list1, list2), len(List), max(list) &
min(list) respectively.
21. . What are the advantages of Tuple over List?
22. What are the two operators that are used in string functions?
23. Explain string comparison with an example.
24. Write a program to check whether entered string is palindrome or not.
25. What is String? How do u create a string in Python?