Skip to main content

Homework 11 — TuneTracker: Functions, Mutation, and Equality (Python)

Skills: 8, 9, 12

Due

Thursday, November 20, 2025 at 6PM (Oakland) or 9PM (Boston)


Introduction

You're building a music streaming service called "TuneTracker". The system needs to manage playlists, track listening statistics, and analyze user preferences. Throughout this assignment, you'll explore how Python handles functions, variable mutation, and different types of equality in the context of music data.

Problem 1

Design a function calculate_song_popularity that takes three parameters:

  1. play_count (int): Number of times the song has been played
  2. likes (int): Number of likes the song has received
  3. shares (int): Number of times the song has been shared

The function should return a popularity score using this formula:

  • Play count contributes 60% of the score (normalized by dividing by 1000)
  • Likes contribute 30% of the score (normalized by dividing by 100)
  • Shares contribute 10% of the score (normalized by dividing by 10)

Problem 2

Design the function total_listening_time that takes a list of song durations (in seconds) and returns the total time.

Problem 3

Part A

Design a function extend_songs_immutable that adds 10 seconds to every song duration in a playlist, returning a new list without modifying the input.

Part B

Design a function extend_songs_mutable that adds 10 seconds to every song duration in a playlist, modifying the input list directly using list indexing.

Problem 4

Like other music streaming services, TuneTracker must pay royalties to musicians whose music it streams. The overall royalty payments due for any given period are, in part, a function of the number of times a musician’s music was streamed. You are deciding whether TuneTracker should try to filter out music that was generated by people using AI tools such as Suno (https://suno.com/home), or whether to allow such music and track the number of times it’s streamed.

Part A

Identify at least three unique categories of stakeholder. For each stakeholder, identify a corresponding interest or value of theirs that might be at stake when deciding whether to allow and to track AI music.

StakeholdersInterest/Value
Stakeholder 1
Stakeholder 2
Stakeholder 3
(Stakeholder n)

Note: you don't have to format this as a table in your solution; you can just list them in comments, as:

# first stakeholder: ...
# interest/value: ...
# second stakeholder: ...
...

Part B

In two or three sentences, explain how at least two different stakeholders’ interests or values from your stakeholder matrix in Part A might conflict.