Data Types in Python

From Interaction Station Wiki
Jump to navigation Jump to search

Variables can store data of different types, and different types can do different things.

Python has the following data types built-in by default, in these categories:

Text Type: str
x = "Hello World"
Numeric Types:	int, float, complex
int: x = 20 	float: x = 20.5   complex: x = 1j
Sequence Types: list, tuple, range
x = ["apple", "banana", "cherry"]	list	
x = ("apple", "banana", "cherry")	tuple	
x = range(6)	range

Mapping Type:	dict
x = {"name" : "John", "age" : 36}
Set Types: set, frozenset
x = {"apple", "banana", "cherry"}
Boolean Type:bool
x = True   
Binary Types:	bytes, bytearray, memoryview
x = b"Hello"	 x = bytearray(5)    x = memoryview(bytes(5))
None Type:	NoneType
x = None

Screenshot 2024-09-03 at 16.14.36.png