Skip to content

Commit b480ed5

Browse files
committed
chore: What are Types?
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
1 parent fd2d70a commit b480ed5

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README_types.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## What are Types in Python?
2+
3+
Python code can be written using various built-in types that define their behavior and available operations:
4+
5+
- **Numeric Types**
6+
- `int`: whole numbers (e.g. `5`, `-100`)
7+
- `float`: decimal numbers (e.g. `3.14`, `-0.5`)
8+
- `complex`: numbers with real & imaginary parts (e.g. `2 + 3j`)
9+
10+
- **Boolean**
11+
- `bool`: truth values, `True` or `False`
12+
13+
- **Text**
14+
- `str`: immutable sequences of characters (e.g. `"hello"`)
15+
16+
- **Binary**
17+
- `bytes`: immutable byte sequences
18+
- `bytearray`: mutable byte sequences
19+
- `memoryview`: a view on another binary object
20+
21+
- **Sequences**
22+
- `list[T]`: mutable, ordered collections (e.g. `list[int]`)
23+
- `tuple[T1, T2, …]`: immutable ordered collections (e.g. `tuple[int, str]`)
24+
- `range`: immutable sequences of integers, typically used in loops
25+
26+
- **Mappings**
27+
- `dict[K, V]`: mutable key→value stores (e.g. `dict[str, float]`)
28+
29+
- **Sets**
30+
- `set[T]`: mutable, unordered unique items
31+
- `frozenset[T]`: immutable sets of unique items
32+
33+
- **None**
34+
- `None`: the singleton “no value” object (its type is `NoneType`).
35+
> _Note: `print()` always returns `None`. Functions return `None` unless an explicit `return` is provided._
36+
37+
---
38+
39+
### Example
40+
41+
x: int = 3
42+
y: float = 1.0
43+
frozen: bool = True
44+
name: str = "Rupert"
45+

0 commit comments

Comments
 (0)