The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 305 Weeks Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Needs to be written in python code with a .py attachment. Please refer to attachment
Attached to this homework is a text file that has 355 lines. Each line contains some song information. This information is rank of song, artist, and title of song.
The rank is a number between 1 and 500.
Write a program that reads the file line by line. Then parses each line to two parts. First part is the ranking. Second part is the artist and title of song. Then your program should utilize dictionaries to save this information. The song rank should be the unique id (key). The artist and title should be mapped to the rank(Value). An item in the dictionary will look like this
“400 : Bruce Springsteen, Pink Cadillac”
Your program should:
1. Ask the user to input a rank between 1 and 500.
2. Check if a song with that rank exists in the dictionary
If yes:
Print the name of the artist along with the song title
If no:
Print a message indicating that there is no song with the requested rank.
Output examples:
If the user input the rank 480, the following output is produced:
If the user input the rank 120, the following output is produced:
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly