----BEGIN CLASS---- [13:33] #startclass [13:33] Roll Call [13:33] Mayank gupta [13:34] now i can charge my laptop, supply came:) [13:34] pooja kumari singh [13:34] kumar vipin yadav [13:34] Abhinav Shirur [13:34] Saikat Dey [13:34] Shivam Singhal [13:34] Priyanka Sharma [13:34] Suraj Ghimire [13:34] Abhishek Singh [13:34] Jason Braganza [13:34] Balaji [13:34] Bhavin Gandhi [13:34] Sandesh patel [13:34] Ashwani Kumar Gupta [13:34] Atul kumar [13:34] Krishnanand Rai [13:34] Aryan tripathi [13:34] Deepika Upadhyay [13:34] yurii pylypchuk [13:35] Priyansh Sourav [13:35] Mahendra Yadav [13:35] Navanil Roy [13:35] pr97: yay! [13:36] :) [13:36] Harsh Vardhan [13:36] wow, the people have gone down [13:36] good for us :) [13:36] Questions please! [13:36] Roll Call Ravindra Lakal [13:36] neha kandpal [13:37] roll call:Himanshu Awasthi [13:37] Mayur khomane [13:37] Kshitij [13:37] Jitesh Pabla [13:37] Mriyam Tamuli [13:39] Anyone has questions so far? from the hometask? [13:39] ! [13:40] Roll Call- Mohsin Mumtaz [13:40] Roll call:Vamsi Krishna. [13:40] next [13:40] Roll Call: Onyinye Madubuko [13:40] why python community change "print" syntax to a function [13:41] Roll Call: Samridhi Agarwal [13:42] championshuttler: https://www.python.org/dev/peps/pep-3105/ [13:42] samridhia, Please stay online after class, I have a few things to say. [13:42] samridhia, Nice blog posts :) [13:42] thanks, kushal [13:42] no more questions? [13:42] This is good : [13:42] :) [13:43] ! [13:43] next [13:43] There is a line in the book "In Python we don’t specify what kind of data we are going to put in a variable.". But then, while reading input from keyboard for a variable, we are using float, int, etc. Please explain this. [13:44] [13:44] skat-sd, a = 213 [13:45] a = 32.4 [13:45] a = "I am not saying that I am dog on Internet" [13:45] skat-sd, ^^^ not defining the data type. [13:46] ! [13:46] I thought python will auto-detect data type while scanning user input just like we are not mentioning data type while declaring a variable. [13:47] skat-sd, when you have to explicitly typecast the input to your desired form like this like this int(input()). This is typecasting to make it into integer and do regular integer operation on it [13:48] s/when/then [13:48] next [13:48] im_mohsin, okay, so we are only going the required specific way by that. Thanks [13:49] ! [13:49] doubt cleared :) [13:49] next [13:49] why python always takes input in string, as it identifies the data type automatically? [13:50] asraisingh: input always returns string [13:51] I am sure there is somewhere in PEP written on why or maybe in doc [13:51] ok [13:51] but I have not thought on it why [13:52] Ok, people can you start reading: http://pymbook.readthedocs.io/en/latest/ifelse.html [13:52] Once you read I will explain again, but read first [13:54] Roll call: Anu kumari Gupta [13:57] done :) [13:57] tell when done [13:57] done [13:57] done [13:57] done [13:57] done [13:58] done [13:58] done [13:58] done [13:58] done [13:58] done [13:58] done [13:58] done [13:58] done [13:59] Done [13:59] done [13:59] done [13:59] done [13:59] done [14:00] Cool [14:00] done [14:00] done [14:01] done [14:03] once you start programming, you would come to a point when you need your program to decide a detour based on condition [14:04] for example you are operating a mobile store [14:04] and you are told to sell mobiles only to people with the age greater than 18 [14:05] so you would put a condition in your program that [14:05] if the age of the person is greater than 18 [14:05] then go ahead sell the mobile [14:05] or else you soo off the kid :) [14:05] this is also called control flow [14:06] because at the end of the day you are managing the control of your program [14:06] the syntax is [14:06] if condition: [14:06] do stuff if the condition is true [14:06] else: [14:06] do stuff is the condition is false [14:07] note the else part is optional [14:07] that means if the age of the person is greater that 18; then you sell the mobile [14:08] and if you don't put the else condition in there, your program will just ignore and passon [14:08] - Few things to remember [14:08] - each if and else line ends with colon [14:08] followed by idented lines [14:09] can somebody explain what is indentation? [14:09] pushing stuff ahead of the margin, by spaces or tabs [14:09] we use tab spacing to make code more readable. [14:09] The space we leave on the left side of the page in text and code [14:10] empty space at the beginning of a line to start something new in it [14:10] It is very important in python. To declare the scope of a set of statements in a loop or conditional check we use indentation [14:11] Suppose we need to put a set of statements under any type of loop or conditional check, we give spaces and maintain the equal amount of spaces throughout within that [14:12] the prorper allignment of code is called indentation. [14:12] it shows that the indented lines belong to the above unindented statement [14:13] A space left between the left-hand margin of a line of type or handwriting and the beginning of a sentence or quotation [14:13] Indentation in python is basically discriminating a block of code, by maintaining a certain space from the margin. [14:14] right, idendation in python is more than just shifting the code [14:14] it is a way to define the scope of the code [14:16] >>> if x < 0: [14:16] ... x = 0 [14:16] sayan: Error: ".." is not a valid command. [14:16] ... print('Negative changed to zero') [14:16] sayan: Error: ".." is not a valid command. [14:17] so if you see here, the idented code is the then block [14:17] there are only 2 lines in the then block [14:17] and if the condition is tru [14:17] s/tru/true/ [14:17] those 2 lines would be executed [14:17] any questions? [14:18] seems like no [14:19] ! [14:19] next [14:19] What was the truth value testing at the bottom of the page? [14:20] ! [14:21] skat-sd: i was planning to come to it later [14:21] sayan, okay. [14:24] in Python even if you don't give a condition [14:24] like x==0, or x<=10 [14:24] at the end of the day python checks if the condition is true or false [14:25] there for even if you give just if True [14:25] or if False, that would just work [14:26] so write a program to take input from user two numbers, number_1 & number_2 [14:26] and preferred operation ( +, -, /, *) [14:26] after the inputs print the result [14:27] Do this task on the azure notebook [14:27] sayan, Nice problem :) [14:29] done [14:29] done [14:29] samridhia, link please? [14:29] https://notebooks.azure.com/n/IEV4pGuJLXE/notebooks/practice.ipynb [14:30] update the links here: https://etherpad.gnome.org/p/dgplug-2018 [14:31] sayan, let them paste here, links may change between start/stop iirc [14:31] samridhia, https://notebooks.azure.com/anon-9o7bwq/libraries/dgplug2/html/practice.ipynb [14:31] wrong [14:31] kushal: they can paste multiple times in the etherpad [14:32] this is because links might now work and people who are referencing might panic [14:32] kushal, ok i have to see [14:32] like I deleted venus :) [14:34] samridhia, sayan said to take input about the operation too [14:34] oh got it kushal [14:35] https://notebooks.azure.com/run/jasonbraganza/dgplug?dest=/notebooks/summertraining.ipynb [14:36] https://repl.it/JmyS/0 [14:36] oh sorry [14:37] done [14:37] jasonbraganza, we need the HTML view :) [14:38] https://notebooks.azure.com/n/gYEEwo4DvbM/notebooks/summertraining.ipynb [14:38] will this do? - https://notebooks.azure.com/n/UoS88puoAwg/nbconvert/html/summertraining.ipynb?download=false [14:39] no i think [14:41] https://notebooks.azure.com/abhinavshirur/libraries/dgplug/html/summertraining.ipynb [14:41] done [14:41] https://notebooks.azure.com/n/lIcDepG7Rmg/notebooks/calculator.ipynb [14:41] jasonbraganza: this: https://notebooks.azure.com/jasonbraganza/libraries/dgplug/html/summertraining.ipynb [14:41] https://notebooks.azure.com/anon-qjhtmg/libraries/dgplug [14:42] sayan - thank you. was madly googling :) [14:42] https://notebooks.azure.com/anon-jm5vqa/libraries/dgplug [14:42] https://notebooks.azure.com/n/QBFrmUluK0A/notebooks/summertraining.ipynb [14:42] People don't read :( I told to update the etherpad link [14:43] only jasonbraganza did [14:43] sorry to interrupt, but I want to share something. I got placed in Eaton Technologies, Pune :) [14:43] done [14:43] jasonbraganza: you had to take the input of the operation too [14:44] sayan - will do [14:44] sayan, sorry [14:44] sayan, i did the code but my code is still in running state since 5 minutes. no idea why? [14:44] https://notebooks.azure.com/n/u6rqtXNxUrw/notebooks/summertraining.ipynb [14:44] samridhia, wrote something wrong, you can restart the kernel [14:45] sayan - aah and that’s where flow control come into play [14:45] ok kushal, trying [14:45] kushal: ? [14:45] sayan, https://notebooks.azure.com/n/Wk6T6AksC1c/notebooks/IOprogram.ipynb [14:45] https://notebooks.azure.com/n/Z2iNApRes9s/notebooks/summertraining.ipynb [14:46] kushal: no samridhia goes to restart the kernel [14:46] balaji: pr97 what will I do with this link? [14:46] Not sure why people can not read the problem sayan gave [14:46] ohh sorry sayan [14:46] He asked to take input of the operator [14:46] it's showing dead kernel! [14:47] samridhia, yes, you can start it again [14:47] ok kushal [14:47] kushal, I did like that only [14:48] https://notebooks.azure.com/n/JTqGecxlkZA/notebooks/calculator_ifelse.ipynb [14:48] sorry for pasting here! [14:49] Also, everyone please try to use the same notebook for everything in the class [14:52] https://notebooks.azure.com/n/KyxAjAp8hRQ/notebooks/summertraining.ipynb [14:52] sayan - done [14:53] https://notebooks.azure.com/anon-jm5vqa/libraries/dgplug [14:53] jasonbraganza: bad choice of variables [14:53] asraisingh: also has bad choice of variables [14:53] sayan - you want me to be descriptive in some way? [14:53] jasonbraganza: yes, that's why I wrote number_1 & number_2 [14:53] I’m sorry. fixing [14:54] sayan, oh sorry for that fixing it [14:54] jiteshpabla: no access [14:54] abhinavshirur: that's good you are using the same notebook I guess [14:54] sayan: ok, i'll check [14:54] but variable names :( [14:55] sayan - fixed [14:55] san-D: cool, you followed the variable names except 'op' [14:55] jasonbraganza: cool [14:55] sayan, sorry, fixing that [14:56] sayan, done [14:57] sayan, done :) [14:58] mdbk: nope, the solution is wrong [14:58] sayan done [14:58] Sayan - okay [14:59] avik: avoid duplication [14:59] We have to add two numbers? [15:00] sayan: link fixed! [15:00] vharsh: nope, calculator [15:00] sayan, okay, The user will input +, -, *, or / [15:00] vharsh: yes [15:00] people any questions? [15:01] sayan, duplication like? [15:01] number1 and number2 ? [15:01] ! [15:01] avik: can you paste your link here? [15:01] next [15:01] what is pass in python? [15:01] sayan, https://notebooks.azure.com/technotron/libraries/dgplug/html/calculator_ifelse.ipynb [15:02] okay people look in avik solution and tell what can be improved? [15:02] No one read the question statement sayan told. [15:03] instead of taking a variable named result he could have directly printed the result [15:03] championshuttler: pass is just a placeholder, does nothing [15:03] And the code can be shorter. Saving time :) [15:04] his variables have to be in curly braces? [15:04] RIcharD_: shorter code != saving time [15:04] in the print statements? [15:04] sayan, okay. [15:04] he repeated the line print [15:05] which is not ideal [15:05] Guest92539, yes, i could have done that! I was initially planning to print the result once , after all if/else conditions!, then realised a problem in that! [15:05] avik: what? [15:05] input command produces string and avik directly processed the string not typecasting into int or float which is more preffered. [15:05] sayan, the else at the end might cause a problem [15:06] asraisingh - he made floarts [15:06] avik: there is a way to fix that [15:06] avik: if condition on result [15:07] like if I gave say 4 as an operator, it would first print the error! then woulgd go on to print an result, which had not been calculated! thus giving a garbage value! [15:07] sayan, yes! [15:07] I thought of that! [15:07] *I did not thought of that [15:07] jasonbraganza, sorry [15:07] :) [15:07] next [15:07] sayan, I couldn't login into my Windows Live account. So I posted a gist. [15:08] sayan, thanks :D [15:08] vharsh: ok [15:08] Going ahead, I am not continuing with loops which I thought [15:09] because people cannot read [15:09] So, I would like to talk on that [15:09] I specifically told to write number_1, number_2 and operator [15:09] people did not read that :( [15:09] So, here are few things I would like to tell on naming variables [15:11] jasonbraganza, give something else as operator and then check the answer [15:11] bhavin192 - i know. will fix later. listening right now [15:11] jasonbraganza, oops sorry, it is a black else [15:12] so, there are two ways of naming followed in Python [15:12] - this_is_a_variable_name [15:12] see how the variable name is self explainable [15:13] and it is seperated by underscore [15:13] all the letters are small [15:13] most of the Python folks follow this convention [15:13] but few places you would see this [15:13] - thisIsAVariable [15:14] This is called camelCase, not much followed (only in the test cases I have seen) [15:14] seen in testcases because of the practices come from Java [15:14] ^^ afaik [15:14] so, DONT use variables name like a, b, c, d, i, j [15:15] I really don't know what they mean [15:15] ! [15:15] nor the project maintainers, the maintainers have huge load of work so having these variable names just annoys them [15:16] variables name should be self-explanatory [15:16] like number_1 instead of n1, num1, num2, or even number1 [15:16] this last one because it's not seperated by underscore [15:17] you can also write number_one [15:17] Always, remember while writing code, the person who would be reading and maintaining your code 10 years later has your home address [15:18] You really don't want to annoy that person [15:18] next [15:18] isn't 'i' used for iterations? [15:18] avik: nope [15:18] so what should we use? [15:19] for school in schools? [15:19] "x" in range? [15:19] ok! [15:19] got that! thanks. [15:20] Like in IRC, some of the shortforms are allowed like brb, bbiab [15:20] similarly there are few variable names that you can use [15:20] like I use elem a lot, but I am moving to using element [15:21] for elem in range(): for element in range() [15:21] ! [15:21] next [15:21] Why do we use capital letters for a constant? [15:22] I really don't know the reason, but it is defined in PEP8 [15:22] okay [15:22] Next, thing is read, even though this is a small question, you read the specifications wrong [15:23] suppose a airline company had been using your code, surely 2-3 planes would have come down [15:23] specifications are important because other people depend on them [15:24] Another thing is people/project have style guides, you need to read before contributing or working to their project [15:24] if you are working on someone else project, you follow their code style guide [15:24] any questions? [15:25] no. this was clear [15:25] I would recommend people to read PEP 8 every 6 months [15:25] https://www.python.org/dev/peps/pep-0008/ [15:26] sayan, it is also in the book :) [15:26] kushal: hope people read that [15:26] also read this blog: http://treyhunner.com/2017/07/craft-your-python-like-poetry/ [15:27] this talk: https://www.youtube.com/watch?v=0PkRhfRkj1s [15:27] and this talk: https://www.youtube.com/watch?v=knMg6G9_XCg [15:29] Roll Call [15:29] Jason Braganza [15:29] Onyinye Madubuko [15:29] Priyanka Sharma [15:29] yurii pylypchuk [15:29] Ashwani Kumar Gupta [15:29] Samridhi Agarwal [15:29] Mayank gupta [15:29] Avik Mukherjee [15:29] Krishnanand Rai [15:29] Harsh Vardhan [15:29] Sandesh Pael [15:29] Deepika Upadhyay [15:30] Jitesh Pabla [15:30] Saikat Dey [15:30] Abhinav Shirur [15:30] Bhavin Gandhi [15:30] Himanshu Awasthi ----END CLASS----