WEBVTT 00:00.590 --> 00:01.410 Welcome back. 00:01.760 --> 00:05.660 In his lecture, I'm going to show you an example program named Bangar. 00:06.410 --> 00:09.880 When I ran the program like this, it will return this. 00:10.760 --> 00:13.280 So the program takes one input argument. 00:14.060 --> 00:20.750 Then it calculates how many characters there are in the past argument, and then it brings it back in 00:20.750 --> 00:27.290 capital letters and it adds exclamation marks next to it, depending on the past arguments lacked. 00:27.920 --> 00:34.610 For example, here he has three characters, so the program prints with three exclamation points or 00:34.610 --> 00:36.470 Heller has five characters. 00:36.480 --> 00:36.790 Right. 00:37.340 --> 00:41.360 So it prints hello with five exclamation points after it. 00:44.430 --> 00:50.640 By the way, for this program, I'm going to use a function from the Strings Package Strings package 00:50.640 --> 00:53.810 provides many utility functions for working with strings. 00:54.600 --> 00:57.300 So let's check out its online documentation together. 00:58.640 --> 01:06.020 Package String's implements simple functions to manipulate UTF eight encoded strings, there are a lot 01:06.020 --> 01:07.930 of functions from time to time. 01:07.940 --> 01:10.040 I'm going to use this package for now. 01:10.070 --> 01:13.760 The function that I'm interested in right now is the repeat function here. 01:14.480 --> 01:15.500 So let's check it out. 01:16.470 --> 01:20.630 Repeat returns a new string consisting of count copies of the string. 01:20.640 --> 01:26.910 Yes, so this means that I can use this function to repeat strings as many times as I want. 01:27.400 --> 01:36.060 OK, look at its function signature it takes to input parameters, as is a string and count as int, 01:36.330 --> 01:38.130 then it just returns a string value. 01:38.910 --> 01:43.020 Now let's get back to the code editor and use this function in the code. 01:47.350 --> 01:51.130 All right, first, I'm going to put the past argument into this variable. 01:52.330 --> 01:58.690 Then I'm going to start the length of the argument in this variable like this is, you know, now land 01:58.690 --> 02:02.860 function here calculates the length of the past argument in bytes. 02:03.400 --> 02:07.570 So this program only works correctly with the non Unicode characters. 02:08.080 --> 02:10.180 OK, now I'm going to create a new string variable. 02:10.690 --> 02:13.460 First, I'm going to type MSgt. 02:13.690 --> 02:17.590 Then I'm going to combine this with the value that will be returned from the strings. 02:17.600 --> 02:19.100 Repeat function like this. 02:20.050 --> 02:25.570 First, I'm going to type an exclamation mark here, then I'm going to pass the URL variable here. 02:26.540 --> 02:32.720 With this repeat function will create a new strength by repeating this exclamation string, literal 02:32.720 --> 02:34.100 and number of times. 02:35.730 --> 02:43.590 So if Al is, too, it will return back to exclamation points, if it is one, it will return back one 02:43.590 --> 02:44.690 exclamation point. 02:44.700 --> 02:45.320 And so. 02:46.800 --> 02:48.210 OK, let's just print it now. 02:51.210 --> 02:54.090 OK, I'm going to open up a terminal and run this program there. 03:00.340 --> 03:01.930 Then I'm going to run it with cool. 03:04.560 --> 03:05.500 Now I'm going to run into it. 03:05.610 --> 03:06.060 Hey. 03:06.980 --> 03:09.110 Now I'm going to pass incomprehensible. 03:12.330 --> 03:18.360 And lastly, I'm going to run it with perfect, as you can see, it adds as many exclamation points 03:18.360 --> 03:21.380 as the length of the past value, right? 03:22.970 --> 03:29.750 OK, now let's use another function from the strings package, this time it will print the past argument 03:29.750 --> 03:31.000 in capital letters. 03:31.730 --> 03:32.420 Let's do that. 03:33.660 --> 03:38.130 Now I'm going to call two upper function with the variable like this. 03:39.560 --> 03:41.390 Let's take a look at its documentation. 03:42.410 --> 03:49.100 This function takes a strange value and returns a copy of it in capital letters, whenever you see the 03:49.100 --> 03:53.180 word copy, it means that it's doing a memory allocation. 03:53.330 --> 03:57.560 However, it's negligible for the simple programs like this one anyway. 03:58.320 --> 03:59.180 That's right now. 04:00.950 --> 04:07.250 It could be today and some, as you can see this time, it's back at me. 04:07.610 --> 04:07.930 Cool. 04:08.390 --> 04:08.890 All right. 04:08.900 --> 04:10.130 That's all for this lecture. 04:13.610 --> 04:14.480 Now it's your turn. 04:14.960 --> 04:16.290 Here's an exercise for you. 04:16.820 --> 04:21.760 I want you to add exclamation marks also in front of the past argument. 04:22.430 --> 04:27.140 For example, if you're on the program with the argument, then you should print this. 04:28.090 --> 04:34.220 Or if you run it with the cool, then it should print this as a bonus. 04:34.390 --> 04:38.110 Use the repeat function only once by using a variable. 04:39.000 --> 04:39.510 Good luck.