Python_Exam_Question_Paper
Python_Exam_Question_Paper
1. Define a function in Python and explain its components with an example. (5 Marks)
2. Write a function `is_even(num)` that returns `True` if the number is even, otherwise `False`. (5
Marks)
3. Create a function `factorial(n)` that calculates and returns the factorial of a given number using
recursion. (5 Marks)
4. Write a Python program to demonstrate the use of default arguments in a function. (5 Marks)
1. Write a program to check whether a given number is positive, negative, or zero using if-else
conditions. (5 Marks)
2. Write a program to print all prime numbers between 1 and 50. (5 Marks)
3. Explain the difference between `while` and `for` loops with examples. (5 Marks)
4. Write a Python program that uses nested if-else statements to check if a given year is a leap year.
(5 Marks)
1. Explain the difference between a list and a tuple in Python. Provide examples. (5 Marks)
2. Write a program to remove duplicates from a list of numbers and sort the result. (5 Marks)
3. Write a Python program to find the second largest number in a list. (5 Marks)
Python Exam Preparation - Question Paper
4. Given a tuple `(10, 20, 30, 40, 50)`, write a program to convert it into a list and add a new element
1. Explain the advantages of using NumPy arrays over Python lists. (5 Marks)
2. Write a Python program to create a 2D array of shape (3, 3) filled with random numbers. (5
Marks)
3. Create a NumPy array with values from 1 to 10 and print only the even numbers using slicing. (5
Marks)
4. Write a program to perform element-wise addition, subtraction, and multiplication on two NumPy
arrays. (5 Marks)
2. Write a program to read a CSV file and display the first 5 rows. (5 Marks)
3. Write a program to filter rows from a pandas DataFrame where the value in the "Age" column is
4. Write a Python program to sort a pandas DataFrame by a column in descending order. (5 Marks)
Write a Python program to read a dataset using pandas, clean missing data, and calculate basic