Python Lab Session 2
Python Lab Session 2
1. Write a Python Program to find the maximum occurred word from a dictionary.
Hint: Occurrence will be dependent on lexicography.
Sample Input: names = {“john”, “johnny”, “jackie”, “johnny”, “john”,
“jackie”,“jamie”, “jamie”, “john”, “johnny”, “jamie”, “johnny”,“john”};
Sample Output: John
John and Johnny get maximum occurrence. Since John is alphabetically smaller,
Output is John.
2. Write a Python Program to find the mirror characters from nth position to the
length of the input string.
Hint: In Mirror operation, change ‘a’ to ‘z’, ‘b’ to ‘y’, ‘c’ to ‘x’ and likewise.
Sample Input: string: “abcd”, length = 4
Sample Output: abcw
Sample Input: string: “abcd”, length = 2
Sample Output: ayxw
3. Write a Python Program to create a list of tuples from given list having number
and its cube in each tuple.
Hint: List of Tuples in output having first element as the number it self and
second element as the cube of first element.
Sample Input: list1 = [1, 2, 3]
Sample Output: tup1 = [(1, 1), (2, 8), (3, 27)]
Sample Input: list2 = [5, 6, 7]
Sample Output: tup2 = [(5, 125), (6, 216), (7, 343)]