Class 12 Informatics Practices
Worksheets
Worksheet 1: Data Handling using Pandas
Topic: Series and DataFrame
1. Q1. Create a Series `s1` from a list of marks: [78, 85, 62, 90, 71] and display it.
2. Q2. Create a Series with subject names as index and marks as values.
Subjects = ['Math', 'Physics', 'Chemistry', 'English', 'CS']
Marks = [95, 89, 76, 88, 93]
3. Q3. Create a DataFrame `df1` with following data:
| Name | Age | City |
|-------|-----|-----------|
| Anuj | 17 | Delhi |
| Riya | 18 | Mumbai |
| Tarun | 17 | Bangalore |
- Print only the names.
- Show all the cities.
- Show the info and describe of the DataFrame.
4. Q4. What is the difference between Series and DataFrame in pandas? Give examples.
5. Q5. Write code to:
- Add a new column “Grade” in the above DataFrame.
- Drop the column “Age” from it.
Worksheet 2: DataFrame Operations
6. Q1. Create a DataFrame for 5 students with columns: `Name`, `Marks`, `Grade`.
7. Q2. Find:
- Maximum and minimum marks.
- Average of marks.
- Count of students scoring more than 90.
8. Q3. Filter rows where `Grade == 'A'`.
9. Q4. Sort the DataFrame based on Marks in descending order.
10. Q5. Rename column `Marks` to `Score`.
Worksheet 3: Data Visualization using Matplotlib
Topic: Line Chart, Bar Graph, Pie Chart
11. Q1. Plot a line chart for years vs population:
Years = [2000, 2005, 2010, 2015, 2020]
Population = [100, 120, 150, 180, 210]
12. Q2. Create a bar graph for the following data:
Subjects = ['Math', 'Physics', 'Chemistry', 'English']
Marks = [90, 80, 75, 88]
13. Q3. Plot a pie chart showing the % of devices used by students:
Devices = ['Mobile', 'Laptop', 'Tablet']
Users = [60, 30, 10]
14. Q4. Customize the graphs by adding:
- Titles
- Labels on x and y axis
- Grid lines
- Color styling
15. Q5. Difference between bar() and barh() functions in matplotlib.