|
|
## Common Data Types (Object types)
|
|
|
### Integer
|
|
|
```int``` - immutable
|
|
|
```python
|
|
|
my_int = 5
|
|
|
```
|
|
|
### Float
|
|
|
```float``` - immutable
|
|
|
```python
|
|
|
my_float = 5.0
|
|
|
```
|
|
|
### Boolean
|
|
|
```bool``` - immutable
|
|
|
```python
|
|
|
my_boolean = True
|
|
|
```
|
|
|
### List
|
|
|
```list``` - **mutable**
|
|
|
```python
|
|
|
my_list = [1, 2, 5.0, True]
|
|
|
```
|
|
|
### Set
|
|
|
```set``` - **mutable**
|
|
|
```python
|
|
|
my_set = {1, 2, 5.0, True}
|
|
|
```
|
|
|
### Dictionary
|
|
|
```dict``` - **mutable**
|
|
|
```python
|
|
|
my_dict = {1: 4, 2: 'b', 5.0: 2.0, True: False}
|
|
|
```
|
|
|
### Tuple
|
|
|
```tuple``` - **immutable**
|
|
|
```python
|
|
|
my_tuple = (1, 2, 5.0, True)
|
|
|
```
|
|
|
### String
|
|
|
```str``` - **immutable**
|
|
|
```python
|
|
|
my_string = 'hello'
|
|
|
```
|
|
|
|
|
|
## Flow Control
|
|
|
Example:
|
|
|
```python
|
|
|
if x == 0:
|
|
|
print('zero')
|
|
|
elif x == 1:
|
|
|
print('one')
|
|
|
else:
|
|
|
print('neither nor')
|
|
|
```
|
|
|
|
|
|
```python
|
|
|
for element in my_list:
|
|
|
print(element)
|
|
|
```
|
|
|
|
|
|
```python
|
|
|
while my_value < 10:
|
|
|
my_value += 1
|
|
|
``` |