Welcome! In this quiz, youβll review:
- Forking a GitHub repository
- Using a provided Python function
- Performing a simple data transformation
- Creating a basic plot
- Committing your work back to GitHub
You have 60 minutes to complete all tasks. Good luck!
sales.csvβ A small dataset of product saleshelpers.pyβ Contains add_revenue function to help with your analysis
β Do not modify these files. Create new files for your work.
- Fork this repository to your GitHub account.
- Clone your fork to your local machine.
- Create a new Python script called
run_analysis.pythat does the following:- Loads
sales.csvusingpandas - Columns:
product,units,price - Task: Add a
total_revenuecolumn (units * price). - Imports and uses the
add_revenue()function fromhelpers.py - Saves the updated data as
sales_with_revenue.csv - Creates a simple bar plot of
productvsrevenueand saves it asrevenue_plot.png
- Loads
- Run your script to generate the output files.
- Bonus: print the product which generates the most revenue
- Deliverables (Must Be in Your Fork by Deadline):
- Python script:
run_analysis.py - Updated CSV:
sales_with_revenue.csvwithtotal_revenuecolumn - Plot image:
revenue_plot.png
- Python script:
Uploads are time-stamped by GitHub. Do not re-upload after deadline.
# You can modify this file if you want
import pandas as pd
import matplotlib.pyplot as plt
from helpers import add_revenue
# Load data
df = pd.read_csv('sales.csv')
# Add revenue column using the provided function
df = add_revenue(df)
# Save updated CSV
df.to_csv('sales_with_revenue.csv', index=False)
# Create and save a simple bar plot
plt.figure(figsize=(8, 5))
plt.bar(df['product'], df['revenue'])
plt.title('Revenue by Product')
plt.ylabel('Revenue ($)')
plt.xticks(rotation=45)
plt.tight_layout()
plt.savefig('revenue_plot.png')
print("β
Done! Check for sales_with_revenue.csv and revenue_plot.png")