0% found this document useful (0 votes)
3 views6 pages

Computer Programming Task

The document outlines a series of tasks using Matplotlib to create various types of plots, including line plots, bar charts, histograms, scatter plots, and pie charts. Each task includes Python code snippets for visualizing data such as temperature changes, student marks, age distribution, study hours vs exam marks, daily activities, monthly sales, books read, height vs weight, favorite subjects, and company profit and loss over time. The document serves as a practical guide for generating visual data representations in Python.

Uploaded by

shayaniqbal788
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)
3 views6 pages

Computer Programming Task

The document outlines a series of tasks using Matplotlib to create various types of plots, including line plots, bar charts, histograms, scatter plots, and pie charts. Each task includes Python code snippets for visualizing data such as temperature changes, student marks, age distribution, study hours vs exam marks, daily activities, monthly sales, books read, height vs weight, favorite subjects, and company profit and loss over time. The document serves as a practical guide for generating visual data representations in Python.

Uploaded by

shayaniqbal788
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

13/06/2026, 15:46 Welcome To Colab - Colab

Task No:01 Create a line plot showing the change in temperature over 7 days.

import [Link] as plt

days = [1, 2, 3, 4, 5, 6, 7]
temperature = [30, 32, 31, 35, 36, 34, 33]

[Link](days, temperature, marker='o')


[Link]("Temperature Over 7 Days")
[Link]("Days")
[Link]("Temperature (°C)")
[Link](True)
[Link]()

Task No:02 Draw a bar chart to compare marks of 5 students in a class.

import [Link] as plt

students = ["Ali", "Ahmed", "Sara", "Ayesha", "Usman"]


marks = [85, 78, 92, 88, 80]

[Link](students, marks)
[Link]("Marks of Students")
[Link]("Students")
[Link]("Marks")
[Link]()

[Link] 1/6
13/06/2026, 15:46 Welcome To Colab - Colab

Task No:03 Plot a histogram to represents the distribution of students ages in a class.

import [Link] as plt

ages = [18, 19, 20, 18, 21, 20, 19, 18, 22, 20, 19]

[Link](ages, bins=5)
[Link]("Distribution of Students Ages")
[Link]("Age")
[Link]("Frequency")
[Link]()

Task No:04 Create a scatter plot showing relationship between study hours and exam marks.

[Link] 2/6
13/06/2026, 15:46 Welcome To Colab - Colab
import [Link] as plt

study_hours = [1, 2, 3, 4, 5, 6, 7]
marks = [40, 50, 55, 65, 70, 85, 90]

[Link](study_hours, marks)
[Link]("Study Hours vs Exam Marks")
[Link]("Study Hours")
[Link]("Marks")
[Link]()

Task No:05 Draw a pie chart showing the percentage of time spent on daily activites

import [Link] as plt

activities = ["Study", "Sleep", "Sports", "Entertainment"]


hours = [6, 8, 4, 6]

[Link](hours, labels=activities, autopct="%1.1f%%")


[Link]("Daily Activities")
[Link]()

Task No:06 Create a line graph showing monthly sales of a shop for 6 months

import [Link] as plt

[Link] 3/6
13/06/2026, 15:46 Welcome To Colab - Colab
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"]
sales = [5000, 7000, 6500, 8000, 9000, 8500]

[Link](months, sales, marker='o')


[Link]("Monthly Sales")
[Link]("Months")
[Link]("Sales")
[Link](True)
[Link]()

Task No:07 Plot a bar chart comparing number of books read by different students.

import [Link] as plt

students = ["Ali", "Ahmed", "Sara", "Ayesha", "Usman"]


books = [5, 7, 4, 8, 6]

[Link](students, books)
[Link]("Books Read by Students")
[Link]("Students")
[Link]("Number of Books")
[Link]()

Task No:08 Create a scatter plot to show height vs weight of students in a class.

[Link] 4/6
13/06/2026, 15:46 Welcome To Colab - Colab

import [Link] as plt

height = [150, 155, 160, 165, 170, 175]


weight = [45, 50, 55, 60, 65, 70]

[Link](height, weight)
[Link]("Height vs Weight")
[Link]("Height (cm)")
[Link]("Weight (kg)")
[Link]()

Task No:09 Draw a pie chart showing favorite subjects of students in a class.

import [Link] as plt

subjects = ["Math", "Science", "English", "Computer", "Urdu"]


students = [10, 8, 6, 12, 4]

[Link](students, labels=subjects, autopct="%1.1f%%")


[Link]("Favorite Subjects of Students")
[Link]()

Task No:010 Create a combined line plot showing profit and loss of a company over 5 years.

import [Link] as plt

years = [2021 2022 2023 2024 2025]


[Link] 5/6
13/06/2026, 15:46 Welcome To Colab - Colab
years = [2021, 2022, 2023, 2024, 2025]
profit = [5000, 7000, 9000, 12000, 15000]
loss = [2000, 1500, 3000, 2500, 1000]

[Link](years, profit, marker='o', label="Profit")


[Link](years, loss, marker='s', label="Loss")

[Link]("Profit and Loss Over 5 Years")


[Link]("Years")
[Link]("Amount")
[Link]()
[Link](True)

[Link]()

[Link] 6/6

You might also like