Hello everyone, welcome to watch my video. In this video, I will tell you how to use different
built-in datatypes in Python with examples. First, let's look at the first example
The example is a custom function. The function name is example.SegureType. First, it will
define a variable x and assign it to it. Then the x variable type is gen. And you can also
use the str function to create a string object and assign it to a variable, such as variable
y. And then we use the type function to get the variable type and print out the variable
value on the console. We will run this example for you. Okay, comment other function
Okay, now we can right-click and click run Python and pass the function in term. You can see
this is the first print function output. It shows the type of the variable x is str and the content
is Python program. And the second one is the second variable y. It's also a string object
and its content is simple is better than complex. Okay, this is a str datatype
Besides str datatype, you can also use other datatypes. For example, int. You can assign
integral number to a variable or use the int function. Float. Complex. Okay, and this function
will show you how to use the numeric datatype in Python. It also uses the type function to get the
variable type. Okay, we can run it. Yes, you can see this is the result
The first one is an integral number so its type is int and this is a value. The second variable is a
float object so this type is float. And the third one is a complex object. Okay, besides this, there
are also other datatypes such as list, tuple, and range. You can create lists using this
way or use the list function. You can create a tuple object like this or use the tuple function
Range is a random object and if you want to print it out on the screen, you should use
this function to convert it to a list. Now we will run this example
Yes, you can see the first one is a list object. The second one is a tuple object and the third
one is a range object. The range object is created by the range function. It will create a
number sequence from zero to the last number but exclude this number. Okay
and besides this built-in datatype, there is also a dictionary datatype like this
You can use this method to create a dictionary datatype. The dictionary datatype contains a key
and a value. So it is also called a key-value pair. You can run it
Okay, we debug this function. Yes, it stops here and use this method to create a dictionary object and then get its type and
print out the content on the screen. You can see here is the result. The type is dictionary object
Okay, and there are also a set type and a frozen set type. The set type is
multiple and the frozen set is immutable. We can run it. Let's see the result. We will create
another video to show you what's the difference between the set and the frozen set. Let's run it
Okay, create the set object, create the frozen set, and the first one type is set. The second one is
the frozen set. Okay, besides the set, there is a built-in datatype. We set this x4 to false
and then print the type and its value. Yes, the type of the variable is 4 for lin and its value is false. Okay, and this is the last
example. It shows the built-in binary datatype. This is a binary string. Add v before the string
and the byte array datatype which is created by a byte array and the memory view. The memory view
is something like a pointer in programming language C or C++. You can run it to see the result
Okay, first create a binary string and create a byte array. Then, create a memory view
The binary string is a bytes object and its value is binary world and the byte array is a byte array
and this is the content and inside it is an empty byte array
And this is the memory view. It's just a memory address. Okay, all this for this video. You are welcome to subscribe to my channel
and I will create more Python programming videos for you. Bye-bye