Welcome back.
Now let's do a practice.
Exercise.
The task ask the user for two numbers then display their sum.
So we need to ask the user for two numbers.
Make the sum and display the result.
The first step is to pause the video, think about it and write your on your notebook in Google Colab
and try to run the file by your own.
I think you solve it well.
So let me start with step one.
Get input Num1 equals to input function.
Enter the first number and num2 equals to input.
Enter the second number.
Then we need to calculate the sum total equals to num one plus num two okay.
The third step is to display the result.
Here we are going to use print f the formatted string.
And here set the sum of number one.
And number two is total okay.
So I used the concatenation and the formatted string, the Num1 and Num2 is total.
And here we used the variables to do the arithmetic operation.
And here we used the input function to get the input from the user.
Run the cell.
Enter the first number 55.
Enter the second number 15 and hit enter.
The sum of 55 and 15 is this concatenation.
And this is not true because it's doing a concatenation of strings.
We didn't convert the strings into integer and do this concatenation.
So here in order to do that, in order to solve this problem we need to convert it using the integer
function.
Integer and surround this variable.
So here we are converting the number one and number two into integers and store them into the total.
In order to do this summation again 5515 and the result is 70.
So I used this exercise in order to clarify the importance of paying attention to the data types.
So data types are very crucial guys.
Any miss, any mistake, any error in converting and getting the correct data type you want, the result
will be wrong.
So as you see here, we have an error in data types.
We have concatenation of two strings.
It gives us 5515.
And the result the correct result is 70.
So it was concatenation of strings.
When we convert them into integers the result becomes true.
So guys please pay attention.
This is a very good example.
It may be very simple, but it it summarizes all the previous concepts and all the tricks that we,
we have in data types.
I want from you to write this down and pay attention to data types.
How to convert between types and how to get input from the user.