# You must make sure to run all cells in sequence using shift + enter or you might encounter errors
from pykubegrader.initialize import initialize_assignment

responses = initialize_assignment("3_flow_control_q", "week_5", "readings", assignment_points = 16.0, assignment_tag = 'week5-readings')

# Initialize Otter
import otter
grader = otter.Notebook("3_flow_control_q.ipynb")

โ“ Functions and Flow Control in the Mall#

Edith Macefield became a symbol of defiance and resilience when she refused a $1 million offer to sell her small, humble home in Seattleโ€™s Ballard neighborhood to make way for a commercial development. Developers planned to construct a sprawling shopping center but faced an immovable obstacle in Macefield, who chose to stay in the house where she had lived for decades. Her steadfastness turned her into a local legend, and her story inspired comparisons to the movie Up. Rather than forcing her out, the developers built the five-story complex around her home, leaving it dwarfed by the surrounding structure. Macefieldโ€™s determination to remain true to her roots captured the publicโ€™s imagination, making her a beloved figure and a poignant reminder of the value of standing up for what matters most to you.

# Run this block of code by pressing Shift + Enter to display the question
from questions._3_flow_control_q import Question1
Question1().show()
# Run this block of code by pressing Shift + Enter to display the question
from questions._3_flow_control_q import Question2
Question2().show()
# Run this block of code by pressing Shift + Enter to display the question
from questions._3_flow_control_q import Question3
Question3().show()

Question 1 (Points: 7.0): Write a Function to Calculate Total Revenue#

The mall is analyzing its revenue from parking fees. Write a Python function calculate_total_revenue that:

  • Accepts a list of hours parked by multiple cars.

Calculates the total revenue, using the following parking fee rules:

  • $5 for up to 2 hours.

  • $10 for 3-5 hours.

  • $15 for more than 5 hours.

  • Returns the total revenue.

...

# Example usage
hours_parked = [1, 3, 6, 2, 5]
print(calculate_total_revenue(hours_parked)) # Should print 45
grader.check("Mall-calculation-total-revenue")

Submitting Assignment#

Please run the following block of code using shift + enter to submit your assignment, you should see your score.

from pykubegrader.submit.submit_assignment import submit_assignment

submit_assignment("week5-readings", "3_flow_control_q")