In [1]:

```
import this
```

In [2]:

```
my_list = ['hi', 'this', 'is', 'my', 'list']
for i,e in enumerate(my_list):
print(i, e)
```

In [3]:

```
x = range(10)
y = range(10, 20)
for xi, yi in zip(x, y):
print(xi, yi)
```

This allows you to avoid a `for`

loop when you don't want to type one out

In [5]:

```
powers = [xi ** 2 for xi in range(4)]
print(powers)
```

In [4]:

```
# make y = x^2 quickly
x = [1, 3, 10]
y = [xi ** 2 for xi in x]
for xi, yi in zip(x,y):
print(xi, yi)
```

In [6]:

```
# by convention, use _ to indicate we don't care about a variable
zeros = [0 for _ in range(4)]
print(zeros)
```

In [7]:

```
x = [4,3, 6, 1, 4]
mean_x = sum(x) / len(x)
delta_mean = [(xi - mean_x)**2 for xi in x]
var = sum(delta_mean) / (len(x) - 1)
print(var)
```

In [8]:

```
x = [4, 10, 11]
y = ['number of people', 'the number 10', 'another number']
#key: value
my_dict = {yi: xi for xi, yi in zip(x,y)}
print(my_dict)
```

You can simplify string formatting with f strings:

In [9]:

```
answer = 4
mean = -3
print(f'The answer is {answer} and the mean is {mean:.2f}')
```