0% found this document useful (0 votes)
14 views

Python_Exam_Question_Paper

Uploaded by

piyushshah16op
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Python_Exam_Question_Paper

Uploaded by

piyushshah16op
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Python Exam Preparation - Question Paper

Section A: Functions (20 Marks)

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)

Section B: Conditions and Loops (20 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)

Section C: Lists and Tuples (20 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

to the list. (5 Marks)

Section D: NumPy (20 Marks)

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)

Section E: pandas (20 Marks)

1. What are DataFrames in pandas? Explain with an example. (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

greater than 25. (5 Marks)

4. Write a Python program to sort a pandas DataFrame by a column in descending order. (5 Marks)

Bonus Question (Optional - 10 Marks)


Python Exam Preparation - Question Paper

Write a Python program to read a dataset using pandas, clean missing data, and calculate basic

statistics (mean, median, and standard deviation) for a numeric column.

You might also like