You can check what kind of variable you are dealing with using the function type().
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# Creating variables in python # Creating an Integer variable intValue = 4 # Creating a Float variable floatValue = 1.5 # Creating a long variable longValue = 121212121212121212121212121212121212121212121212121212121212121 # Creating a complex variable complexValue = 1j # Creating a float variable floatValue1 = 1/3 # Creating a Boolean variable falseCondition = False trueCondition = True # Creating a string variable # you can use single, double or triple quotes for creating string variables strValue1='Hello Python!' strValue2="hello Python!" strValue3='''Hello Python again!''' |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
# type() function will print the datatype of any variable # Every variable is a child of a parent datatype (data class) print(type(intValue)) print(type(floatValue)) print(type(complexValue)) print(type(falseCondition)) print(type(strValue2)) |
Sample Output:

Author Details
Lead Data Scientist
Farukh is an innovator in solving industry problems using Artificial intelligence. His expertise is backed with 10 years of industry experience. Being a senior data scientist he is responsible for designing the AI/ML solution to provide maximum gains for the clients. As a thought leader, his focus is on solving the key business problems of the CPG Industry. He has worked across different domains like Telecom, Insurance, and Logistics. He has worked with global tech leaders including Infosys, IBM, and Persistent systems. His passion to teach inspired him to create this website!
