Added code for lecture 2026-11-10
This commit is contained in:
parent
5b630435ae
commit
07b9e54bf0
52 changed files with 1248 additions and 1 deletions
15
lecture20261110/lists/grades02.py
Normal file
15
lecture20261110/lists/grades02.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/python3
|
||||
# grades02
|
||||
# List element manipulation.
|
||||
|
||||
scores = [75, 95, 90, 87, 99, 100, 97, 100]
|
||||
|
||||
numberOfScores = len(scores)
|
||||
|
||||
# We will sum the scores. Initialize sum value to zero then add each value to the sum.
|
||||
sum = 0
|
||||
for score in scores:
|
||||
sum = sum + score
|
||||
|
||||
print(f"The sum of the {numberOfScores} scores is {sum:.2f}")
|
||||
print(f"The average of the {numberOfScores} scores is {sum/numberOfScores:.2f}")
|
||||
Loading…
Add table
Add a link
Reference in a new issue