----BEGIN CLASS---- [15:26] #startclass [15:26] Roll Call [15:26] Jason Braganza [15:26] Amey Jain [15:26] pooja kumari singh [15:26] Bhavin Gandhi [15:26] Ashwani Kumar Gupta [15:27] Deepika Upadhyay [15:27] Kshithij Iyer [15:27] Sandesh Patel [15:27] Krishnanand Rai [15:28] Okay. [15:28] Before we take questions, you can see there was enough time to discuss between all participants, but there were not many questions. [15:28] https://paste.fedoraproject.org/paste/1AFFhbd6xdXmNJvnMzZeEQ/raw [15:28] There is a list l. [15:29] Which has a few English words. [15:29] Devesh Verma [15:30] Write some code (using whatever is taught till now) on your notebook, and tell us which two words has highest usages? [15:31] Anu kumari Gupta [15:32] Priyanka Sharma [15:32] kushal, what do you mean by usages? [15:32] where to tally from? [15:33] avik, Number of times there in the list. [15:33] ok! [15:36] ! [15:40] next [15:45] Balaji [15:47] https://notebooks.azure.com/n/cL7jv4S75TY/notebooks/summertraining.ipynb [15:47] kushal, is it correct? [15:48] checking [15:48] Sorry once again my variable names are not correct [15:48] Apologies [15:48] It is confusing to read. [15:49] anuGupta, now suggestion: Use a dictionary to have each word as a key, and the number of times you see them is a value. [15:49] https://notebooks.azure.com/n/huqBE3doFt4/notebooks/pythonPractice.ipynb [15:49] anuGupta, Use that [15:49] https://paste.fedoraproject.org/paste/eaIGHXgLhYdrHflwHyhIvg [15:49] san-D, no access [15:49] Ok kushal [15:50] oops! [15:50] https://notebooks.azure.com/n/huqBE3doFt4/notebooks/pythonPractice.ipynb [15:50] sorry my azure notebook is not opening for some reason [15:50] san-D, still not accessible, post the library link [15:52] https://notebooks.azure.com/san-D/libraries/san-D [15:53] ashwanig: select pythoPractice [15:54] san-D, It is accessible now. I got the same output. Let kushal check :) [15:54] :) [15:55] san-D, when you are creating tuples, good idea is to put them inside of () [15:55] first = ("". 0) [15:55] and same [15:55] kushal: ok [15:57] https://notebooks.azure.com/n/Hh3H19RDTXs/notebooks/summertraining.ipynb [15:58] knrai, no access [15:59] https://notebooks.azure.com/anon-4cd7pa/libraries/knrai [16:02] knrai: good logic :) [16:04] knrai, Just a suggestion, don't you think `s` should have a better name? [16:05] ashwanig: yup [16:06] ! [16:07] next [16:07] When I am trying `for word, frequency in frequency_table:` I get a ValueError [16:08] it tells me that too many values to unpack. Why is that? [16:11] ashwanig, means frequency_table has more than 3 times for each item :) [16:11] Anyway, for everyone, https://notebooks.azure.com/kushaldas/libraries/dgplug [16:11] check the summer training notebook [16:12] This should have a words dict which contains the details [16:13] tell me if you can not see that [16:13] #hello everyone :) [16:14] kushal, sorry, I was not able to complete the task as I was travelling. but I was thinking about the logic [16:16] I am thinking to switch to linux distro other than ubuntu, any suggestions? I am confused between debian, fedora and out of curiousity RHEL. :) [16:21] ! [16:22] https://notebooks.azure.com/technotron/libraries/dgplug/html/summertraining.ipynb [16:22] kushal, ^^ [16:23] Phi_mb, there is a session going on, so ask later. [16:23] avik, Okay [16:23] next [16:23] kushal: oops sorry, [16:23] People please have a look at my summertraining notebook [16:24] Although it's absurd but if I know the value in a dictionary, can I access somehow the key? [16:24] anuGupta, you will have to loop though all the key/value combination to do that. [16:24] anuGupta, Please have a look at the code I wrote [16:25] ! [16:25] kushal, understood [16:25] I am pasting here for later reference [16:25] words = {} # Empty dictionary [16:25] for word in l: [16:25] if word in words: [16:25] count = words[word] [16:25] count += 1 [16:25] words[word] = count [16:25] else: [16:25] words[word] = 1 [16:25] [16:25] # print(words) [16:25] list_of_words = [(word[1],word[0]) for word in words.items()] [16:25] list_of_words.sort(reverse=True) [16:25] print(list_of_words[0], list_of_words[1]) [16:25] next [16:26] a very stupid question : how can I learn to think simple? the way you did [16:26] kushal, I didn't use `frequency_table.items()` so was getting that error [16:26] avik, Takes time, and you will have to read a lot of code, and then write some also [16:26] Aah I missed today's session. [16:26] ashwanig, otherwise you were only getting the key. [16:26] okay! a long road ahead! :D [16:26] ikshitij, It is still going on. [16:26] avik, Yes. [16:27] Ok kushal [16:27] ! [16:27] next [16:27] `list_of_words = [(word[1],word[0]) for word in words.items()]` - what is this line doing? [16:28] ashwanig, let us split that line. [16:28] words.items() [16:28] What does this function do? [16:28] ashwanig, ^^ [16:28] kushal, we get key,value pairs [16:28] Okay, good. [16:28] next [16:28] oops [16:29] for word in words.items --- what is this? [16:29] A for loop, where we will get a tuple everytime, containing key, value. [16:29] ashwanig, ^^ correct? [16:29] iterating each key,value pair at a time in the dictionary word [16:29] ashwanig, Correct [16:29] yes [16:29] So, I could add those tuples in a list by this [16:30] list_of_words = [] [16:30] ah, understood :) [16:30] for word in words.items(): [16:30] kushal - what is the else doing? [16:30] how to get list of friends in hexchat? [16:30] list_of_words.append(word[1], word[0]) [16:31] kushal, got it :) [16:31] ashwanig, now, I wrote that in a simple way using list comprehension [16:31] :) [16:31] jasonbraganza, What was your question? [16:32] still trying to grasp the dictionary creation part [16:32] i got the for part [16:32] i do not understand wgat the else is for? [16:32] i mean what the else condition does [16:32] jasonbraganza, when a new word occurs which is not in the dictionary [16:33] else: [16:33] words[word] = 1 [16:33] this one? [16:33] yes [16:33] oh wait! [16:33] If the key is not the words, means we are encountering the word for the first time [16:33] I got it backwards [16:33] the for condition is counting and appending the count [16:33] so setting the count as 1 for that word. [16:33] of occurenses [16:33] the else takes care of every new word like ashwanig says [16:34] jasonbraganza, Yes. [16:34] ok. now to figure out the next part. [16:35] nope. kushal help [16:35] what is this doing? list_of_words = [(word[1],word[0]) for word in words.items()] [16:35] jasonbraganza, ask [16:35] i got the other two lines [16:35] jasonbraganza, I'm not able to understand that too [16:35] jasonbraganza, I just explained that to ashwanig above. [16:35] ver sorry [16:35] will read [16:35] jasonbraganza, read the log please :) [16:36] Everyone, next start reading the strings chapter https://pymbook.readthedocs.io/en/latest/strings.html [16:37] the session is continuing [16:37] I am not closing it. [16:37] ask questions here. [16:39] kushal - I got it and kind of understood it. [16:39] but i definitely need practice [16:40] jasonbraganza, if you have any doubts we can discuss it [16:41] nope. just a matter of me having to break it down and build it up fluently [16:46] I have a doubt [16:47] jasonbraganza, you will have to do it 10 times in next 4 months [16:47] anuGupta, ask [16:47] kushal totally agree. [16:47] Can we sort a dictionary ? [16:47] anuGupta, we just did that [16:48] anuGupta, But, there are other ways [16:48] You created a tupple before that [16:48] anuGupta, I will leave that to you :) [16:48] anuGupta, To think about how sort works tec [16:48] etc [16:48] Ok kushal [16:48] :) [16:52] Impressive! it sorts the list using first value from the tuple [16:55] and uses next value if there is a tie [16:58] bhavin192, yes [17:03] Ending the session, please ask if you have any questions ----END CLASS----