Hi, everybody, and welcome, this lecturer's topic will be integer and thought variables, which are
numeric variables.
In the last lecture we have cathode string variables and now we'll talk about numbers.
So let's go over the definition.
Python supports two types of numbers, integers and floating point numbers.
So just a quick reminder, guys, we talked last last lecture.
How can we identify integer sorry, string variables?
How can we identify them?
So we said that if we have a variable equals and then we have quotation marks before and after the value.
So this will be a string variable.
Now, as you can see, the numeric variables which are integer and float does not have quotation mark.
And this is how we can def differentiate this integer and float variables from the string variable.
So integers are whole numbers.
All right.
So when you see a variable and it equals to a whole number, you can identify this is an integer.
And if we have, for example, Y equals 15, simply the value 15 will be stored inside the Y value.
So and then we have the float variable, the float variable.
We have an American value, whether that's a small portion.
And this is how you can differentiate an integer from a float.
So once you see that simple point, you can say that this and this variable is a float.
So let's go quickly over a few examples.
You can see here the variable age, which is equal to 52, and this is an integer.
You can see here the wait, you have a decimal point, so this is a float here, also a whole number.
So this is an integer and another one with the decimal point, the height.
So this is a float.
So now that we get the hang of it, let's go straight, straight to PI charm.
Let's open it our initial project.
And once it's all just right, click on it new and then create a new file.
All right, sorry, Carlos, for me.
All right.
Let's call it integer.
And float variables, let's give it the quick headline, Integer and Float.
Variables, which are numbers I'm giving all of these comments, because if we encounter this fall further
on like it from eight months from now or a few weeks from now, so we can get what the content immediately
using these comments.
So let's start quickly with the simple example.
Print off a simple string.
Variable, and let's just declare a new one.
And let's give it the value 10 then, Brent, same as we did with strings, and that's put the variable
inside.
Right, click on the file run and there you have it, you have the variable value right here and now
I'm going to do something and different before the variable here in the industry in their print.
So let's add a string.
Let's say integer variable value is two dots, then space.
And then after the quotation mark, we want to add this variable to the print.
Let's just add the plus side and that's printed.
Right.
Click, run.
Whoa.
All right.
So we can see here in the console, I read the text, which indicates obviously we had an error up until
this point.
We didn't handle with exceptions or errors, but we will deeply for the further on in the exception
handling part.
But right now, let's do it the first time.
So always when you have an error, you have indicative information in it.
So try to read it to understand what happened.
So we can see here the file, which is integer and float variables, which is our file.
And we have an error error in line five, which is this line, the print one.
And you can see here that we have can only concatenate string and not int to string meaning by charm
is angry with us that we mixed string along with integer.
He doesn't like it, so we need to solve it in order to remove this error.
And how do we resolve this issue?
We need to have one type of variable, one type of variable inside the print so we simply add brackets
before and after the variable.
And then we want after we have brackets around it that we want to add here, the letters s t r and you
can see it turned purple for me.
Maybe you have other calls.
It doesn't matter.
This means that we will convert this the of the integer variable into a string in order to have one
type of variable inside the print.
So let's try to run it right now again.
There you have it.
So integer variable value is ten.
So problem resolved.
All right.
So let's give some more manipulations and math manipulations on integers and floats.
And all along the way, I'm going to use the text and then string and then I'm going to put the number
inside for one simple reason, because if I remove this text and then you will have here at 10 or 15
values downwards, you will not know which one is or what, what manipulation we did upon the numbers
you will see here.
So when you have indicative text and then a number, you can know what the number had been through.
So let's go on.
So first of all, that's defined simple variables for further money.
Two locations, so let's do a simple variable, A. And let's put it five, and then we have simple.
Variable B equals then and let's start with the summary with the plus sign.
And let's create a third variable, which will contain the summary of two of them summary.
Result.
And then that's put simple, by the way, I just want to remind you gathered that once you once you
try typing, you have all of these options open here.
And instead of typing the whole simple variable, a thing with your keyboard, you can just heat enter
once selecting what you want.
Plus simple variable be enter.
All right.
So in the last lecture when we talked about strings, so once we do the plus sign, we just try to printed.
What we had seen is that you get the string first string and then the second string printed one after
the other.
But now we're dealing with numbers.
So this would not happen.
Now the plus sign will do a mathematical action upon these numbers.
So let's just try to print it.
Some are into that then after that plus SDR.
And brackets and some result, let's print it and see what happens.
Great.
So we have the summary of 10 plus five right here, which is 15.
And that's amazing.
So let's do another one.
Let's do.
Multiply.
Two numbers and
let's do it again, multiply result equals simple number A and then do the star.
And then simple, no be.
All right, then, let's try to print it.
And to the plus, all right, and then multiply a result.
And don't forget to convert it using brackets and SDR letters and before it and let's try to print it
five times, then we get 50.
So we get it right here.
And now we need to do a division, divide two numbers and divide result.
And let's do.
Simple, not a simple variable, a then slash and then simple, not a variable B.
Sorry, B, and then A, we want to divide five divided by ten, divided by five.
Then be divided by a.
All right, click, Ron, I, I disappointed sorry, my bad print enter
divide.
To devise a result, let's have the same pattern as the others.
Right.
Just added the results here.
So we have results for all of them.
And plus SDR and brackets and double click on it control.
See the copy control to paste and.
That's right.
Click and run.
Great.
So ten divided by five.
We have two.
All right.
So this answer is correct.
And now let's try to do power two numbers.
So power result.
And once you want to do power, you need to do for example, let's take a simple variable A and do it
power and two.
And let's bring the result.
So basically, when you do power plus ACR, Brackett's, same thing, you seeing the same thing all
along, and once we try to print it, we'll see.
Twenty five.
For those of you who don't know what power is, power is, just want to do a quick point here.
So power is basically this.
All right.
So this is what you get with power, you just write, uh, you just write two stars, two times a star,
and then you have the power action applied.
All right, great.
So next one in line is a special one is modular and modular is something that you don't encounter in
daily basis.
And but still, we're going to try to teach it and try to learn it.
Sorry.
And basically what that means is when we take a variable, for example, the value of five, right,
because simple variable is five and then you do the percentage sine and then you do two.
Basically, when you take five and you divided by two, you get the whole number, which is two.
But you have like a left left over, which is one.
All right.
Because it's not a whole number that you get when you divide five by two, we'll get to where the left
of one.
So modular would give you the left one, the one the.
This is the purpose of modulo.
And let's try to see SDR copy paste inside the SDR and let's run it.
All right.
So there you have it.
You have the model result.
And now let's try to all of these words, integer variables, and let's try now to use a flawed variable
which has a decimal point.
It's not to use each decimal point variable, which is float, and that's do that.
Valuable, a stake, two point five, and that's IMO very will be, and that's put a zero 25 and let's
try to submit a new one summary.
ofThe.
To that symbol of two floats, to be more exact, so that more variable A and then that's A more variable
B and let's try to print it right here, a summary of two float variables and plus the I'm sorry, ETR
and Samari.
And it's right here, you can click it with your mouse as well.
And let's run it so we have a plus here so we can get.
We're going to get two point seventy five when summarizing this value along with this one.
And let's do one last thing.
All right.
Up until this point, what we did is we took these two variables, all right.
A and B, and we apply the actions upon them along the way.
But you don't have to use variables like this and then to apply actions between the two variables.
All right.
You can also just take two numbers as well and apply actions upon them as well.
It's the easier thing.
So I'm just going to give you one example.
It's the easier way and the harder thing is to apply actions upon the variables.
Actually, it's pretty much the same.
But I want you to see the whole all cases.
So you become a ninja in numbers on Python.
So right here you can see all mathematical actions.
All right, guys.
So it gives you great power once you start writing automation test cases and you'll need to use math
inside your test case.
This gives you great power, guys, because now you know how to use numbers, you know how to play numbers.
And later on, you're going to create lots of variables using these numbers and passing the variable
and then using it and applying math actions on them.
And this is very, very useful stuff.
So let's do like this apply, act, apply actions upon variable.
It's not just actions, it's math actions upon the very well.
And let's do, for example, uh.
Actions on a variable and again, it's not actions just like that, it's math actions equals, for example,
let's do four times five.
And let's just try to print it and apply math actions on a variable and.
SDR, that's Sculpey, this one, and open the brackets, put it inside and try to run it.
All right, so you can do this option as well, you see, I just apply the actions straight ahead on
a variable without using declaration of variable before applying actions as we did in all of these places.
So right here, we just applied it straight ahead on a variable.
And you could do it with all the math actions that you want.
Let's try the plus sign and it's a nine.
All right.
So that's about it, guys.
Now, you have domination of all math actions, both on integer and offloads, so you can use whole
numbers and also use float numbers with decimal point.
So this party's is over.
And I urge you guys that to know that knowing actually knowing the stuff, knowing the material is not
just understanding it, but please do the following lectures and practice it so it will get deep in
your mind.
So later on, when you know all the parts together, you'll start writing test cases and you'll be a
professional, you'll be a true ninja.
So please practice first.
First of all, just read the instructions in the next lecture of the assignment.
Try to solve it by yourself.
And if you are not mentioning managing to solve it by yourself, then see the following after that lecture
to see the resolution.
And I'll show you the whole resolution of the practice.
And that's about it, guys.
So thank you.
And see you in the next lecture.