----BEGIN CLASS---- [13:32] #startclass [13:32] yeah we were waiting. [13:32] Roll Call [13:32] tabrez khan [13:32] Naman Sharma [13:32] Kumar Vipin Yadav [13:32] <__rex__> Rakshit Airani [13:32] Shruti Dash [13:32] sarthak agrawal [13:32] Jagannathan Tiruvallur Eachambadi [13:32] Anu Kumari Gupta [13:32] Prajit Mukherjee [13:32] Prabhu Sharan Singh [13:32] Shaikh_farhan [13:33] Shital Mule [13:34] pooja kumari singh [13:34] Less number of people, means good. [13:35] Okay, questions on the data structure chapter of PYM book? [13:35] Roll call: Shubham Sharma [13:35] ! [13:36] next [13:36] what is happening beneath the List? [13:37] can we saw where it is storing? [13:37] Bhavesh Gupta [13:37] ! [13:38] prokbird, Yes, wait [13:38] kushal, okay. [13:39] Gajendra Saraswat [13:39] prokbird, https://github.com/python/cpython/blob/master/Objects/listobject.c [13:39] next [13:39] kushal, I want to know how add function add items, i mean in sorted form or in last ? [13:40] in sets . [13:41] sets will be random. [13:41] the values inside. [13:41] kushal, ok thank you [13:41] prokbird, yes, the core objects, parsers and many libraries are written in C. [13:42] interesting. [13:42] Any other question [13:42] ? [13:42] yes [13:42] ! [13:43] next [13:43] consider i am putting a value inside a variable (a = 5), how to know its memory location? [13:44] prokbird, You don't. [13:45] You don't need. [13:45] why? [13:45] prokbird, what are you going to do with the memory location? [13:46] Python is a dynamic language and the interpreter will take care of these things for you. [13:46] prokbird, Python is not C or C++. [13:46] nothing,just asking for curiosity [13:46] yeah, i know. [13:48] Most of the code I ever wrote in Python, I only need these few data structures [13:48] if i am delaying the session you can move on. [13:49] ! [13:49] The following question, only the new programmers answers please, seniors in programming, do not answer. [13:49] Say, you have 500 names or 5000 names. and I want you to tell me if name "asdfas" exists in those or not. How will you store the names in your code? [13:50] prokbird, A language become more secure if it do not provide pointers, any High level after c++ do not support pointer or anything like that :) [13:50] All the new programmers, please answer what ever you think. [13:50] string [] [13:50] no need to tell anyone if they are right or wrong. [13:50] kushal, I use list [13:51] Let us hear what people think. [13:51] kushal find('string') in file(with names) [13:51] kushal:string [] or list. [13:51] Sarques, there is no file, say you already read the file, [13:52] Shaikh_farhan, what is string [] ? [13:52] using a list [13:52] People, please answer. [13:52] kushal: Will use a list for storing the names [13:52] a list [13:52] list as stack. [13:52] If you don't answer, no meaning of attending the session. [13:52] let us wait for everyone. [13:52] <__rex__> array of strings [13:52] I will check for " asdfas " pattern in the string and return it if found. [13:52] Say, you have 500 names or 5000 names. and I want you to tell me if name "asdfas" exists in those or not. How will you store the names in your code? [13:52] kushal:we can store names in it [13:52] kushal then string in list, if true, it exists, else not [13:53] <__rex__> in python maybe lists [13:53] kushal, 'asdfas' in names, where name is a list of names [13:53] Everyone attending the session, please answer. [13:53] alphabetically storing names in a list [13:53] <__rex__> I guess there is a search method for lists in python [13:54] does not matter if you are a new or old in programming [13:54] I will store them in list and use .contains over it [13:54] if 'asdfas' in name_list [13:54] name_list will be of list data type [13:54] using list we can add [13:54] will search the list for asdfas and store those in another list [13:55] list for the names since they aren't unique [13:55] set if they are [13:55] will store the names in a list and search 'asdfas' [13:56] if 'xyz' in name_list: [13:57] anyone else? [13:58] I will wait for 2 minutes [13:59] dictionary [13:59] by using append on the list [14:00] Will use list if names are not unique [14:01] oh yes, we can do -> 'asdfas' in names and if true name_found.append(name) [14:02] we will use append in the list [14:02] Okay, now let us check the answers. [14:02] The popular answer is using list. [14:02] One person said about using Dictionary. [14:02] 1. Using list. [14:03] We can check if a value is there in a list using in. [14:03] "asdfas" in names [14:03] Where names is a list of all the names. [14:03] 2. using dictionary [14:04] say d = {"name": True} and we have added all the names as keys. [14:04] then we can use in again. [14:04] "asdfas" in d [14:05] But, what will be the difference in both cases? [14:05] ! [14:05] ! [14:06] next [14:06] next [14:06] next [14:07] what if we consider this :-> names = "Some random names with asdfas between them" & then, find(asdfas, beg=0, end=len(names)) [14:07] kushal, what will be the values of 500 names if we use name as keys ? [14:07] kvy, think each name as a key [14:07] I just wrote it as example [14:07] in dictionary , for key is name , value is added that is something extra apart form list. [14:07] kushal, ok [14:07] prokbird, dictionary and lists are not same. [14:08] yes true. [14:08] ! [14:08] for lists, it will have to start traversing the list from the index 0 till the end. [14:08] and then it will find if the "asdfas" is there or not. [14:09] but, in case dictionary, it will use the underlying the hashing mechanism, and will find if the key exists or not in one operation. [14:09] so where it may have to 4999 times in list, but in dictionary, it will only search once. [14:09] ! [14:09] Means it will be faster any day. [14:09] next [14:10] I would go with generating IDs for keys with name as the value but list would work in that case [14:10] ! [14:10] 😢I got left. [14:10] kushal, hmm got it [14:10] cypher01, no, that will also take a lot of time. [14:10] Can you explain this hashing mechanism part please? I felt like both will be 0(n) [14:11] souvikhaldar, please only ask when batul says so. [14:11] next [14:11] souvikhaldar, this is your time to ask the question. [14:12] Can you explain this hashing mechanism part please? I felt like both will be 0(n) [14:12] souvikhaldar, in dictionary, it is always O(1). [14:12] souvikhaldar, No, I can not, as I never read what is the implementation. [14:12] I just use it. [14:12] souvikhaldar, feel free to read the Python source code for the same. [14:12] next [14:12] How does dictionary search in just 1 operation? Doesn't it use the same searching mechanism as list? [14:13] ! [14:13] prabhuss, No, that is why this is a different data structure. It stores and accesses the data in different way. [14:13] next [14:14] would there be any case where list would give better result then dict? [14:14] ! [14:15] BhaveshSGupta[m], not that I know. [14:15] next [14:15] Does Dictionary uses binary seacrh algorithm [14:15] Shaikh_farhan, no. [14:15] prabhuss, dictionary use hashing technique but list use linear searching. [14:15] kvy, thanks [14:15] Shaikh_farhan, ^^^^ [14:16] ! [14:16] kushal:thanks [14:16] next [14:18] Sorry if I missed above messages, but I wanted to ask that does the 'exists' keyword iterate over all the keys one by one in the dictionary? [14:18] souvikhaldar, keyword? [14:18] dictionary has methods. [14:19] Also i don't remember any such method. [14:20] May be it was something in Python2 long time back, but, as you can see, I totally forgot. [14:20] I just use `in` [14:20] next [14:22] next chapter is strings, this is what I use highest number of time daily. [14:22] https://pymbook.readthedocs.io/en/latest/strings.html [14:22] Please have a read over the weekend. [14:22] This will be very very important. [14:22] If no other questions, we can end the session. [14:23] kushal, ok [14:23] kushal, something off topic. ----END CLASS----