Python Blogs
Data type in Python
- Fundamental data type
- Collection data type
Strings - used to represent text data, the text is given under quote marks. eg:"ABCD"
Eg:
x="ABCD"
print(x)
print(type(x))
Output:
ABCD
<class 'str'>
NOTE:-
The type function either returns the type of the object or returns a new type object based on the arguments passed.
The type function either returns the type of the object or returns a new type object based on the arguments passed.
- Integer - used to represent integer numbers. eg. 1, 2, 3
Eg:
x=1000
print(x)
print(type(x))
Output:
1000
<class 'int'>
Eg:- Float - used to represent real numbers. eg. 1.2, 42.42
x=123.123
print(x)
print(type(x)
Output:
123.123
<class 'float'>
- Boolean - used to represent True or False.
Eg:
x=True
print(x)
print(type(x))
Output:
True
<class 'bool'>
Eg:- Complex - used to represent a number in complex plain. eg. 1.0 + 2.0j, 1.5 + 2.5j
x=3+4j
print(x)
print(type(x))
Output:
(3+4j)
<class 'complex'>
Post a Comment
0 Comments