1 00:00:00,720 --> 00:00:02,940 Andrei: Alright. We're almost, 2 00:00:02,940 --> 00:00:04,350 kind of flying through this. 3 00:00:04,350 --> 00:00:05,670 I know we're going slow here, 4 00:00:05,670 --> 00:00:09,060 but trust me, once you get these data types, 5 00:00:09,060 --> 00:00:11,040 things become a lot easier. 6 00:00:11,040 --> 00:00:12,600 So we're just climbing that mountain 7 00:00:12,600 --> 00:00:15,750 so that we can start looking at a higher level 8 00:00:15,750 --> 00:00:17,193 at the language of Python. 9 00:00:18,630 --> 00:00:19,680 To keep going, 10 00:00:19,680 --> 00:00:22,620 let's talk about this data type. 11 00:00:22,620 --> 00:00:25,833 Str, which stands for strings. 12 00:00:26,730 --> 00:00:27,930 Let's see what they are. 13 00:00:30,480 --> 00:00:35,480 A string is simply, well, a piece of text. 14 00:00:35,640 --> 00:00:39,030 For example, a string can be written 15 00:00:39,030 --> 00:00:40,560 with quotation marks, 16 00:00:40,560 --> 00:00:44,490 and I can say, "Hi, hello there". 17 00:00:44,490 --> 00:00:46,080 And that is a string. 18 00:00:46,080 --> 00:00:49,050 You see that the color changed here in my editor. 19 00:00:49,050 --> 00:00:53,340 I can also make strings with double quotes. 20 00:00:53,340 --> 00:00:57,900 So once again, this is also a valid string. 21 00:00:57,900 --> 00:00:59,670 And I can put anything I want in here, 22 00:00:59,670 --> 00:01:01,410 I can do numbers, if I wanted to, 23 00:01:01,410 --> 00:01:05,040 exclamation marks, it's just a piece of text. 24 00:01:05,040 --> 00:01:07,770 You can think of it as a sentence for now. 25 00:01:07,770 --> 00:01:10,920 And if I do the type function here, 26 00:01:10,920 --> 00:01:13,470 remember these brackets denote 27 00:01:13,470 --> 00:01:15,510 that we wanna perform some sort of action, 28 00:01:15,510 --> 00:01:19,200 which is we're using the type action that Python gives us. 29 00:01:19,200 --> 00:01:21,960 And if I click Run, you see that, 30 00:01:21,960 --> 00:01:24,780 oh, and remember, we have to print it out as well, 31 00:01:24,780 --> 00:01:28,623 so let's do print, so that we can see the display. 32 00:01:30,180 --> 00:01:31,530 And I click Run. 33 00:01:31,530 --> 00:01:36,270 You see that it's str, it's a type of string. 34 00:01:36,270 --> 00:01:39,390 Now we can use this in important ways. 35 00:01:39,390 --> 00:01:43,500 For example, imagine you're creating a login form, 36 00:01:43,500 --> 00:01:47,193 and we wanna collect somebody's username and password. 37 00:01:48,060 --> 00:01:52,230 Well, we can have username variable 38 00:01:52,230 --> 00:01:56,100 that we assign let's say some sort of username, 39 00:01:56,100 --> 00:01:57,513 let's call it supercoder. 40 00:01:59,730 --> 00:02:03,813 And then password can be supersecret. 41 00:02:04,650 --> 00:02:07,530 And now we have these variables, usernames and passwords, 42 00:02:07,530 --> 00:02:09,270 that we can use throughout our program, 43 00:02:09,270 --> 00:02:12,840 such as to check if a password exists. 44 00:02:12,840 --> 00:02:16,263 And remember, I can use single quotes or double quotes. 45 00:02:17,190 --> 00:02:21,360 But there's a third way that we can write strings in Python. 46 00:02:21,360 --> 00:02:25,200 And this, well, is used for long strings. 47 00:02:25,200 --> 00:02:28,320 So let's just create a variable long_string, 48 00:02:28,320 --> 00:02:32,250 and what we can do here is three single quotes 49 00:02:32,250 --> 00:02:34,380 in a row like this. 50 00:02:34,380 --> 00:02:37,650 And then here, I can just say, 51 00:02:37,650 --> 00:02:38,850 wow, 52 00:02:38,850 --> 00:02:42,120 maybe, a pair of eyes of somebody 53 00:02:42,120 --> 00:02:43,560 that's really impressed, 54 00:02:43,560 --> 00:02:45,423 and let's go with a mouth. 55 00:02:46,800 --> 00:02:49,170 That actually kind of looks like hair. 56 00:02:49,170 --> 00:02:50,003 Alright. 57 00:02:50,003 --> 00:02:53,820 And then I finish it off with three single quotes again. 58 00:02:53,820 --> 00:02:58,820 So now if I print the long string, 59 00:02:59,790 --> 00:03:02,850 and I click Run, look at that. 60 00:03:02,850 --> 00:03:07,170 My little weird emoji face is printed. 61 00:03:07,170 --> 00:03:10,470 So the three single quotes is for long strings 62 00:03:10,470 --> 00:03:13,380 that I can keep going on multiple lines. 63 00:03:13,380 --> 00:03:15,690 For example, I can't do this with the single quote. 64 00:03:15,690 --> 00:03:18,540 You see that the orange color is now gone, 65 00:03:18,540 --> 00:03:20,100 because Python is going to say, 66 00:03:20,100 --> 00:03:22,920 this is a new line and this is another line, 67 00:03:22,920 --> 00:03:23,970 and it's going to give me an error 68 00:03:23,970 --> 00:03:28,970 because, well, ecret with a quote doesn't mean anything. 69 00:03:29,130 --> 00:03:31,410 But if we use three single quotes, 70 00:03:31,410 --> 00:03:34,470 you can see that we can do multi-line strings. 71 00:03:34,470 --> 00:03:36,900 And this is really useful if you wanna have 72 00:03:36,900 --> 00:03:39,810 maybe long sentences and paragraphs. 73 00:03:39,810 --> 00:03:41,124 Now with a string, 74 00:03:41,124 --> 00:03:44,130 we can do some cool things that we saw 75 00:03:44,130 --> 00:03:45,753 in the numbers videos. 76 00:03:46,890 --> 00:03:50,220 What if I had something like this. 77 00:03:50,220 --> 00:03:55,220 Let's say I wanted to grab the first name of a user. 78 00:03:57,990 --> 00:03:59,970 Just give my own name here. 79 00:03:59,970 --> 00:04:01,293 And then last name. 80 00:04:02,580 --> 00:04:06,540 And again, my super hard to pronounce last name. 81 00:04:06,540 --> 00:04:08,010 Could we do something like this, 82 00:04:08,010 --> 00:04:11,610 where we have full_name equals 83 00:04:11,610 --> 00:04:13,130 to first_name, 84 00:04:15,180 --> 00:04:17,463 plus last_name. 85 00:04:19,620 --> 00:04:24,620 And then if we print here the full_name like this. 86 00:04:28,170 --> 00:04:29,070 Should this work? 87 00:04:29,070 --> 00:04:30,120 Well, let's have a look. 88 00:04:30,120 --> 00:04:32,850 Let me remove this part here, 89 00:04:32,850 --> 00:04:36,150 just so we have nice and clean looking code. 90 00:04:36,150 --> 00:04:39,870 And if I click Run, there you go. 91 00:04:39,870 --> 00:04:40,890 My name is printed, 92 00:04:40,890 --> 00:04:43,500 but you see that there's no spaces here, 93 00:04:43,500 --> 00:04:46,110 because we're going to use the addition sign 94 00:04:46,110 --> 00:04:48,330 to attach Andrei to Neagoie, 95 00:04:48,330 --> 00:04:50,460 but you can see that there's no spaces here. 96 00:04:50,460 --> 00:04:52,680 So I can add a space if I wanted to, 97 00:04:52,680 --> 00:04:56,460 or I can just simply create another string 98 00:04:56,460 --> 00:04:57,513 inside of here, 99 00:04:59,310 --> 00:05:00,143 just like this, 100 00:05:00,143 --> 00:05:01,983 and then add a space in between. 101 00:05:03,360 --> 00:05:05,610 So we're just using the plus sign, 102 00:05:05,610 --> 00:05:08,700 which we've seen in the numbers videos, 103 00:05:08,700 --> 00:05:11,163 but instead to add strings together. 104 00:05:12,240 --> 00:05:13,683 And now if I click Run, 105 00:05:14,640 --> 00:05:16,410 you see that I got the space, 106 00:05:16,410 --> 00:05:19,140 because I'm adding a space in here, 107 00:05:19,140 --> 00:05:21,000 in between the names. 108 00:05:21,000 --> 00:05:22,533 Very, very cool. 109 00:05:23,460 --> 00:05:24,930 But there's a few more neat things 110 00:05:24,930 --> 00:05:26,130 that we can do with strings. 111 00:05:26,130 --> 00:05:27,270 So let's take a break, 112 00:05:27,270 --> 00:05:29,020 and I'll see you in the next video.