Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction The aim of this homework is to practice on file operations and dictionaries. In addition, please try to utilize functions since they would reduce

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Introduction The aim of this homework is to practice on file operations and dictionaries. In addition, please try to utilize functions since they would reduce the complexity of your program. Description You are given a file named "turkiye_spotify_data.txt", which stores the daily ranking of top 200 songs listened in Turkiye by Spotify users between 1st January 2017 to 9 th January 2018 (including both). Your task is to develop a Python program which, given a year and a month, recommends that month's top hits in sequence until the song the user wants to hear is found. In your program, the user will provide two inputs: year and month. Herein, the year must be either 2017 or 2018 , and the month must be between 1 and 12 , if the year is 2017; and only 1 , if the year is 2018. Your program should make sure that the inputs provided obey the rules mentioned. Your code will then process the given Spotify data to find the song with the most streams in the specified year and month. As your program suggests songs to its user, it will also ask whether they want to listen to this song or not. When the answer is yes, your program should share the url of the song and finish afterwards. Otherwise, your program should continue suggesting upcoming songs based on the streaming number in the asked month, until the user decides to listen. Please see the "Sample Runs" section for better understanding on the flow of the program, the inputs and the outputs. You will be given only one input file sample. The name of this input file will be turkiye_spotify_data.txt. This file contains information about the songs on Spotify, including the song's position on the chart, the track name, artist, number of streams, URL, release date, and region. Each line of this file represents a different song, and the data for each song is separated by a horizontal tab character ("\t"). You can assume that the file information will be given in the correct format. Thus, you don't have to perform any format check on the file content. You can also assume that there are no duplications and no empty lines in the file. However, you cannot make any aspumptions on the number of lines of this file. Keep this in mind while you're preprocessing the content of the file. THE FOLLOWING RED PART WAS ADDED LATER, PLEASE CHECK IT OUT Note that there can be different versions of some songs with the same name (but with a different url). For instance "Cheap Thril1s" from "Sia" has two different versions in January 2017 with the following links: 'https://open. spotify,com/track/27SdWb2rFzO6GWiYDBTD9j' 'https://open.spotify.com/track/378iszndTZAR4dH8kwsLC6' Please consider them as the same song, and consider their both streaming counts, but the link for this song should be the first link that appears on this month. So, the track name + artist name together should be unique. And the link for 'Cheap Thri11s, Sia' in January 2017 should be the following one: 'https://open. spotify.com/track/27SdWb2rFz06GWiYpBTD9j' Sample Run 1 Enter the year: 2017 Enter the month: 11 NEW SUGGESTION: Etei Belinde, Manu Baba (Total stream number in this month: 1671410) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: rockstar, Post Malone (Total stream number in this month: 1531063) Do you want to listen this song (enter either yes or no): yes Enjoy rockstar, Post Malone. Here is the url for you: https://open. spotify,com/track/7wGoVu4Dady5GVOSv4UIsx Sample Run 2 Enter the year: 2023 Enter the year: 2016 Enter the year: 2017 Enter the month: 6 NEW SUGGESTION: Despacito - Remix, Luis Fonsi (Total stream number in this month: 1665129) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Shape of You, Ed Sheeran (Total stream number in this month: 1455589) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Attention, Charlie Puth (Total stream number in this month: 1094736) Do you want to listen this song (enter either yes or no): yes Enjoy Attention, Charlie Puth. Here is the url for you: https://open, spotify, com/track/4ilag9SeJSntoCSPICSjxv Sample Run 3 Enter the year: 2018 Enter the month: 7 Enter the month: 4 Enter the month: 1 NEW SUGGESTION: Yan yoruz, Burak King (Total stream number in this month: 790051) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Heyecan y Yok, Gazapizm (Total stream number in this month: 675705) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Gmn Beni ukura, Eypio (Total stream number in this month: 560320) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: rockstar, Post Malone (Total stream number in this month: 536499) Do you want to listen this song (enter either yes or no): yes Enjoy rockstar, Post Malone. Here is the url for you: httos://open, spotify, com/track/7wGoVu4Dady5GVOSv4UIsx Sample Run 4 Enter the year: 2017 Enter the month: 2 NEW SUGGESTION: Shape of You, Ed Sheeran (Total stream number in this month: 2050088) Do you want to listen this song (enter either yes or no): nr Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Deli, Norm Ender (Total stream number in this month: 1084866) Do you want to listen this song (enter either yes or no): yes Enjoy Deli, Norm Ender. Here is the url for you: httpsi//open, spotify. com/track/2BZn6alrAFnKWmDAMcsIAn Sample Run 5 Enter the year: 2017 Enter the month: 4 NEW SUGGESTION: Shape of You, Ed Sheeran (Total stream number in this month: 2144459) Do you want to listen this song (enter ejther yes or no): YES Enjoy Shape of You, Ed Sheeran. Here is the url for you: https://open, spotify.com/track/7qiZfu4dY 12W22z7mPBI3 Sample Run 5 Enter the year: 2017 Enter the month: 4 NEW SUGGESTION: Shape of You, Ed Sheeran (Total stream number in this month: 2144459) Do you want to listen this song (enter ejther yes or no): YES Enjoy Shape of You, Ed Sheeran. Here is the url for you: https://open, spotify.com/track/7qiZfu4dY 12W22z7mPBI3 Sample Run 6 Enter the year: 2018 Enter the month: 1 NEW SUGGESTION: Yanyyoruz, Burak King (Total stream number in this month: 790051 ) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Heyecan Yok, Gazapizm (Total stream number in this month: 675705) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Gmn Beni ukura, Eypio (Total stream number in this month: 560320) Do you want to listen this song (enter either yes or no): 0 Do you want to listen this song (enter either yes or no): no I. NEW SUGGESTION: rockstar, Post Malone (Total stream number in this month: 536499) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Iki Ak, Ersay Oner (Total stream number in this month: NEW SUGGESTION: Imkansizam, Ezhel (Total stream number in this month: 478214) Do you want to listen this song (enter either yes or no) : no NEW SUGGESTION: Zalm, Ceylan Ertem (Total stream number in this month: 452216) Do you want to listen this song (enter efther yes or no): no NEW SUGGESTION: Geceler, Ezhel (Total stream number in this month: 433961) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Havana, Camila Cabello (Total stream number in this month: 423176) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: New Rules, Dua Lipa (Total stream number in this month: 406164) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Sehrimin Tadn, Ezhel (Total stream number in this month: 380631) Do you want to listen This song (enter either yes or no): no NEW SUGGESTION: Ozlmedin mi?, Simge (Total stream number in this month: 358308) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Him \& I (with Halsey), G-Eazy (Total stream number in this month: 342199) Do you want to listen this song (enter either yes or no): no NEW SUGGESTION: Etei Belinde, Manus Baba (Total stream number in this month: 308352) Do you want to Listen this song (enter either yes or no): yes Enjoy Etei Belinde, Manuss Baba. Here is the url for you: https://open,spotify,com/track/3lPrs LfylHXjPPfstoDXDg

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions