References:

- Fundamentals of Python Programming. Halterman, Richard. Southern Adventist Univesity. 2018.

There are two modes when a cell is highlighted.

- create a new cell above the current cell: a
- create a new cell below the current cell: b
- delete the current cell: dd
- change the current cell’s type to “Code”: y
- change the current cell’s type to “Markdown”: m

- execute the current cell and create a new cell: SHIFT + ENTER

In [ ]:

```
```

In [ ]:

```
```

`lst = [20, 1, -34, 40, -8, 60, 1, 3]`

evaluate the following expressions. Write your answers in markdown first then use code to verify your answer.¶- lst[0:3]
- lst[4:8]
- lst[-5:-3]
- lst[4:]
- lst[:]
- lst[:4]
- lst[1:5]
- -34 in lst
- -34 not in lst
- len(lst)

- [2,3,4,5]
- [1,3,5,7]
- [1,2,3,4,5,6] (use negative indices for this problem)
- [1,2,3,4,5,6,7,8]
- [8,7,6,5,4,3,2,1]
- [6,5,4,3]

In [ ]:

```
```

1) Then use a for loop to append to the list the multiples of 3 from 12 to 2340. Print out the length of this list.

2) Redo part 1) of this problem but use list comprehensions instead of a for loop.

3) Use list comprehension as in part 2) but add in the additional condition that the numbers need to be a multiple of 7.

In [ ]:

```
```

`list()`

and the `range()`

function to create a list of even numbers from 2 to 50.¶In [ ]:

```
```

`sum`

to find the sum of a list created in the previous problem.¶In [ ]:

```
```

- [x + 1 for x in [2, 4, 6, 8]]
- [10*x for x in range(5, 10)]
- [x for x in range(10, 21) if x % 3 == 0]

In [ ]:

```
```

`n`

. Use list comprehension to create a list `factors`

which is a list of factors of `n`

.¶In [ ]:

```
```

`n`

? (Pretty cool!)¶```
[x for x in range(2, n) if n % x == 0] == []
```

One sample output:

```
Mike 2.3
John 3.5
Michele 3.7
Carol 3.2
```

In [ ]:

```
```