> For the complete documentation index, see [llms.txt](https://www.pythonclassroom.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pythonclassroom.com/lists/lists-numbers/lists-strings-problems.md). Agents can also search and read this documentation through its [MCP server](https://www.pythonclassroom.com/~gitbook/mcp).

# Problems

## Problem 1

Create a list named sales. Use a loop to ask the user to enter a store’s sales for 7 days.&#x20;

Print the total amount of sales.

### Sample Output

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-M7-JXDw7_tzIErpphiz%2F-M7-JZEFUqFOoQDL3aCp%2Fimage.png?alt=media\&token=762d24f6-5cd8-4739-a55a-f8d7abaf1a1b)

## Problem 2

Create a list named steps. Use a loop to ask the user to enter the number of steps they walk for 5 days.  Print the highest, lowest and average number of steps.

### Sample Output

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-M7-JXDw7_tzIErpphiz%2F-M7-KaMCaAXLEmAJU8p7%2Fimage.png?alt=media\&token=98af44e5-42aa-49a3-917f-5fdd8a4427e3)

## Problem 3

Create a list of 5 numbers that contains positive and negative numbers.  Print the list.  Delete all of the negative numbers. Print the list again.

### Sample Output

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-M7-Q6B6Gdl_oe5KlalI%2F-M7-QdaeyDsx0twhqYSp%2Fimage.png?alt=media\&token=2c459a1a-4868-484d-b440-dc6c730f4e64)

## Problem 4

Create a list of 5 numbers. Print the list.  Sort the numbers.  Swap the values of the first and last numbers. Print the list.

{% hint style="warning" %}
Do not hard code the last element with list\[4]
{% endhint %}

### Sample Output

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-M7-Q6B6Gdl_oe5KlalI%2F-M7-RIj7BZur0KWeHegl%2Fimage.png?alt=media\&token=3c39f0eb-89a9-4e5f-8b3e-cd6e34bf7ea4)

## Problem 5

Create a list of 5 numbers. Print the list.  Print the position of the largest element.

{% hint style="warning" %}
Do not hard code the solution.  Your solution should work for any list.
{% endhint %}

### Sample Output

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-M7-Q6B6Gdl_oe5KlalI%2F-M7-S4zlXRhHP_kjdE2c%2Fimage.png?alt=media\&token=b7b2f04e-65b9-4a1e-b8ff-8c7db1988304)

## Problem 6

Create a list named grades with 5 grades.  Print the list.  Print the average of the grades.

Sometimes teachers like to drop a student’s lowest grade. Delete the lowest grade and print the new average.

What's the difference between the new average and the original average?

### Sample Output

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-M7-S7NcJG4EYmd455oT%2F-M7-TLllPg3zIyGGPdaX%2Fimage.png?alt=media\&token=d53687ef-6937-430e-9061-2b871d348b7b)

## Problem 7

Create a list of 10 positive and negative numbers.  Print the list.  Print the sum of the positive numbers and the sum of the negative numbers.

### Sample Output

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-M7-S7NcJG4EYmd455oT%2F-M7-Ufj_EbPd5OvrA7mS%2Fimage.png?alt=media\&token=a40b5678-fb22-4c62-9eee-ca00d32295ad)

## Problem 8

Create a list of 10 positive and negative numbers. Print the number of the positive numbers, number of the negative numbers and the number of 0's.

### Sample Output

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-M7-S7NcJG4EYmd455oT%2F-M7-WDdFo8DDpfqV9SSI%2Fimage.png?alt=media\&token=920b0d02-538c-4df4-a3be-a9533c6d13b0)

## Problem 9

Create a list of 10 positive and negative numbers. Print the average of the positive numbers and average of the negative numbers.

### Sample Output

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-M7-S7NcJG4EYmd455oT%2F-M7-V6alvq_tFWzzDhZI%2Fimage.png?alt=media\&token=7edf5506-71bd-43e4-b5a9-42797a2317f3)

## Problem 10

Create a list of 10 numbers that contains positive and negative numbers.  Print the list.  Print the number of odd numbers, even numbers and zeros.

{% hint style="info" %}
0 is an even number
{% endhint %}

### Sample Output

![](https://729613953-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVVKHMnpflHwghmbdgi%2F-M7-XM5muS-x0LgB9Y4f%2F-M70Wcvw-6e13eJsxe9J%2Fimage.png?alt=media\&token=5a987262-f555-4956-a704-54f59d908855)

## Problem 11 (Challenge)

The interquartile range (IQR) is a measure of variability, based on dividing a data set into quartiles.

Quartiles divide a rank-ordered data set into four equal parts. The values that divide each part are called the first, second, and third quartiles; and they are denoted by Q1, Q2, and Q3, respectively.

Q1 is the "middle" value in the first half of the rank-ordered data set. Q2 is the median value in the set. Q3 is the "middle" value in the second half of the rank-ordered data set. The interquartile range is equal to Q3 minus Q1.

For example, consider the following numbers: 1, 3, 4, 5, 5, 6, 7, 11. Q1 is the middle value in the first half of the data set. Since there are an even number of data points in the first half of the data set, the middle value is the average of the two middle values; that is, Q1 = (3 + 4)/2 or Q1 = 3.5. Q3 is the middle value in the second half of the data set. Again, since the second half of the data set has an even number of observations, the middle value is the average of the two middle values; that is, Q3 = (6 + 7)/2 or Q3 = 6.5. The interquartile range is Q3 minus Q1, so IQR = 6.5 - 3.5 = 3.

Create a list of 10 numbers. Find the IQR. Create a list of 11 numbers. Find the IQR. How do your methods differ.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.pythonclassroom.com/lists/lists-numbers/lists-strings-problems.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
