Today, I’m going to give you a 30-minute summary lecture I’m going to use Jupyter Notebook in ‘goorm IDE’ First of all, go to the web page and log in Click the ‘대시보드(dashboard)’. Then click ‘새 컨테이너 생성(new container)’ I’m going to use Private Name ‘python_summary’. This is python summary video Select Jupyter Notebook and click ‘생성하기(create)’ button Click the ‘실행(create)’ button This is how to use Jupyter Notebook with goorm IDE Also you can install Anaconda on your computer and run Jupyter Notebook It is okay to do that Click here to ‘실행(run)’ Then Jupyter Notebook will run Then click this url It will enter directly to the Jupyter Notebook Then click New button and Python 3 This is Jupyter Notebook working space look like I’m going to increase it a littel bit The title is 001. Click rename button Some of you may have used Jupyter Notebook for the first time, so I’ll show you briefly how to use it x is 3, y is 7. x+y and press Ctrl + enter. Then it runs Change y as 10 and press Ctrl + enter again. Then it runs again This is second time to run, so the number is changed If you press Alt + enter, then the number is changed as 3 And there will be one more cell underneath. Then you can re-code below Here you don’t have to use print However, we will type print here It is because when you print multiple copies, you have to type print Let’s start with the Markdown. # hello world and 3 single quotes hello world Commets are used to describe your code, but also used to hold your code temporarily For example, if you give # to the ‘print’ like this, the print will not work When you press Ctrl + enter, there will be no output Erase # and Ctrl + enter, then it works again It would be good for you to know that you can use this code in a pending form Alt + enter As we did above x and y are variable that can vary We put 3 in x and 10 in y, then x + y comes out 13 y was 7 for the first time though We changed y once It’s called a variable that can vary Here we’ll see the type of variables a b c d e f g h i j a is 10, b is 10.1, c is ‘hello world’, d is -1, e is ‘lee’. f is ‘hojun’ g is 10+2j, h is 0b1001, i = 0o1001, j = 0x1001 0 is zero, b is alphabet This o is also alphabet Other is all numbers Let’s try print(a+b) What will caome out? It comes 20.1 This is an integer And this is a real number Since this is a real number, you have to print it as a real number type so there is no loss So the form of output is a real number print(a+b) comes out 20.1 Now, I will put single quote to ‘a’ like this After that when I press Ctrl+enter, I got an error When I type a+a and run it, I got 1010 And if I do b+b and run it, now I got 20.2 Why is that? It is because of type The single quotation mark represents String Write down here str A number without single quotation mark is int type And a number with a decimal point like this is called float type The data type is the world of code that brings about the ideological things that we generally think of in society Therefore, integer + integer is of course integer, and the real number + real number is real number For example, ‘lee’ + ‘hojun’ comes out ‘leehojun’ print(e+f) gives me ‘leehojun’ However, when you think that is this a natural phenomenon in the world of code? I don’t think so You can change all of these, ‘lee’ + ‘hojun’, to binary and then add them together but, why is it like this? It is because the real world use like this That’s why the world of code is reflecting the real world in which we live Thus, this language is called an object-oriented language What’s the type of -1? I will organize the types next to them integer float string is it integer? float? or string? This is integer. This one is string, and string what’s the type of this? This one is complex But I’m not going to do this This one is binary integer This is octal integer This is hexadecimal integer I push back little by little

Now, how do I check the type? print(type(a)) Ctrl+enter It showed me class ‘int’ We will learn class later You can see that the data type of a is int This code has a mate code, print(dir) Then you can see that there are various methods that you can have in this int type But I’ll go ahead and do this later Make it as comment Alt + enter Let’s take a look closer the String data type First of all, the text enclosed in single quotation makrs is called String data type paullab CEO LeeHoJun I will put it in s print(type(s)) print(dir(s)) and Ctrl + enter You can see that it is a string Here are several letters that we do not know We will learn this later I’ll make it as comment since it’s complicated Let’s check one by one Print out the 0th in s Then you have p The 0th in s is p. It always starts from 0 from 0 1 2 3 4 5 6 2 3 4 5 6. Printing out from 0th to 6th is [0:7] Then it cut before the 7th It came out only up to paullab We call the inside number an index And this calling is called indexing Now, let’s try some more Print out from 0th to 15th in s with skipping 2 spaces Ctrl+enter then the output is pulbCOLe It skipped two spaces You can put the value of -1 this time Then you have to look from the big to the small Ctrl + enter. Then you got OEC ballua It came up to before a Ctrl c and v. Now, I’m going to skip the front one And I will do like this Then you got pulbC. It is It is the same with this one This means from the beginning And I will skip the last one like this. Ctrl + enter This means frome the beginning to the end Ctrl c and v. And If you give -1, It prints by -1 indexing, which means it prints in reverse order Why is this possible? If you print(s[-1]), then it gives you n where is the n? here You can give it a – value It is an index. So whenever you want to know the last value, Use -1. It is good to know Copy the very first one. Alt + enter Print(type(s)) and print(dir(s)). Of course we already know what the value is, but I want to emphasize that we need to take this as a set Ctrl + enter Things that we use a lot in here the ‘_’ things are higher levels then our levels, so I’m going to tell you this when the ‘Class’ time I’m going to do the rest of them Let’s do some easy things first Fristly, lower and upper How to use them? Print(s.upper()) and Ctrl + enter Then it’s all changed to uppercase Ctrl c and v print(s.lower()) and Ctrl + enter It changes to uppercase and lowercase like this The functions without under bars are good implements to use in String type It is called method So I’m going to give you only the ones you use a lot For exmaple, ‘count’. Count is used for counting s.count(‘l’) means I will count how many l in s There are two l in s Let’s print it out Then it prints out that there are two l ‘join’ are also used a lot, and lstrip, rstrip, split are used a lot because they remove the empty space For example, here is ss It can be removed when I use ‘lstrip’ and here, ‘rstrip’ cleans this up When I use ‘strip’, then both of the empty space will disappear print(ss.strip()) and Ctrl + enter Here it comes without space If I just print out the ss, then there is a space There is a split For example, print(s.split(‘ ‘))

That means I will split s in space units Then it gives me paullab, CEO, LeeHoJun It splits based on the space I want to split based on the !, so I will put ! in my s Ctrl + enter. Because it was splited based on !, it becomes two I will delete this ! Also, ‘join’ are used a lot It is used for combining things For example, I re run the print(s.split(‘ ‘)) Then there are paullab, CEO, LeeHoJun And I want to join these again Then you can use ‘join’ For example, I put s.split(‘ ‘) in a and print out ‘a’ But I want to show ‘a’ that joins with ! Ctrl + enter. It comes out like this. paullab!CEO!LeeHoJun One of the things I use a lot is ‘format’ I will explain ‘format’ print(‘My name is {}. My age is {}’ .format(‘LeeHoJun’,33)) and Ctrl + enter My name is LeeHoJun. My age is 33 This one matched this, and that one matched this You can specify the order here I told you that it always starts from 0, I put 1 here, so 33 will match here. Ctrl + enter My name is 33 My age is 33. Like this If I put 0 here and there, what will come out? Format has many usages But I can’t do all of them, so please study the format Alt + enter a = 2019, b = 9, c = 24 I want to print out September 24, 2019 2019/9/24 I want to print like this Comment this out Press the Ctrl + / to comment it all at once print(a,b,c) and Ctrl + enter 2019 9 24 Copy this code It comes out like this 2019 9 24 You can connect the variables with , in ‘print’ And you can give some options This is ‘end’ option I give the option end=’ ‘, which means I want to give space at the end Then this will come up The default of print is enter I’m not going to put enter at the end, but space instead. Ctrl + enter. It comes up That’s because there is no enter Now, I give a separate option. This means that I want to split it How to divide each of the elements? I’m going to give a ‘/’ here like this Ctrl + enter. Then the output is the way we wanted earlier, 2019/9/24 These two options are used a lot, so you need to know them Alt + enter. This time I’m going to the casting a = 10, b = ’10’, and print(a+b) We already knew that it does not work But I convert the type of b to an integer Now it becomes a number It is string type but because I convert the type, this is called a casting Ctrl + enter then it runs I’m going to do this way in this time print(str(a) + b) Ctrl + enter, there is 1010 This is because string + string Thus, Casting is when you convert a variable value from one type to other type Put the name of the type in front and enclose in parentheses We converted the type. There is one data type we did not do above, which is True and False a = True, b = False. There are only true and false print(type(a)) and print(dir(a)). They are always a set Dir is complicated, so make it as comment. Class is bool I’m going to do some test For example, print(bool()). It means that if you do this, you will do the casting Copy this 5 times What will come out if you do this? It comes out True because it contains space How about this? Ctrl + enter. It gives you False It contains nothing If you put 0, then it is False I’m going to do some more If you put 1 Ctrl + enter, then you have True All numbers except are True -1 is also True One more thing, there is None ‘None’ clarifies that you have nothing Ctrl + enter. The last one is False I think it would be better to know, so I explained it Alt + enter. I’m going to do arithmetic a = 3, v = 10 Let’s start with print(a+b), addition, subtraction, division(float and floor), multiplication, power and modulus

You already know addition, subtraction, and multiplication but what will this result? I’m sorry but I’m going to change a to b and b to a like this This will come 3.33333, which is a float type And this one is integer type Let’s run it. This is 3.3333.. and that is 3 This is multiplication so it comes out 30 And this one is power operator. 10^3 is 1000 This is modulus. This operator is very important b is divided by a is 3 and the remainer is 1 So it returns only the remainder What if the rest is 0, then what does it mean? That means b is a multiple of a. You must remember this! I’ve done arithmetic Alt + enter. Now, let’s do comparison operators a = 10, b = 3. print(a > b) a is greater than or equal to b, greater , less than, less than or equal to, equal to, and finally a is not equal to b Ctrl + enter It either returns True of False according to the condition Be careful these two conditions. The equal operator is not = This is substitution. Do not confuse between mathematics and coding two of ‘=’ are comparison, and != means not equal to Alt + enter. Let’s do the logical operators a = True, b = False. print(a and b), a or b, and not b ‘And’, ‘Or’, and ‘Not’ are called logical operators True is 1 False is 0 And is multiplication Or is addition Not is the opposite. Then it becomes clear If either of them has 0, and it is multiplication, so it becomes 0 If either of them has 1, and it is an addition, so it becomes 1 What about 1 + 1? what if a is True and b is also True? Then it becomes 2 However, as we did above, all the numbers except 0 is True Thus, it becomes True Also, b is False, and the opposite side of False is True. So not b is True Alt + enter. Let’s do the assignment operators I put 10 in a. I want to accumulate something in a Put a + 10 in a and then print(a) Then the output of a is 20 a has 10 and then a has a + 10 The equal operator always works last So the output is 20 But now a is repeated, so I want to erase the repeat I delete this a and put + in front of = like this Then it works as above Ctrl + enter It becomes 30. This upper line and lower line means the same Right now, you can use like this, but later, you’ll get used to it this more So this is an operator you should know Let’s do bitwise operators Actually, bitwise operators are rarely used in beginners a = 40 b = 14 print(a & b) and then # &(and) and |(or). ‘|’ is located above the enter shift + \( or dollar) => | And the ‘not’ operator is ~. These three are the bitwise operators Let’s print it out Ctrl + enter. Then it comes out 8 You don’t know how 8 is come out right? What would happend if I convert a to binary? Now a is 40. I’m going to convert a to binary Also, I’m going to convert b to binary Ctrl + enter. 101000 and 1110 The place value is not matched each other, so I’m going to make it fit I make these in binary and make their figures fit each other I’m going to print it again with 6 digits This is slicing that we did before It starts at 2nd. Why did I cut it like this? Because the first two digits are 0 and b, so I want to cut them out And then I’ll do the calculation below I’ll bring these two here What is the result of that 0 and(operation) 1 (0*1)? It is 0. And 0*0 is 0. If either of them is 0, then it becomes 0. So it will be like this, 001000 What is 1000 in binary? 2 4 8 so it is 8 Thus, print(a&b) is 8 Ctrl + / makes them as comments at once I’ll do like this so you can review this easier later The ‘OR’ operator works with the same principle The ‘NOT’ operator is little bit hard, so I’m not going to do this. Alt + enter Among the operators, there is a priority operator But we are not going to handle it Which one is the priority between addition and multiplication? Of course multiplication Then, what about between logical operators and arithmetic operators?

These kinds of things make you confused If you’re confused then just enclose in parentheses I’m going to do some functions define f with x and y z = x + y and this function will return z And I put 3 and 5 in function f Let’s print it 3 and 5 are x and y z will be return. Ctrl + enter. Then 8 is returned The return value entered here This front place is 4 spaces It is not a ‘Tab’ Of course, one Tab gives you 4 spaces But you shouldn’t think of it as a Tab It is because if you mix it with a Tab and a space, then you will get an error However, it cannot be recognized by the eye So use a space Of course, there is an editor that changes it automatically itself, but somes dosen’t This is the scope of the function. Alt + enter Same as before, define ff There is no input in this time print(‘1’), print(‘2’), print(‘3’), and then print(4). Then ff() Then how will it print? Here is the input, but there may be no input like this We called ff() though. However this def ff(): is it just look over here, not the bottom It just goes over So it runs this first And then I’ve called ff(). It goes back to print(‘1’) print(‘2’) print(‘3’). If you print it out, then it’s 4 1 2 3 Same here. Look at f(x,y) first, and go down here f(3,5). 3,5 will be x, y 3 + 5 = 8 so 8 is the return value. Thus, 8 is printed out Likewise, print 4 first, and run the function ff(), then 1 2 3 will be printed out By the way, I’m going to remove this blank How will it print out? It will be 3 4 12 Ctrl + enter. 3 4 1 2 Why is that? Because the scope of a function is up to the blank The value that you put in this way is called a parameter The value you put in directly is called an argument There is also an other name, but this one is the official name How would print(ff()) be? Ctrl + enter. It is None This one is omitted, return None Thus, even though we don’t type ‘return None’, the function always has ‘return None’ Now, let’s find the area of a circle define circle(r): width = r*r*3.14 return width print(circle(10)) Ctrl + enter It comes 314.0 I’ve tried a simple example Let’s do def aplus() a += 10. return a I’m going to put 10 in a How would print(aplus()) be? a has 10 Even though there is no value here, the inside of this function has a += 10 Then you can say that a will return 20 (10 + 10) Ctrl + enter. But I get an error This is because there is no the value of ‘a’ inside of the function What this mean is that This ‘a = 10’ cannot fit the value that changes into it Think about that there are tons of functions It is difficult to sepecify all variables differently I made that each other doesn’t interfere, and the ‘a’ variable (a = 10) has no effect in this ‘a’ variable (a += 10) In order to make this work, you need to give it an argument, ‘a’, like this. ( ‘a +=’ is changed to ‘aa +=’) The variable ‘a’ goes into the functions as an argument 10 Then ‘aa’ takes the argument 10, so aa comes out 20 Therefore, 20 will be printed out However, if you want to use a = 10 Then you can type ‘global a’. Now it works It didn’t work before though But you should be used ‘global’ with caution Because it affects other functions too It affects the other variables, which are in outside of the function Therefore, you need to use it carefully This is the end of the 001 file Let’s make 002 file Click File, New Notebook, Python 3, and name 002 I’m going to do list, tuple, dictionary, and set First of all, the list Let’s get to a variable called l with square brackets and 100, 200, 300, and 400 Then print(l), print(type(l)), and print(dir(l)). Make the last one as comment Ctrl + enter It comes out 100, 200, 300, 400, and ‘list’ I’m going to start with the list I’ll summarize the list first A list is a data structure in Python that is a mutable, or changeable, ordered sequence of elements Because there is an order, you can print out the order as we did with strings before The first of l Ctrl + enter, then 200 comes out 0th is 100 and the first one is 200, so 200 comes out But what happens when I put 1000 in the first place of l? print(l) and Ctrl + enter

Then 100, 1000, 300, 400 come out. It is because list is a mutable structure Alt + enter I don’t need to make ‘l’ again because I alreay made it print(dir(l)) Let’s do everything here, from append to sort l.append(300) and print(l) Then 100, 1000, 300, 400, 300 come out 300 is appended at the end The append method adds a single item to the end of the existing list l.clear() gives you nothing. This removes all elements from the list For this class, I’m going to go ahead without doing it Also I will explain l.copy() later l.count(300) is counting 300. Let’s print it We learned about a fuction before These open and close parentheses mean an argument Then somewhere it is used as a parameter The returned value is the number of 300 There are 300 here and here and here. Then the value will be three Ctrl + enter. But the value is 1 Because I kept running this cell, I got an error I will bring it below here like this Then there is 100, 200, 300, 400, 300, so 2 is printed out. It is because there is two 300 I continue the process with ‘l’ Now, let’s do l.extend() Append can only add one element However, exptend() extends the list by adding all items of a list Print(l). Then it printed out from 100 to 300 100, 200, 300 are extended An index refers to a position within an ordered list Let’s find the index of 400 What is the result? It is 3. 0 1 2 3 If there are two same items? Then only the very first item will be returned Try 100. Then 0 is returned Next, l.insert(3, 100), put 1000 in 3rd position print(l) and Ctrl + enter 1000 is in the thrid But there is no a deleted value It is pushed back from 400 till the end, like this So, 1000 is inserted in a list Pop removes and returns last value from the list or the given index value So, l.pop removes 300 in l list print(l). 300 is gone Also, pop can give an index If l do l.pop(3), then the third one, 1000, will be gone I’m going to do just pop here Now, l.remove(1000) print(l) and Ctrl + l. Then 1000 is gone Then what about l.remove(100)? Ctrl + enter Not every 100 is removed, only the first one is removed This 100 is still here And then reverse. l.reverse() Reverse() reverses objects of list in place print(l). 1000 is located here now The sort() sorts the elements of a given list in a specific ascending or desending order 100, 200, 200, 300, 300, 400, 1000 But as you will learn later, The sorted() and the reversed() are different sort() and reverse() handle the initial list, l, directly But sorted() and reversed() only handle a list without modifying the original sequence Let’s make them as comments So, we finished to learn a list Alt + enter Let’s do tuple A variable t = (100, 200, 300) print(t), print(type(t), and print(dir(t)) and then Ctrl + enter There are only few of them There are only count and index Tuples are sequences Also, tuples cannot be changed The immutable sequence means that it is impossible to insert an element into a given index, like this Ctrl + enter If you run this, you will get an error like this. It is because of a tuple Since we’ve done count and index, I won’t mention these again What happens if I try to add a list l into the tupple t like this? l is a list with 10 and 20 A data type that can be changed has been entered in a data type that cannot be changed I can change the data that can be changed I’m going to insert 10000 into 0th of l print(t). Then the value is changed But I said tuple is immutable This means that t cannot be chaged that it refers to l in 0th position The list l still can be change Thus, tuples are immutable which means you cannot update or change the values of tuple elements l is a list which I can change, so the value of t was changed And I didn’t do one thing l and t are sequences, so they can do slicing Which we’ve done it when string l[::-1] This reverses the order Ctrl + enter. Then you can see the reverse ordered from l, 400, 300, 200, 100 Same as before, list can slicing like string like this, l[start : stop : step] Next, go down below. I’ll do an easy one I’ll start set first S = {100, 200, 300, 300, 300} print(s), print(type(s)), print(dir(s)) Check out the result. There are only 200, 100, and 300, and the order also changed The other two 300 are gone A set is an unordered collection data type Also it has no duplicate elements This set is the same as intersection set, difference set, union set that we learned at school before

Those functions also exist here I think it would be good to study yourself these functions One example. If I want to add 500, then s.add(500) and print(s) 500 is added There is no order, they are scrambled Set is usually used for removing duplicates For example, print(set(‘aabbcccdddefggg’)) and Ctrl + enter Then the duplication is completely removed It is very often used in algorithmic problems It is important to use a set well Let’s try one more thing, union ss = {1,2,3} print(s.union(ss)) 1, 2, 3, 100, 500, 200, 300. This is an union set Alt + enter I’m going to do a dictionary this time A dictionary holds key : value pair. {key:value} Ctrl + / I’m going to tell you based on this The key ‘one’ has the value 10 And the key ‘two’ has the value 20 A dictionary is an unordered collection of data values and the key has no duplicates So, can I do print(d[1])? No, because there is no order Thus, here is the key Ctrl + enter. It receiving the key and printing out the value This kind of data type is called a dictionary print(type(d)) and print(dir(d)) and Ctrl + enter There is only few I’m going to do a ‘copy’ and ‘items’ , ‘keys’, and ‘values’ I copyed it three times d.values(), d.keys(), and d.items() then Ctrl + enter The first one is a collection of values The second one is a collection of keys The third one displays a list of a given dictionary’s (key, value) tuple pair You must remember this because it is used a lot The way to call it when it is called like this I’ll take it as a list, l Convert it to a list like this Print 0th of l Then ‘one’ and 10 come out The 1st of l gives you ‘two’ and 20 But I want to print only 10 Then the 1st of the 0th I did not to explain earlier This is mult-dimensional list When there are multiple circuit objects and ordered objects, index like this Ctrl + enter, then you can see only 10 comes out I’m going to do a ‘copy’ in a new cell I often use this example, I live in Jeju Let’s say I’m working at fruit store in Jeju A banana is 5,000won ($5) and an orange is 2,000won ($2) I found a Seoul store since the Jeju store worked well But there was a typhoon, so the price of orange so the price of orange of Jeju has risen to 100,000won Then, if you print out the Seoul store, the price of orange is changed Why is that? It is because of this seoul and jeju are equal These are not different stores You have to do .copy() here. Ctrl + enter Then now the seoul store is unchanged and only the jeju store is changed You need to know the purpose of a ‘copy’ I’ve finished to look at data types I’ll cover the control structures in part 2 Thank you

You Want To Have Your Favorite Car?

We have a big list of modern & classic cars in both used and new categories.