-
Notifications
You must be signed in to change notification settings - Fork 0
Python Tips & Tricks
Joey Kleiner edited this page Dec 13, 2022
·
34 revisions
Data Types:
| Example | ||
|---|---|---|
| Text Type: | str | “Hello World” |
| Numeric Types: | int, float, complex | 20, 99.142, (10+7j) |
| Sequence Types: | list, tuple, range | [1, 2, 3], (1, 2, 3), range(6) |
| Mapping Type: | dict {key:value} | {"name" : "John", "age" : 35} |
| Set Types: | set, frozenset | {"apple", "banana", "cherry"}, frozenset({"apple", "banana", "cherry"}) |
| Boolean Type: | bool | True or False |
| Binary Types: | bytes, bytearray, memoryview | b"Hello", bytearray(5), memoryview(bytes(5)) |
| None Type: | NoneType | None |
print()iterate over key-value pairs using list comprehension to print line by line
[print(key,':',value) for key, value in state.items()]