0% found this document useful (0 votes)
48 views

Lecture On Python Types.

Python uses different data types like integers, floats, strings, lists and dictionaries to store different kinds of data. The type() function allows you to check the type of a Python variable. The document demonstrates using type() to check that a string variable is type 'str' and an integer variable is type 'int'. A variable's type determines what operations can be done on that data.

Uploaded by

Methyl Orange
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Lecture On Python Types.

Python uses different data types like integers, floats, strings, lists and dictionaries to store different kinds of data. The type() function allows you to check the type of a Python variable. The document demonstrates using type() to check that a string variable is type 'str' and an integer variable is type 'int'. A variable's type determines what operations can be done on that data.

Uploaded by

Methyl Orange
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Lecture Topic: TYPES

Python equips us with many different ways to store data. A float is a different kind
of number from an int, and we store different data in a list than we do in a dict.
These are known as different types. We can check the type of a Python variable
using the type() function.

a_string = "Cool String"


an_int = 12

print(type(a_string))
# prints "<class 'str'>"

print(type(an_int))
# prints "<class 'int'>"

Above, we defined two variables and checked the type of these two variables. A
variable’s type determines what you can do with it and how you can use it. You
can’t. get () something from an integer, just as you can’t add two dictionaries
together using +. This is because those operations are defined at the type level.

Comments:
So type command is used to know the type of data of variables.
For example, if we have defined the following variables as integer, dictionary or
list we can know the type of our data by using the following code:

a_int = 5
print(type(a_int))

my_dict = {}
print(type(my_dict))

my_list = []
print(type(my_list))

You might also like