Welcome back.
In his lecture, I'm going to show you an example program named Bangar.
When I ran the program like this, it will return this.
So the program takes one input argument.
Then it calculates how many characters there are in the past argument, and then it brings it back in
capital letters and it adds exclamation marks next to it, depending on the past arguments lacked.
For example, here he has three characters, so the program prints with three exclamation points or
Heller has five characters.
Right.
So it prints hello with five exclamation points after it.
By the way, for this program, I'm going to use a function from the Strings Package Strings package
provides many utility functions for working with strings.
So let's check out its online documentation together.
Package String's implements simple functions to manipulate UTF eight encoded strings, there are a lot
of functions from time to time.
I'm going to use this package for now.
The function that I'm interested in right now is the repeat function here.
So let's check it out.
Repeat returns a new string consisting of count copies of the string.
Yes, so this means that I can use this function to repeat strings as many times as I want.
OK, look at its function signature it takes to input parameters, as is a string and count as int,
then it just returns a string value.
Now let's get back to the code editor and use this function in the code.
All right, first, I'm going to put the past argument into this variable.
Then I'm going to start the length of the argument in this variable like this is, you know, now land
function here calculates the length of the past argument in bytes.
So this program only works correctly with the non Unicode characters.
OK, now I'm going to create a new string variable.
First, I'm going to type MSgt.
Then I'm going to combine this with the value that will be returned from the strings.
Repeat function like this.
First, I'm going to type an exclamation mark here, then I'm going to pass the URL variable here.
With this repeat function will create a new strength by repeating this exclamation string, literal
and number of times.
So if Al is, too, it will return back to exclamation points, if it is one, it will return back one
exclamation point.
And so.
OK, let's just print it now.
OK, I'm going to open up a terminal and run this program there.
Then I'm going to run it with cool.
Now I'm going to run into it.
Hey.
Now I'm going to pass incomprehensible.
And lastly, I'm going to run it with perfect, as you can see, it adds as many exclamation points
as the length of the past value, right?
OK, now let's use another function from the strings package, this time it will print the past argument
in capital letters.
Let's do that.
Now I'm going to call two upper function with the variable like this.
Let's take a look at its documentation.
This function takes a strange value and returns a copy of it in capital letters, whenever you see the
word copy, it means that it's doing a memory allocation.
However, it's negligible for the simple programs like this one anyway.
That's right now.
It could be today and some, as you can see this time, it's back at me.
Cool.
All right.
That's all for this lecture.
Now it's your turn.
Here's an exercise for you.
I want you to add exclamation marks also in front of the past argument.
For example, if you're on the program with the argument, then you should print this.
Or if you run it with the cool, then it should print this as a bonus.
Use the repeat function only once by using a variable.
Good luck.