Hello Tutors!
I am an ambitious Python newbie without any CS background! I am currently
taking an online 30-hour/36-lecture Python course which I am enjoying a lot. I
am religiously answering the quizzes and solving all the exercise problems
(usually short and straightforward).
So far, I have learned introductory topics such as data types,
lists/dictionaries/tuples/sets, conditional statements, for and while loops,
functions, and apparently uncommonly used lambdas (along with maps and
filters). I know that my real, long battle lies ahead.
Almost midway through the course, with the latest course content on lambdas,
filters, maps, min/max built-in functions and created a long problem statement
for an interesting self-exercise. However, I might have gotten a tad bit too
ambitious and need help.
Below is my long problem statement: Please ignore the details regarding some
ultra-popular Bollywood song artists and only a fraction of their most popular
song titles. You can replace the artists' names and their Bollywood song
titles with western artists' names and their respective song titles if the
current names and titles are too distracting.
I would appreciate it if you could simply focus on the nature of the data to be
used and the multi-part problem. Those who might be willing to help, it would
be easier if you copy and paste the entire code below into a Python 3 text
editor such as Sublime Text (which I am using).
Also, I have added my personal comments on problems which I have attempted so
far and either solved completely or have come dangerously close to solving. I
am not looking for a spoon-fed solution to every single unsolved problem. Just
something that would push me over to the next step would suffice. I know
conceptually how I would solve each of these problems anyone can solve them in
their mind. What I'm struggling the most with is the syntax and order of
certain functions when solving. Perhaps I am not considering some intermediate
code steps that are required and/or helpful.
Please note that the primary objective is to solve these problems using
lambdas, filters, maps, etc. and NOT for or while loops or list comprehensions.
Any help will be greatly appreciated with heartfelt thanks and email
fist-bumps. Thank you for your time and consideration.
Regards,
Rahul A.
So here it goes.
# This function accepts a list of several dictionaries that contain song
artists' names and their song titles and
# returns the following outputs in tuples (remember to return a tuple for each
output!):
# 1. The highest number of songs sung by any artist
# 2. The name of the artist with the highest number of songs
# 3. A tuple containing the name of the artist and their number of songs sung
# 4. The longest song title in the entire song list
# 5. The name of the artist with the longest song title
# 6. A tuple containing the name of the artist w/ longest song title and their
longest song title
# 7. A tuple containing the name of the artist w/ longest song title and the
length of their longest song title
# 8. A list of artists and their number of songs sung sorted (default ascending
order) by the number of song titles
# 9. A list of artists and their longest song titles sorted in descending order
of the length of the song title
# 9a. Similar list as original but longest title listed first and shortest
title listed last for each artist
# 9b. BONUS: same as 9a above with artists sorted in default ascending order.
Thus the artists will be listed
# in regular alphabetical order, but their song titles will listed in the
descending order of title length
songmix = [
{"artist":"Rafi","titles":["Pukarta chala hoon main","Aapke haseen rukh
pe","Thaheriye hosh main aaloon","Woh jab yaad aaye","Deewana hua badal","Ehsan
tera hoga mujhpar"]},
{"artist":"Asha","titles":["Aja aja main hun pyar tera","Dil cheez kya
hai","Aaiye meherban","Aao huzur tum ko","In aankhon ki masti mein","Paan khaye
saiyan humaro"]},
{"artist":"Suman","titles":["Rahete kabhi jinke dil mein","Na tum hamen
jano","Jo hum pe guzarti hai","Rahe na rahe hum","Aajkal tere mere pyar
ke","Tujhe dekha tujhe chaha","Parbaton ke pedon par","Tumne pukara aur"]},
{"artist":"Kishor","titles":["Beqarar dil","Nile nile ambar
pe","Muqaddar ka sikandar","Mere mehboob kayamat hogi","Mere sapno ki rani
kab","Pyar diwana hota hai","O mere dil ke chain","Yeh shaam mastani","Pal pal
dil ke paas"]},
{"artist":"Lata","titles":["Lag ja gale","Tera jana dil ke armanon
ka","Tera mera pyar amar","Yoon hasraton ke daag","Awaz deke hamen tum
bulao","Mujhe kitana pyar hai tumse","Mausam hai aashiqana","Tujhe dekha to
jana sanam","Salam-e ishq meri jaan","Yeh dil aur unki"]},
{"artist":"Hemant","titles":["Tumhe yaad hoga","Tum pukar lo","Jane wow
kaise log the","Neend na mujhko aye","Beqarar karke humein",]},