Name=Mayank kumar Topic=Tutorial 2
Registration no.=25BCE10023
1. Bar Chart
Question: Create a bar chart that shows the number of students enrolled in different
courses at a university. Use the following dataset:
courses = [’Mathematics’, ’Physics’, ’Chemistry’, ’Biology’, ’Computer Science’]
enrollment = [120, 85, 75, 90, 150]
Expected Plot: A bar chart with courses on the x-axis and the number of students on the
y-axis.
CODE: OUTPUT
2. Pie Chart
Question: Generate a pie chart showing the market share of different smartphone
brands. Use the dataset below:
brands = [’Apple’, ’Samsung’, ’Huawei’, ’Xiaomi’, ’OnePlus’]
market_share = [35, 25, 15, 15, 10]
Expected Plot: A pie chart with each slice representing a different smartphone brand
and its market share.
CODE: OUTPUT:
3. Linear Plot
Question: Plot a linear graph to visualize the change in temperature over a week. Use
the dataset:
days = [’Monday’, ’Tuesday’, ’Wednesday’, ’Thursday’, ’Friday’, ’Saturday’, ’Sunday’]
temperatures = [22, 24, 21, 19, 23, 25, 20]
Expected Plot: A line plot with days on the x-axis and temperatures on the y-axis.
CODE: OUTPUT:
4. Scatter Plot
Question: Create a scatter plot to show the relationship between hours studied and
scores obtained in an exam. Use the following dataset:
hours_studied = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
scores_obtained = [55, 60, 65, 70, 75, 80, 85, 90, 95, 100]
Expected Plot: A scatter plot with hours studied on the x-axis and scores obtained
on the y-axis.
CODE: OUTPUT:
5. Bar Chart with Custom Colors
Question: Plot a bar chart with custom colors for different product sales. Use the
dataset below:
products = [’Product A’, ’Product B’, ’Product C’, ’Product D’]
sales = [300, 150, 200, 250]
colors = [’blue’, ’green’, ’red’, ’purple’]
Expected Plot: A bar chart with each bar representing a product’s sales, using the
specified colors.
CODE: OUTPUT:
6. Pie Chart with Percentages
Question: Create a pie chart with percentages displayed on each slice. Use the dataset:
categories = [’Electronics’, ’Furniture’, ’Groceries’, ’Clothing’]
expenses = [400, 300, 500, 200]
Expected Plot: A pie chart with each slice showing the percentage of total expenses
for each category.
CODE: OUTPUT:
7. Linear Plot with Multiple Lines
Question: Plot a line graph with two lines to compare the sales performance of two
different products over a month. Use the following dataset:
days = [’Week 1’, ’Week 2’, ’Week 3’, ’Week 4’]
product_A_sales = [120, 135, 140, 150]
product_B_sales = [100, 110, 120, 130]
Expected Plot: A line plot with weeks on the x-axis and sales figures on the y-axis,
showing two lines for Product A and Product B.
CODE: OUTPUT:
8. Scatter Plot with Regression Line
Question: Generate a scatter plot with a regression line to analyze the relationship
between advertising spend and revenue. Use this dataset:
ad_spend = [1000, 2000, 3000, 4000, 5000]
revenue = [15000, 25000, 35000, 45000, 55000]
Expected Plot: A scatter plot with ad spend on the x-axis and revenue on the
y-axis, including a regression line.
CODE: OUTPUT:
9. Bar Chart with Horizontal Bars
Question: Create a horizontal bar chart to show the top 5 best-selling books in a store.
Use the dataset:
books = [’Book A’, ’Book B’, ’Book C’, ’Book D’, ’Book E’]
copies_sold = [250, 300, 200, 400, 350]
Expected Plot: A horizontal bar chart with books on the y-axis and copies sold on
the x-axis.
CODE: OUTPUT:
10. Pie Chart with Exploded Slices
Question: Generate a pie chart with one exploded slice to emphasize the largest
[Link] the following data:
categories = [’Rent’, ’Utilities’, ’Groceries’, ’Entertainment’]
expenses = [1200, 300, 400, 200]
explode = (0.1, 0, 0, 0) % Explode the ’Rent’ slice
Expected Plot: A pie chart with the ’Rent’ slice exploded to highlight it, showing the
distribution of expenses.
CODE: OUTPUT: