Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Python Test

Uploaded by

onkarghorpade18
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Python Test

Uploaded by

onkarghorpade18
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1. Write a recursive function in Python to find the factorial of a number.

2. Write a function that takes a list of numbers and returns a new list with each number
squared.

3. Write a Python program to generate Fibonacci numbers up to a given number n, using


both an iterative approach and a generator.

4. Write a program that uses a lambda function to double a given number.

5. Write a Python program to handle a division by zero error using a try-except block.

6. Write a list comprehension to generate a list of even numbers between 1 and 20.

7. Create a simple Python class with an __init__ method that initializes a name attribute.

8. Write a Python program to read and print each line of a file called "data.txt".

9. Write a program that uses the len() function to print the length of a string and a list.

10. Write a Python program that doubles each number in a list using the map() function.

11. Write a Python program that sorts a list of dictionaries based on multiple keys. For
example, sort a list of students by "grade" first and then by "name" if the grades are the
same.

12. Write a program to compute the mean, median, and standard deviation of a NumPy
array.

13. Write a program to create a pandas Series and a DataFrame, each with at least two
elements.

14. Write a program to filter rows in a DataFrame where a specific column's value is greater
than 50.

15. Write a program to load a CSV file into a pandas DataFrame and display the first 5 rows.
16. Write a program to group data in a DataFrame by a column and calculate the average of
another column.

17. Write a program to merge two DataFrames on a common column.

18.Write a function that takes a list of integers and returns a list of only the unique elements,
without using the set() function

19. Write a program to replace missing values in a DataFrame with the mean of their
column.

20. Write a program to create a NumPy array, find its shape, and print all elements greater
than a given value.

You might also like