Lesson Summary - Python Review (for Huy)
Hi Huy! You were absent today, so here's a summary of what we covered in Python class.
Make sure to review this and try the practice task at the end. Let me know if you have questions!
What We Learned Today
1. Lists and .append()
- We learned how to store multiple values using a list.
- Example:
scores = []
score = int(input('Enter score: '))
[Link](score)
- .append() adds new items to the list.
2. Looping Through Lists
- We used a for loop to go through every item in a list:
for score in scores:
print(score)
3. Built-in Functions for Lists
- len() -> counts how many items
- sum() -> adds all numbers
- max() / min() -> finds the biggest / smallest
average = sum(scores) / len(scores)
4. Pass/Fail Logic
- We used an if inside the loop to check if a score was a pass (>= 50):
if score >= 50:
print('Passed')
else:
print('Failed')
5. Counting How Many Passed or Failed
- We used counters to keep track:
passed = 0
failed = 0
for score in scores:
if score >= 50:
passed += 1
else:
failed += 1
Homework:
Write a program that:
1. Asks for 6 student scores
2. Stores them in a list
3. Prints:
- All scores
- Highest & lowest score
- Average
- How many passed (score >= 50)
- How many failed (score < 50)
Bonus: If everyone passed, print 'Excellent class!'
Let me know when you're done so I can check it for you.
We missed you today! Looking forward to seeing you in the next class!