Learn with Yasir

Share Your Feedback

Independent Practical Task


14. Independent Practical Task

Now complete the following exercises independently.

The exercises are arranged from beginner to advanced level.

D. Practical Programming Tasks (2)

Question 12. Monthly Electricity Consumption

A household records electricity consumption over six months.

Month Units Consumed
January 250
February 280
March 260
April 300
May 320
June 350

Create a line chart that:

  1. Displays monthly electricity consumption.
  2. Includes a title and axis labels.
  3. Uses a blue line with circular markers.
  4. Displays gridlines.
  5. Shows the numerical values beside each point.
  6. Explains the overall trend.

Question 13. Compare Two Departments

A university wants to compare student enrollment in two departments.

Month Computer Science Mathematics
January 40 30
February 45 35
March 50 38
April 55 42
May 65 45
June 70 50

Create a multiple line chart that:

  1. Displays both departments.
  2. Uses different colors and markers.
  3. Uses different line styles.
  4. Includes a title and axis labels.
  5. Displays a legend.
  6. Displays gridlines.
  7. Identifies which department has higher enrollment.

Exercise 1: Beginner – Monthly Shop Sales

Scenario

A shop owner wants to monitor monthly sales.

Use the following dataset:

Month Sales (PKR)
January 20,000
February 25,000
March 22,000
April 30,000
May 35,000
June 40,000
July 38,000
August 45,000
September 50,000
October 48,000
November 55,000
December 65,000

Requirements

  1. Prepare two Python lists.
  2. Create a line chart using plt.plot().
  3. Add an appropriate chart title.
  4. Label both axes.
  5. Change the line color to green.
  6. Add circular markers.
  7. Display gridlines.
  8. Display the chart.

Questions

  • Which month has the highest sales?
  • Which month has the lowest sales?
  • During which month did sales decrease?
  • What is the overall sales trend?

Exercise 2: Intermediate – Daily Student Attendance

Scenario

A teacher records the attendance of students over 15 working days.

Use the following dataset:

Day Students Present
Day 1 35
Day 2 38
Day 3 36
Day 4 40
Day 5 42
Day 6 39
Day 7 43
Day 8 45
Day 9 41
Day 10 44
Day 11 46
Day 12 48
Day 13 45
Day 14 47
Day 15 50

Requirements

  1. Prepare the attendance dataset.
  2. Create a line chart.
  3. Add a suitable title.
  4. Label the X-axis and Y-axis.
  5. Add circular markers.
  6. Change the line color.
  7. Add gridlines.
  8. Display data labels for each point.
  9. Rotate the X-axis labels if necessary.

Questions

  • Which day has the highest attendance?
  • Which day has the lowest attendance?
  • How many students were present on Day 10?
  • Did attendance generally increase or decrease?

Exercise 3: Advanced – Department-wise Student Enrollment

Scenario

A university wants to compare enrollment in three departments over 12 months.

Use the following dataset:

Month Computer Science IT Mathematics
Jan 50 40 30
Feb 55 45 32
Mar 60 48 35
Apr 65 55 38
May 70 60 40
Jun 75 65 45
Jul 80 70 48
Aug 85 75 50
Sep 90 80 55
Oct 95 85 58
Nov 100 90 60
Dec 110 100 65

Requirements

  1. Prepare four Python lists.
  2. Create a multiple line chart.
  3. Display all three departments on the same chart.
  4. Use different colors for each department.
  5. Use different markers.
  6. Use different line styles.
  7. Add a chart title.
  8. Label both axes.
  9. Add a legend.
  10. Add gridlines.
  11. Display the chart using plt.show().

Questions

  • Which department has the highest enrollment?
  • Which department has the lowest enrollment?
  • Which department shows the greatest overall growth?
  • Do all three departments show an increasing trend?
  • Why is a multiple line chart suitable for this comparison?