[Tutor] A Python Newbie Requesting help with Lambdas, Filters, and Maps

2019-05-20 Thread Rahul Alawani
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",]},

Re: [Tutor] Case Insensitive Globing

2019-05-20 Thread Alan Gauld via Tutor
On 20/05/2019 09:49, Alan Gauld via Tutor wrote:
> On 19/05/2019 19:19, Alan Gauld via Tutor wrote:
> ...
>> So I always end up with two copies - the original file and the
>> edited version.

> I forgot I had moved all my photos onto my NAS box
> and then mounted that in my pictures library under
> Windows 10. 

On closer study it was slightly more complex.
In fact, the errant editor is actually a Linux utility program
that I only rarely use but which uses the same NAS folder as is
used by the Windows box(obviously, that's why it's on the NAS!)
Now, because I do 90% of my photo editing on Windows (Affinity
Photo really is superb!), I only noticed the duplicate file
names there and so assumed it was a Windows thing.

So,to summarize:
I copy the files from the camera to the (Linux based) NAS.
I edit the file on my Linux PC (which saves with the .jpg extension)
Then I open the folder for serious editing on Windows and
see two filenames differing only in the case of the extension.

No NTFS involved.
Just memory loss from a befuddled senior... :-(

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Case Insensitive Globing

2019-05-20 Thread Alan Gauld via Tutor
On 19/05/2019 19:19, Alan Gauld via Tutor wrote:

> Hmm, odd. My NTFS filesystems on Windows all appear to be case
> sensitive. For example I have a photo editor that saves its files
> with a jpg extension but the files from my camera all end in JPG.
> So I always end up with two copies - the original file and the
> edited version.

Amazing how you forget the simple things over time.
I forgot I had moved all my photos onto my NAS box
and then mounted that in my pictures library under
Windows 10. Because you access them via the Library
feature I'd completely forgotten they were on the
NAS. So the filesystem is really ext3 and
I'm assuming that's why the double names exist...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor