Sample qp-2
Sample qp-2
2. Create a tuple with set of string values and perform following operation based on user choice.
• If choice is 1 display the element present in last index position
• If choice is 2 display number of elements in the tuple
• If choice is 3 display number of occurrence of the string “hello”
• If choice is 4 find whether the element “python” is present in the list or not
• If it does not satisfy any of the above choice, display "Invalid"
(Same can be asked with list, string, set, tuple and dictionary)
4. Write a Python program to check whether a given number is a perfect number or 10 not. A perfect
number is a number that is equal to the sum of its proper divisors
(excluding the number itself). For example, 6 is a perfect number because its
5. Write a Python program to calculate median value of the given list of elements using
statistics module and write it into the file “classmedian.txt”.
6. Create a Python program to initialize a list and handle index error exception. Raise index
error exception if the length of the list is less than 5.
7. Create a package which contains two modules, one should contains withdraw details and
balance amount and other should display the details of the customer. Write a Python program
to withdraw amount and to display customer details.
8. Create a function to find whether the given string is palindrome or not. If it is palindrome return 1
else return -1. Consider default value of the string as “MADAM”.