[16:01:31] [## Class Started at Mon Jul 25 16:01:31 2016 ##] [16:01:31] #startclass [16:01:39] Roll Call [16:01:42] Vaibhav Jain [16:01:42] Avik Mukherjee [16:01:42] Akshay Shipurkar [16:01:43] Akhilesh Dhaundiyal [16:01:43] Harsh Vardhan [16:01:43] Rhitik Bhatt [16:01:44] Priyanka Sharma [16:01:45] Vivek Shelar [16:01:47] Moiz Sajid [16:01:48] Varsha R [16:01:48] Abhishek Shrivastava [16:01:49] Madhuri Muley [16:01:49] Pooja Yadav [16:01:49] Prashant Jamkhande [16:01:49] shobhit upadhyay [16:01:50] Rohan Hazra [16:01:51] Suniva Priyadarshini [16:01:52] Deepanshu Kapoor [16:01:53] sandeep kumar choudhary [16:01:59] mspreddy [16:02:01] Anupama Mandal [16:02:02] Yashwanth M [16:02:04] Mamoon Manzoor [16:02:04] Akshay cv [16:02:09] chandu [16:02:13] Jogender Kota [16:02:14] Saurav Saha [16:02:17] Sidhant Gupta [16:02:19] Pabitra Pati [16:02:56] ganesh kadam [16:03:06] Good evening, I am new to dgplug and have spent the last few days going through the logs. I am still unclear with Git and the basics of python. So should I attend the session today or spend time clearing up python basics and Git? Thanks. [16:03:16] sidhant, Welcome! [16:03:51] rahul bajaj [16:04:16] Aniket Khisti [16:04:38] So last class was on Python Data Structures. [16:04:39] Satyajit Bulage [16:05:12] I think most of you have queries, Feel free to type ! to ask your queries and wait for your turn to ask questions [16:05:35] ! [16:05:40] sairam [16:05:48] next [16:05:52] Mahesh [16:06:10] Did we have a class on Friday? [16:06:15] sidhant: I would suggest that you should spend time to clear python basic like variable, datatype, available data structure before jump to today session if you have basic knowledge of python then you can carry on. [16:06:20] previous Friday [16:06:26] moizsajid: yes we had. [16:06:43] chandrakumar: Thank you. [16:07:09] praveenkumar: Can you please upload the log for that class? [16:07:26] Roll Call : Amol Kahat [16:07:57] moizsajid: Alright will make it available. [16:08:08] next [16:08:10] Thanks [16:08:32] Any more queries from last class before moving to new topic. [16:09:20] ! [16:09:24] next [16:11:19] is there ay difference between print(dic[key]) and prit get(dic.get(key))? [16:11:29] *any [16:12:47] avik: yes, if you don't have key in the dictionary then first one give you a traceback KeyError and in second case if key not available then it will return None. [16:12:48] avik, if you do dict[key] and key is not present [16:13:01] oh praveenkumar answered it [16:13:08] Roll Call: Mriyam Tamuli [16:13:35] ooo got that. thank you guys :) [16:13:47] next [16:14:54] So i am going to start with new topic "Strings" [16:15:42] So first question what are strings? [16:16:03] sequence of characters placed together. [16:16:25] an array of characters [16:16:52] Immutable data type [16:17:06] rahul_bajaj, avik moizsajid yes [16:17:23] but in simple words it is simple text [16:17:40] set of characters [16:18:14] Everybody please open your terminal and start python3 interpreter [16:19:11] So in python a string can be declared using single quotes, double quotes or triple quotes [16:19:18] https://shellshare.net/r/summertraining [16:19:25] Everybody take a look here [16:22:41] rtnpr0_ is now known as rtnpr0 [16:22:51] Please try the above examples from https://shellshare.net/r/summertraining [16:23:00] and stop me if you have any queries [16:23:41] One interesting thing here when i have done 'hello world' and "hello world" [16:24:13] or """hello world"" it has printed 'hello world' [16:24:24] chandankumar: Why does it return everything in single quotes? [16:24:45] so, is triple double quote used for multilines ? [16:25:00] because python interpreter converts everything in single quotes by default [16:25:01] avik: Yes [16:25:07] avik, yes [16:25:17] and others not? [16:25:22] chandankumar: Does it use this representation for internal use? [16:26:05] so suppose user enter anything from keyboard using '', or "" or """ quotes python first convert it into '' quotes [16:26:09] for example [16:26:18] see shellshare [16:26:20] Understood. [16:27:01] I just saw even ''' works as """ [16:27:19] is it right? [16:27:26] to understand in a better way let us print "" quoted strings [16:27:42] avik, ''' are called as Docstrings, you will learn about them. very useful :) [16:28:06] avik, These are just like Java's javadoc. [16:28:09] :O [16:28:14] as in they are used to write Docstrings. [16:28:17] Thanks, btw [16:29:40] check the last example to understand difference [16:31:31] So this way use print double quotes with in a single quotes or vice versa. [16:32:12] let us i have to print it's [16:32:47] one way [16:33:18] another way of printing of it's [16:33:26] any queries till now? [16:33:32] no [16:33:37] nope [16:33:57] ok going ahead [16:35:10] "hello \n world" does not printed in two lines [16:35:20] to print the output let's use print [16:37:13] In the same way we can use \t for tabs [16:37:20] got that? [16:37:31] YEs [16:37:46] yes [16:37:51] jyes [16:37:52] s/YEs/yes [16:37:53] yes [16:38:13] so we can write multiple line statement using triple character [16:39:12] we can use \ to do multi line statement [16:40:09] chandankumar, please don;t clear the shell as someone can later refer to it [16:40:22] pabitra, ack! [16:41:38] so we can use \ to do continuation with in the code or in the string. [16:41:43] pabitra, they can not [16:42:21] i think we can scroll it up kushal [16:42:44] any queries till now? [16:42:46] pabitra, only when the session is on, it can get destroyed anytime. [16:42:51] no [16:43:03] oh okay [16:43:05] no question [16:43:53] ok moving ahead with string concatenation [16:44:20] concatenation can be done only when we have two string literals [16:44:46] we can + to do concatenation [16:44:47] literals? [16:45:24] ! [16:45:53] next [16:45:59] what are string literals? [16:46:58] avik, literals are nothing but data types like int , float [16:47:17] ooo, got that [16:47:20] list, tuples or dict [16:47:30] now check shellshare [16:48:14] we can also use whitespace to do concatenation in python3 [16:49:23] now try "hello" 2 [16:49:39] in python3 interpreter and tell me the output [16:49:53] invalid syntax [16:50:15] Can't convert 'int' object to str implicitly [16:50:24] >>> "hello" "2" [16:50:24] 'hello2' [16:50:35] so concatenation will only work with same literals [16:50:52] * string literals [16:51:10] otherwise it will give error [16:51:20] any queries till now? [16:51:59] No Queries...:) [16:52:06] so to concate "hello" str(2) [16:53:10] we can find the type of literal using type() function [16:53:42] moving ahead [16:54:17] let's learn some methods associated with strings [16:55:21] first is title() to convert it into titledcased version of the string [16:55:50] some other methods [16:56:04] upper() to make the string in upper case [16:56:36] to make it in lower case we can use lower() method [16:57:58] we can use swapcase() to return with case swapped [16:59:21] we can check truth value checking over string [16:59:49] like isupper() to check whether string is uppercases or islower() to check for lower cased [17:01:34] we can check whether all strings is of only numbers using isalnum() [17:02:19] sorry [17:02:40] ! [17:02:41] is it alpha numeric ? [17:02:50] we can use isalnum() for checking alpha numeric characters [17:03:29] digits + special characters + alphabets are alpha numerics [17:04:30] we can check all characters are numbers using isdigit() [17:05:14] can you check "hello 123" is alpha numeric or not? [17:06:09] false [17:06:09] No [17:06:14] why? [17:06:20] space [17:06:21] space ? [17:06:25] false because of the whitespace [17:06:35] Space is not alpha numeric character. [17:06:46] LambaInsaan, yes correct [17:07:46] so from here we can tell anyone that a user can entered strings in caps or small or in alpha numeric [17:07:57] which is generally used in password system [17:08:17] through this [17:08:22] any queries till now? [17:08:56] No queries...:) [17:09:09] there are two more methods [17:09:18] startswith() and endswith() [17:09:23] check shellshare [17:11:19] please stop me here if you have any queries till now [17:11:26] so that i can move in next part [17:11:46] ! [17:11:50] next [17:12:16] solved [17:12:17] how do these methods work ? Do they check for one string literal ? [17:12:24] s/check/match [17:12:43] abstatic, yes [17:13:01] chandankumar, okay. [17:13:12] you can check with int literals and you can understand the difference [17:13:22] next [17:13:26] next [17:13:32] now moving ahead [17:13:48] we can split or join operations on a string [17:14:02] using split() method [17:14:31] split() takes a string as a argument [17:14:37] check shellshare [17:15:48] if we donot give any agrument it will takes space by default [17:16:59] split() always returns a list [17:17:59] let us join to the string [17:18:12] join() method takes lists a input [17:19:23] "".join(list) [17:19:49] one more example [17:22:28] so split and join methods clear? [17:22:47] yes [17:22:49] yes [17:22:57] yup :) [17:23:04] yes [17:23:19] next topic is strip [17:23:50] strip() method also takes argument as a chars [17:24:29] if we donot pass anything in strip() it strips whitespaces and new line characters [17:25:00] check shellshare [17:26:48] if you want to do striping from left side use lstrip() and from right striping using rstrip() [17:27:47] when we do a.lstrip('wd') [17:28:06] it first bring wd in to 'w' , 'd' and 'wd' [17:28:33] if it first find 'w' in the string sequence it will strip w and stop [17:29:20] lstrip('dw') [17:29:33] it will first check whether it starts with d or w or dw [17:29:46] if d not, then go for w if w find stops [17:30:01] in the same rstrip() works [17:30:52] any queries till now? [17:31:00] one we have two more topics left [17:31:54] * chandankumar waits for the response. [17:31:58] ! [17:32:01] next [17:32:08] how to trim strings ?? [17:32:08] Nope [17:32:52] no queries [17:32:58] ! [17:33:00] abstatic, using lstrip or rstrip we can trim strings [17:33:30] chaitanya, okay. [17:33:40] chandankumar, okay. [17:33:50] abstatic, we can do more triming or slicing over strings in upcoming topic [17:33:55] just like list [17:34:00] next [17:34:08] while stripping from right or left when an argument is passed, is it not mandatory to maintain the order of the arg passed to strip, o anything from it ? [17:34:19] ok. I was hoping we'd have something like trim from python. [17:34:42] abstatic: yes, we have slicing [17:34:44] s/from python/from php [17:35:54] srvsaha, nope, the order doesnt matter if you have only a single character say 'w' or 'd' from 'wd' but if you have a complete 'wd' the sequence would matter. [17:36:28] ok thanks rahul_bajaj [17:36:35] rahul_bajaj, Thanks :-) [17:36:38] ! [17:36:42] next [17:36:44] how did this last example with rstrip work ? [17:36:48] abstatic, have patience [17:36:54] 'rgo' does not match ? [17:37:10] you will get to know about slicing in upcoming sessions :) [17:37:36] abstatic, so the set generated here might be in any order [17:37:45] 'org' might comes earlier [17:37:57] abstatic, the characters need to be in sequence [17:38:11] srvsaha, ^^ rahul_bajaj [17:38:31] I think rstip reads string in right to left way, is it so? [17:38:38] I did not understand [17:38:59] where does this set thing fit in here ? I though it just compares the string given in the arg and then removes ? [17:39:17] s/though/thought [17:39:22] rstrip works from right to left [17:39:43] ok, thanks chandankumar [17:40:21] abstatic, http://python-reference.readthedocs.io/en/latest/docs/str/rstrip.html [17:40:38] avik, abstatic http://pastebin.centos.org/49536/ [17:41:06] abstatic, ^^ [17:41:17] chandankumar, surajd thanks [17:41:23] I got it :) [17:41:27] moving to next topic [17:41:38] we can find a string or character with in a string [17:41:52] check shellshare [17:42:50] find() method will give index [17:43:05] if a searched string is not found it will return -1 [17:43:24] index starting from 0. [17:43:32] rahul_bajaj, yes [17:43:52] as earlier said strings are immutable their index value is not changed [17:44:33] we can find the length of string using len("string") function [17:44:54] now moving to last topic [17:44:58] string slicing [17:45:11] before moving ahead any queries [17:45:11] ? [17:45:21] no [17:45:23] nope. [17:45:26] no [17:45:26] nope [17:45:36] nope :) [17:45:47] just like list we can do slicing [17:46:04] difference between string and list is immutability nature [17:46:13] i mean their index value is not changed [17:46:17] check shell share [17:49:02] ! [17:49:27] next [17:49:33] chandankumar, a[1:5] would mean starting from index 1 and till index 4. i think. [17:49:43] rahul_bajaj, yes [17:49:48] rahul_bajaj, typed wrongly [17:49:53] :D [17:49:56] it basically acts as a range [17:50:40] ! [17:50:43] a[1:6:2] [17:51:10] it will print from from index 1 to till 5 by taking two steps [17:51:12] next [17:51:15] after this can you please give another example of rstip! [17:51:28] avik, sure [17:51:38] : [17:51:40] :) [17:51:46] got that string slicing? [17:51:55] any queries [17:51:57] ? [17:52:25] no [17:52:28] we can reverse the string using a[::-1] [17:52:50] we can also run for loop on string [17:53:21] Before ending the class [17:53:28] please follow these two links [17:53:33] http://pymbook.readthedocs.io/en/latest/strings.html [17:53:40] https://docs.python.org/3.1/tutorial/introduction.html#strings [17:53:54] we can take questions tomorrow [17:54:02] Roll Call [17:54:07] Rahul bajaj [17:54:07] Akhilesh Dhaundiyal [17:54:08] Aniket Khisti [17:54:14] Saurav Saha [17:54:15] Suniva Priyadarshini [17:54:23] Madhuri Muley [17:54:24] Varsha R [17:54:28] Abhishek Shrivastava [17:54:32] Rhitik Bhatt [17:54:32] Priyanka Sharma [17:54:37] Vivek Shelar [17:54:38] Moiz Sajid [17:54:40] Avik Mukherjee [17:54:41] Mamoon Manzoor [17:54:51] Anupama Mandal [17:54:56] Jogender Kota [17:54:58] shobhit upadhyay [17:55:15] mahesh [17:55:26] Pooja Yadav [17:55:32] #endclass [17:55:32] [## Class Ended at Mon Jul 25 17:55:32 2016 ##]