Class 03 Data Types (int, bool, float, string)
Class 03 Data Types (int, bool, float, string)
PYTHON
DATA TYPES
3
What is Data Type?
Yeasir Arafat Ratul
MILK DRINKS
Data Types of Python
Yeasir Arafat Ratul
Numbers Collection
Integers Float
In Python 3, there is effectively no limit to how long an integer value can be. Of course, it is constrained by
the amount of memory your system has, as are all things, but beyond that an integer can be as long as you
need it to be.
int() function returns a floating point number from a float number or string.
>>> float(3)
3.0
>>> float('2')
2.0
>>> float('x')
Traceback (most recent call last):
File "<pyshell#29>", line 1, in <module>
float('x')
ValueError: could not convert string to float: 'x'
String
Yeasir Arafat Ratul
a = ‘R’
b = “Python”
There are a lot of functions in python used for manipulating functions in different ways.
More: https://www.w3schools.com/python/python_ref_string.asp
String Formatting
Yeasir Arafat Ratul
string = ‘CONGRATULATIONS’
string = C O N G R A T U L A T I O N S
Forward Indexing 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Backward Indexing -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
string = ‘CONGRATULATIONS’
string = C O N G R A T U L A T I O N S
Forward Indexing 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Backward Indexing -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
>>> len(string)
15
>>> string[0:15]
'CONGRATULATIONS’
>>> string[0:13]
'CONGRATULATIO'
strip(), split()
Yeasir Arafat Ratul
rjust/ljust/center(width, filcher = ‘ ’)
THANK YOU
LIKE | COMMENT | SUBSCRIBE