Reminder of Project guidelines
1. Projects are individual. Please work alone and do not share answers, in-progress work, etc. with classmates. You must create and type all of your code yourself.
2. You are welcome to use Python resources you find on Google. The only online resources that are not allowed are homework websites such as but not limited to Chegg, or coding websites such as but not limited to StackOverflow.
Additionally, please do not consult roommates, friends, GradQuant, etc. I trust that you will follow the honor system.
3. You are welcome to ask for help on Campuswire on any of the Python topics covered in the pre-activity or listed as a reference below. I cannot provide specific project answers, and if you are responding to a Campuswire question, please do not share specific answers.
4. Any instances of suspected cheating will be investigated thoroughly. Please read the UCR Integrity Statement in the syllabus if you are unclear about what constitutes cheating.
Project 1: Python
Pre-Project learning references
You will need to learn about lists in Python before you can begin.
Lists part 1: PY4E – Python Lists (Chapter 8 Part 1)
Lists part 2: PY4E – Python Lists (Chapter 8 Part 2)
Lists part 3: PY4E – Python Lists (Chapter 8 Part 3)
Additionally, here are two resources you might find helpful.
Using the split() function: https://www.w3schools.com/python/ref_string_split.asp
Using the abs() function: https://www.w3schools.com/python/ref_func_abs.asp
Case scenario
DJ Yoshi is an aspiring DJ here at UCR. He hopes to one day play big shows. However, he needs some help identifying songs that mix well together. He’s turned to the MGT 205 class for help. Your goal is to write a Python program that can identify a song’s “energy” and see if two songs are a good mix.
What you need to know
In this program, a song is identified by its “track ID,” which is the artist’s name and the song title. This information is separated by a ^ character. The artist’s name is always first.
For example, the song “Dynasty” by the artist “Kaskade” would have a track ID of:
Kaskade^Dynasty
Spaces are allowed in the artist’s name and the song title. For example:
Rick Ross^Aston Martin Music
Use the starter code
Please find the starter code here: https://replit.com/@mgt205/Project-1-starter-code#main.py Copy the code into your own account. Make sure that you don’t change any of the provided code.
What is given to you
Function: get_energy(t)
This function takes an input parameter that is a song title. It returns the number of characters (in other words, the length) of the title. This number is the song’s “energy.”
What you need to create
Function: check_match(t1, t2)
This function takes two song titles (t1 and t2) as input parameters. This function should call get_energy twice, once for each song, to find each song’s energy. If the difference in energy between the two songs is not more than two, which means it is a GOOD mix, return true. Otherwise, it is a BAD mix; return false.
Function: mix(at1, at2)
This function displays whether two songs are a good mix or a bad mix. It takes two track IDs as input parameters. You need to first separate each track ID into artist name and song title. Then, call check_match with the two titles to determine if it’s a good mix. If it is a good mix, print the information for both songs and tell the user that the two songs are a GOOD mix. If it is a bad mix, print the information for both songs and tell the user that the two songs are a BAD mix. There should not be a ^ character or comma in the final output. This function does not need to return anything.
Function: main_menu()
In this function, ask the user how many PAIRS of songs they want to mix. Each pair of track IDs will be entered on one line, separated by a comma, with no spaces other than in the artist name or song title. For example:
Artist A^Song 1,Artist B^Song 2
Ask for and take in all pairs of track IDs before moving on.
Finally, call mix for each track ID pair.
This function does not need to return anything.
Assumptions and clarifications
You can assume that for each pair, the user will always enter two valid track IDs, separated by a comma, all on one line. Artist names and song titles can contain spaces and any punctuation except ^ and a comma.
Hint: the user can enter a large number of pairs, but there is a definite ending point. Once they’ve entered the chosen number of pairs, input stops.
You are required to call mix from main_menu.
You are required to call check_match from mix.
You are required to call get_energy from check_match.
You are not allowed to call check_match or get_energy directly from main_menu.
All pairs of tracks must be entered before you start the good mix / bad mix checks. See the sample output below and the highlighted line in the main_menu() description above. If your program asks for a pair of tracks and does a mix check one by one, you will not earn full credit.
A user can request to check 100, one million, or one billion pairs. You should write your program to handle any positive number of pairs. Do not limit your program to three pairs or print the pair number manually. Use proper logic to do this.
There should not be a ^ character or comma in your final output. You should print the song information as you would see it on Spotify, Apple Music, YouTube, etc. For example, if I enter
Prof. Rich^My Song,Scotty Highlander^UCR Anthem
The output should be
Prof. Rich – My Song and Scotty Highlander – UCR Anthem are…
You can use a dash to separate the artist and song name. Please see the sample output below.
A space in the song title counts as a character. However, get_energy() handles this automatically. Please do not change any of the code in that function.
Sample output
Each group of output is from a separate run of the program. The program only needs to run once each time.
How many PAIRS of songs do you want to mix? 3
Input track ID pair 1 : Rich^123,Rich^123
Input track ID pair 2 : Rich^123,Rich^12345
Input track ID pair 3 : Rich^123,Rich^123456
Rich – 123 and Rich – 123 are a GOOD mix
Rich – 123 and Rich – 12345 are a GOOD mix
Rich – 123 and Rich – 123456 are a BAD mix
In the sample output above, note the length of the song titles. 123 (three chars) and 123 (three chars) have a difference of zero, so it’s a good mix. 123 and 12345 have a difference of two, so it’s also a good mix. 123 and 123456 have a difference of three, so it’s a BAD mix. Remember that the cutoff for being a good mix is a difference of two.
How many PAIRS of songs do you want to mix? 1
Input track ID pair 1 : DJ Yoshi^Spaces Do Not Matter,Prof. Rich^Punctuation Doesn’t Matter Either
DJ Yoshi – Spaces Do Not Matter and Prof. Rich – Punctuation Doesn’t Matter Either are a BAD mix
How many PAIRS of songs do you want to mix? 3
Input track ID pair 1 : Kaskade^Dynasty,Kaskade^Angel On My Shoulder
Input track ID pair 2 : Drake^0 to 100,DJ Khaled feat. Future and Jay-Z^I Got The Keys
Input track ID pair 3 : Prof. Rich^Welcome to 205,Prof. Rich^Welcome to 205!
Kaskade – Dynasty and Kaskade – Angel On My Shoulder are a BAD mix
Drake – 0 to 100 and DJ Khaled feat. Future and Jay-Z – I Got The Keys are a BAD mix
Prof. Rich – Thank you for a great quarter and Your TAs – Thank you for a great quarter! are a GOOD mix
In the sample output above, there is only a one character difference between Welcome to 205 and Wlecome to 205!, which means it is a good mix.
Answer the question below
Your answer should be anywhere between half a page to one page long, single-spaced. Include your references below your answer (references can also go on the next page).
Question
The government of any country is usually very slow in making and passing new laws and changes. There is a lot of paperwork, voting, debating, and other things that need to happen. As you might imagine, government legislatures use a traditional waterfall approach.
Does this mean that government legislatures will always be constrained to the waterfall approach?
Choose one position below and justify your answer with information from articles, history, etc. In your answer, clearly state which position you are choosing. Address all points in the listed position.
Position A: “I believe government legislatures will always be constrained to a waterfall approach.” Describe why an agile process would not be possible in government legislatures—give an example, if possible. Describe why you feel government legislatures will always be constrained to a lengthy waterfall-style process.
Position B: “I believe government legislatures can switch to an agile process.” Describe the changes needed to switch to agile (you can use your home country’s government as an example). Describe the potential benefits or outcomes of switching to an agile process.
How to submit
Open a new Google Doc or Word file. Paste your Python link (see below) at the top. Make sure it turns blue and is clickable.
Type your answer to the essay question below the link.
If you are using Word, save your file as a PDF and upload it to the submission area. If you are using Google Docs, create a share link to your Doc and submit your share link as a text submission in iLearn.
In case you forgot: how to get your Python link
When you are done with your code, click into your browser’s address bar and copy that entire link.
Grading rubric
150 points total.
Essay 50 points (50 Excellent / 40 Satisfactory / 30 Unsatisfactory): Is your essay question well-written and justified using examples or resources? Proper writing skills — spelling, grammar, etc. — will factor into your grade on this part.
For the Python component, I will check a variety of things, including but not limited to:
1. Does your program run?
2. Does your program work successfully and follow the requirements?
3. Do you call the appropriate functions correctly?
Your program should work organically with any valid input.