Python Data Types
28 Admin
Data types are the classification or categorization of data items.Data types represent a kind of value which determines what operations can be performed on that data. Numeric, non-numeric and Boolean (true/false) data are the most used data types.
Python has the following standard or built-in data types:
Text Type: | str |
Numeric Types: | int , float , complex |
Sequence Types: | list , tuple , range |
Mapping Type: | dict |
Set Types: | set , frozenset |
Boolean Type: | bool |
Binary Types: | bytes , bytearray , memoryview |
In Python, the data type is set when you assign a value to a variable:
Example | Data Type | |
---|---|---|
x = “Welcome” | str | |
x = 14 | int | |
x = 21.5 | float | |
x = 4j | complex | |
x = [“monkey”, “dog”, “cow”] | list | |
x = (“orange”, “mango”, “apple”) | tuple | |
x = range(8) | range | |
x = {“name” : “Mohan”, “age” : 27} | dict | |
x = {“mango”, “apple”, “banana”} | set | |
x = frozenset({“sparrow”, “parrot”, “hen”}) | frozenset | |
x = True | bool | |
x = b”Welcome” | bytes | |
x = bytearray(6) | bytearray | |
x = memoryview(bytes(6)) | memoryview |
Recent Comments