Python Lists

Let’s Analyze Your Data With Python

Lists

Try It: Make Your Own Lists

🎯 Checkpoint 5. a: Storing Data as Lists

Replace the ??, ??, ??, and ?? placeholders with the nitrate and nitrite readings from your group!

Click the ▶️ Run Code button to run the block.




Basic Operations with Lists


Once we have a list, we can do all kinds of things with it!

🎯 Checkpoint 5. b: Basic Functions with Lists!

Click the ▶️ Run Code button to run the blocks.

len()

The len() (length) function tells us how many items are in a list. We can use it to find the number of nitrate readings we took.

min()

The min() function finds the smallest number in a list. It will tell us what the lowest nitrate reading was.

max()

The max() function finds the biggest number in a list. It will tell us what the highest nitrate reading was.

In Summary:
- len() = length (how many items)
- min() = minimum (smallest number)
- max() = maximum (biggest number)

These are called functions - they’re like tools that do specific jobs!


Checking If Water Is Safe

🎯 Checkpoint 5. c: Making Comparisons—EPA Limits

Let’s use Python to check if water is safe. We can tell Python the maximum EPA-allowed concentration of nitrate and have it compare the maximum nitrate reading with that cut-off.

Replace the ?? placeholder with the EPA limit for nitrate!

Click the ▶️ Run Code button to run the blocks.




Key Python Terms We Learned

Word What It Does Example
list Stores multiple numbers [7.2, 7.1, 7.3]
len() Counts items len([1,2,3]) = 3
min() Finds smallest min([5,2,8]) = 2
max() Finds biggest max([5,2,8]) = 8
print() Shows results print("Hi!")
if Makes decisions if pH > 7:

Remember: The best way to learn is by trying things! Change numbers, experiment, and see what happens. You can’t break anything! 😊