You are on page 1of 2

MCA11 Programming with Python

Practice Exercises – Set 2


1. Find all occurrences of a substring in a given string by ignoring the case.
2. Simulate the working of a stack using function and list operations.
3. Simulate the working of a queue using function and list operations.
4. Create the emails Dictionary and perform the following operations on the dictionary
created.
 Add Initial Items.
 Sort the specified keys or values

 Delete an element from the dictionary.

 Print the items presents in the dictionary as a sequence of (key, value) tuples.

 Count the frequency of elements.

 Count the key: value pair from the dictionary.


 Get all the keys and values of the dictionary in a list form.

 Get the specified keys and values from the dictionary.

 Add an element to the last in the dictionary.

 Update the element of the dictionary.

 Create a shallow copy of a dictionary

 Removes and returns the last key: value pair from the dictionary

 Delete all the key: value pairs from the dictionary

5. Develop a recursive function to find the factorial of a number.


6. Write a Python function to find the Max of three numbers.
Hint: Define 2 functions.
a.Function to find the max of 2 numbers
b.Function to find the max of 3 numbers, which in turn to call the function defined in
(a)
7. Write a lambda function for each of the following: -
i. Take one argument and return true if it is nonzero
ii. Take one argument and return true if it is odd
iii. Take two arguments and return their sum
iv. Take two arguments and return true if their sum is odd
v. That three arguments and return true if the produce of the first two is less than or equal
to the third.
8. Write a program using map function to convert the temperature from celcius to Fahrenheit
and vice versa.
9. Develop a Python program that prints the intersection of two lists. (without using list
comprehension/sets)
10. Develop a function which returns the factorial of a number. Using that returned value,
calculate nCr = n!/(r! (n-r)!)

You might also like