WEBVTT

00:00.080 --> 00:00.920
Welcome back.

00:00.920 --> 00:06.200
We learned about variables and we run the cell and get this output.

00:06.400 --> 00:11.560
Now let's move to the second lesson which is the basic data types.

00:11.840 --> 00:15.280
Python has several built in data types.

00:15.280 --> 00:20.520
The most common ones are integer, float, string, and boolean.

00:20.640 --> 00:25.600
In any programming language, data type is an important concept.

00:25.760 --> 00:31.440
Variables can store data of different types and different types can do different things.

00:31.480 --> 00:40.560
Python has many data types, for example string, int float, complex list, tuple range, dictionary

00:40.760 --> 00:47.440
set, frozenset, bool, non-type bytes, byte array, memory view, and others.

00:47.440 --> 00:52.120
You can get the data type of any object by using type function.

00:52.120 --> 00:57.120
Here we have the integer, float, string, and boolean.

00:57.160 --> 01:03.080
Those are the most common variable and variable types in data types.

01:03.080 --> 01:11.580
In Python, integer is used for integer numbers like 42, minus three, 1000, and others.

01:11.820 --> 01:18.500
Float, which is used for decimal numbers 3.14, 2.0, -0.5.

01:18.700 --> 01:21.460
String used for texts or strings.

01:21.620 --> 01:23.180
Hello world!

01:23.180 --> 01:28.220
You can write them both types and Boolean used for true or false.

01:28.220 --> 01:32.780
You can check the type of each variable using the type function.

01:32.780 --> 01:40.220
Let me run this and you will get the first variable name which is string.

01:40.220 --> 01:43.620
If we go up, we created those variables.

01:43.620 --> 01:45.940
The name is of type string.

01:46.100 --> 01:50.220
The age of type, an integer height Boolean.

01:50.940 --> 01:54.620
It's a decimal and a student is a boolean.

01:54.620 --> 01:58.180
So we have string, int, float and boolean.

01:58.220 --> 02:06.300
Okay, this is how we check for the type of each variable in Python using the type function.

02:06.300 --> 02:10.380
Also we can use Python variable casting.

02:10.540 --> 02:15.420
There are many times when you want to specify a type on a variable.

02:15.420 --> 02:17.500
This can be done with casting.

02:17.540 --> 02:24.570
Python is an object oriented language and as such it uses classes to define data types, including its

02:24.570 --> 02:26.250
primitive data types.

02:26.370 --> 02:35.450
For example, if I want to cast the age or the height to an integer, what I need to do here.

02:35.650 --> 02:39.290
Casting variable from float to int.

02:39.330 --> 02:47.690
Let me say height casted equals to integer and we need to specify the height.

02:47.730 --> 02:51.610
Then go and print the type of the height casted.

02:51.650 --> 02:53.850
Run again and here we go.

02:54.090 --> 02:59.290
We casted the type from from float to integer.

02:59.330 --> 03:03.970
Let me run, print and see the height casted.

03:04.010 --> 03:15.250
It's not 5.9, it's now five because it's casted to integer and the integer removes that decimal part.

03:15.290 --> 03:17.410
So here we are casting.

03:17.410 --> 03:22.850
We are transforming the height from float into integer.

03:22.890 --> 03:27.730
One last note for the strings in Python.

03:27.730 --> 03:34.360
Strings in Python are surrounded by either single quotation mark or double quotation mark.

03:34.400 --> 03:38.920
You can display a string literal with a print function.

03:38.920 --> 03:49.040
So here we can use print hello developers without using a variable and calling the variable inside the

03:49.040 --> 03:49.640
print.

03:49.640 --> 03:54.880
So you can notice that hello developers is printed booleans.

03:54.880 --> 03:55.320
You.

03:55.360 --> 03:59.720
You often need to know if it's an expression true or false.

03:59.720 --> 04:06.280
You can evaluate an expression in Python and get one of two answers, either true or false.

04:06.440 --> 04:13.680
When you compare two values, the expression is evaluated and Python returns the boolean answer.

04:13.680 --> 04:15.280
For example, let's run.

04:15.280 --> 04:20.480
Now we get false because x is not equal to y.

04:20.720 --> 04:23.480
Let me check if it is greater than.

04:23.600 --> 04:27.360
Also we get false x less than y.

04:27.680 --> 04:28.520
Run.

04:28.600 --> 04:30.240
We have true okay.

04:30.520 --> 04:35.680
So we're going to learn about comparison and operators in the next videos.

04:35.680 --> 04:39.360
But when you compare two values the expression is evaluated.

04:39.360 --> 04:42.480
And Python returns the boolean answer.
