Welcome back.
We learned about variables and we run the cell and get this output.
Now let's move to the second lesson which is the basic data types.
Python has several built in data types.
The most common ones are integer, float, string, and boolean.
In any programming language, data type is an important concept.
Variables can store data of different types and different types can do different things.
Python has many data types, for example string, int float, complex list, tuple range, dictionary
set, frozenset, bool, non-type bytes, byte array, memory view, and others.
You can get the data type of any object by using type function.
Here we have the integer, float, string, and boolean.
Those are the most common variable and variable types in data types.
In Python, integer is used for integer numbers like 42, minus three, 1000, and others.
Float, which is used for decimal numbers 3.14, 2.0, -0.5.
String used for texts or strings.
Hello world!
You can write them both types and Boolean used for true or false.
You can check the type of each variable using the type function.
Let me run this and you will get the first variable name which is string.
If we go up, we created those variables.
The name is of type string.
The age of type, an integer height Boolean.
It's a decimal and a student is a boolean.
So we have string, int, float and boolean.
Okay, this is how we check for the type of each variable in Python using the type function.
Also we can use Python variable casting.
There are many times when you want to specify a type on a variable.
This can be done with casting.
Python is an object oriented language and as such it uses classes to define data types, including its
primitive data types.
For example, if I want to cast the age or the height to an integer, what I need to do here.
Casting variable from float to int.
Let me say height casted equals to integer and we need to specify the height.
Then go and print the type of the height casted.
Run again and here we go.
We casted the type from from float to integer.
Let me run, print and see the height casted.
It's not 5.9, it's now five because it's casted to integer and the integer removes that decimal part.
So here we are casting.
We are transforming the height from float into integer.
One last note for the strings in Python.
Strings in Python are surrounded by either single quotation mark or double quotation mark.
You can display a string literal with a print function.
So here we can use print hello developers without using a variable and calling the variable inside the
print.
So you can notice that hello developers is printed booleans.
You.
You often need to know if it's an expression true or false.
You can evaluate an expression in Python and get one of two answers, either true or false.
When you compare two values, the expression is evaluated and Python returns the boolean answer.
For example, let's run.
Now we get false because x is not equal to y.
Let me check if it is greater than.
Also we get false x less than y.
Run.
We have true okay.
So we're going to learn about comparison and operators in the next videos.
But when you compare two values the expression is evaluated.
And Python returns the boolean answer.