MODULE–2 (Functions & Strings)
ASSIGNMENT 2
Please follow the instructions below carefully while completing this assignment:
1. Use A4 sheets for the assignment.
2. The assignment should be handwritten. Typed submissions will not be accepted.
3. Write the code neatly with proper indentation. Code structure is essential for readability and
understanding.
4. Compile all A4 sheets in order and number each page at the top right corner.
5. Submit the sheets stapled. Failure to adhere to these instructions may affect your grade
6. Due Date: Friday, November 21, 2025. Late submissions will not be accepted.
1. Define a function in Python. Write down the advantages of using functions in Python.
2. Explain the different types of function arguments with examples.
3. What are actual and formal parameters? Explain different types of return statements in Python with
examples.
4. What are nested functions? Write a program that contains a function inside another function.
5. Write a python program using functions that returns the largest of three numbers.
6. Write a python program using functions to check if a character is a vowel.
7. Write a python program to compute factorial(n) using recursion.
8. Write a Python program to find the smallest of two numbers using a lambda function.
9. Write a python program using functions that returns the number of vowels in a string.
10. Write a python program using functions to check whether a given word is a palindrome.
11. Write a Python program to demonstrate string slicing using positive indices, negative indices and step
values.
12. Write a Python program to demonstrate built-in string methods with examples.
13. Write a Python program that counts alphabets, digits, spaces and special characters in a string.
14. Develop a program that encrypts a message by adding a key value to every character.
Hint: If key=3 then the string “HelloWorld” encrypted as “KhoorZruog”
15. Develop a program that takes username and PAN number as input, validate the information using
isXfunction and print the details.