0% found this document useful (0 votes)
15 views

Practice Model Coding Questions

The document provides practice coding questions related to data analysis and visualization using Python libraries like Pandas and Matplotlib. The questions involve loading and manipulating datasets, creating scatter plots, bar charts and scatter matrices to analyze relationships between variables.

Uploaded by

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

Practice Model Coding Questions

The document provides practice coding questions related to data analysis and visualization using Python libraries like Pandas and Matplotlib. The questions involve loading and manipulating datasets, creating scatter plots, bar charts and scatter matrices to analyze relationships between variables.

Uploaded by

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

"Disclaimer: The questions given here are indicative of the format of

questions in coding section of the end semester exam, and not exhaustive.
The final question paper for your exam will be set by the University and will
have a wide range of questions. Please use this model in conjunction with
your other course materials to prepare well for your exams."

Practice coding questions

1. Sofia is a psychology student and she wants to analyze the relationship between the age and
happiness score of people. Write a program to:
a) import pandas library
b) load data set "happiness_scores.csv"
c) Get the first 10 rows of the data set
d) Plot a scatter plot having "Age" in the x-axis and "Happiness_Score" in the y-axis

2. Write a program in Matplotlib to create a stacked bar chart using the following data:
[email protected]
4U6SFIGVQN categories = ['Cat A', 'Cat B', 'Cat C']
values1 = [20, 35, 30]
values2 = [25, 32, 28]
values3 = [18, 28, 35]

3. Using the following dataset:


import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data = pd.DataFrame({
'month': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
'revenue': [5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000],
'profit': [1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500],
'expenses': [500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]
})
Create a plot that shows the revenue, profit, and expenses for each month as stacked bars. Add
appropriate titles, labels, and legends to the plot.

4. Using the following dataset:

import pandas as pd

import numpy as np

This file is meant for personal use by [email protected] only.


Sharing or publishing the contents in part or full is liable for legal action.
import matplotlib.pyplot as plt

data = pd.DataFrame({

'income': np.random.normal(50000, 10000, 100),

'age': np.random.normal(30, 5, 100),

'education': np.random.choice(['high school', 'college', 'graduate'], size=100),

'gender': np.random.choice(['male', 'female'], size=100)

})

Create a scatter plot that shows the relationship between income and age, with different colors and
markers for males and females. Add appropriate titles, labels, and legends to the plot. Then, create a
scatter matrix that shows the relationships between income, age, and education, with different colors and
markers for males and females..

[email protected]
4U6SFIGVQN

This file is meant for personal use by [email protected] only.


Sharing or publishing the contents in part or full is liable for legal action.

You might also like