1.3.3. Homework#
Use this assignment to practice the chapter’s concepts and coding skills in runnable Python code.
Sign in from the account menu before you start working on the assignment.
Write and run your code directly in the coding cells.
Multiple submissions are allowed. The highest score is kept.
1. Data Science in a Retail Decision
A retail team combines sales records, Python summaries, statistics, merchandising knowledge, and a manager-facing recommendation to decide which products to reorder. Calling this work data science is appropriate.
2. Data Without Context
A marketing analyst has click data but does not know the campaign goal, product margins, or customer segment. The analyst can still decide the best campaign from the data alone.
3. Descriptive Questions
A store manager asks, “How many returns did each product category have last month?” This is mainly a descriptive data science question.
4. Predictive and Prescriptive Questions
An operations director asks, “Which shipments are most likely to arrive late next week?” This is mainly a prescriptive question.
5. Formal Language Rules
A finance script has the right formula but is missing a closing quote in one print() statement. Because the business idea is correct, Python syntax rules will not affect whether the program runs.
### 6. Classify Management Questions
# A customer success team is reviewing subscription cancellations.
# Store the correct label for each question: descriptive, predictive, or prescriptive.
# Then print each label with the question name.
#
# question_a: How many customers canceled last month?
# question_b: Which customers are most likely to cancel next month?
# question_c: Which retention offer should we send first?
question_a = ""
question_b = ""
question_c = ""
### Your code starts here.
### Your code ends here.
Question A: descriptive
Question B: predictive
Question C: prescriptive
### 7. Write a Stakeholder Status Line
# The lab asked you to print technical values. Here, turn values into a concise status line.
# Use an f-string and the variables below to print exactly:
# North store has 7 late shipments out of 80.
store = "North"
late_shipments = 7
total_shipments = 80
### Your code starts here.
### Your code ends here.
North store has 7 late shipments out of 80.
### 8. Fix a Syntax Error
# The lab asked you to write correct statements. Here, practice recognizing broken syntax.
# The two lines below have syntax problems:
# print("DSM homework"
# print("Syntax fixed.")
# Write corrected code that prints exactly:
# DSM homework
# Syntax fixed.
### Your code starts here.
### Your code ends here.
DSM homework
Syntax fixed.
### 9. Build an Inventory Code
# The lab printed separate number-system and character-code values.
# Here, combine those pieces into one inventory code.
# Use ord() and hex() with the variables below to print exactly:
# Inventory code: R-82-0x2d
category = "R"
item_id = 45
### Your code starts here.
### Your code ends here.
Inventory code: R-82-0x2d
### 10. Calculate Audit Metrics
# The lab calculated an order total. Here, calculate simple management metrics from case counts.
# Use the variables below to calculate open_cases and closure_rate.
# Print exactly:
# Open cases: 17
# Closure rate: 0.67
starting_cases = 20
new_cases = 7
closed_cases = 10
assigned_cases = 15
### Your code starts here.
### Your code ends here.
Open cases: 17
Closure rate: 0.67