Exam on Python Programming
Theory Part
1. What is the output of the following code?
2. Which of the following is a valid variable name in Python?
3. What does the len() function do in Python?
4. What is the output of this code?
5. Which data type is immutable in Python?
6. What is the result of this code?
7. What does the range(2, 10, 2) function return?
8. Which keyword is used to define a function in Python?
9. What is the output of the following?
[Link] will this code output?
[Link] the different types of loops in Python with examples.
[Link] are functions in Python? How do you define and call a function?
[Link] is a dictionary in Python? How is it different from a list?
[Link] the concept of exception handling in Python with example.
[Link] is the difference between is and == in Python?
Practical
[Link] a Python program to count the number of vowels in a string.
[Link] a Python function that takes a list of numbers and returns a new list with
only the even numbers.
[Link] a Python program to find the second largest number in a list.
[Link] a dictionary from user input where keys are words and values are their
lengths.
(Example: input = "cat dog rabbit" → output = {'cat': 3, 'dog': 3, 'rabbit': 6})
[Link] a Python function to return the frequency of each character in a string,
ignoring spaces and case.