## Course Content

1.

Python Variables

0 min

3 min

9

2.

The Print Function

4 min

3 min

0

3.

Numbers and Math in Python

0 min

1 min

0

4.

What is Machine Learning?

0 min

6 min

0

5.

Strings in Python

0 min

11 min

0

6.

Comments in Python

0 min

4 min

0

7.

Functions in Python

0 min

26 min

0

8.

String Formatting with F-Strings

0 min

3 min

0

9.

Conditionals, Booleans, and If Statements

0 min

12 min

0

10.

Intro to Python Lists

0 min

6 min

0

11.

Intro to Python Lists - Exercises

0 min

2 min

6

12.

Lists as a Sequence of Values

0 min

6 min

0

13.

Coming Soon...

0 min

1 min

0

- Save
- Run All Cells
- Clear All Output
- Runtime
- Download
- Difficulty Rating

## Loading Runtime

## Exercise 1

Make a list that contains exactly five integers - each as separate elements within the list.

Save the list to a variable called 'five_ints`

`[1, 2, 3, 4, 5]`

## List Generator Function

This isn't an exercise, just some code that will help you complete the later exercises.

The code cell below uses some code techniques (that we haven't talked about yet) to generate a random list of numbers. Each time you run the code cell a different list will be generated and saved to the variable `random_list`

Please run the code cell at least once before completing the rest of the exercises below. Don't stress out if the code in this code cell doesn't make sense to you.

```
[2, 5, 4, 6, 1, 10, 3, 10, 8, 3, 8, 8, 7, 3]
```

## Exercise 2 - Length of a List

Create a variable called `list_length`

and use the `len()`

function to store the number of items in `random_list`

to the variable `list_length`

.

`14`

## Exercise 3 - Sum of a list

Create a variable called `list_sum`

and use the `len()`

function to store the sum of all integers in `random_list`

to the variable `list_sum`

.

`78`

## Exercise 4 - Mean of a list

Write a function called `mean`

that takes in a list of numbers as an argument and returns the statistical mean of the passed-in list.

`5.571428571428571`

## Exercise 5 - Even or Odd Length?

Write a function called `even_odd`

that takes in a list. The function should calculate the length of the list and if the length is an odd number return the string `"odd"`

. If the length is an even number, the function should return the string `"even"`

.

`even`

## Exercise 6 - List Range

Write a function called `list_range`

that takes in a list of numbers as an argument and returns the difference between the highest value in the list and the lowest value in the list.

In other words, calculate the highest number in the list (the max) as well as the lowest number in the mist (the min) and then return the result of the maximum value minus the minimum value.

`9`