Read first
Task 53
Average a column of text data
Real data arrives as text. Split each line on the comma, take the number, turn it into an int, and only then do the arithmetic.
Task
Task: Average a column of text data. What does this program print?
The editor already contains a starting point. Change it until every check passes — the Next task button unlocks when it does.
What you start with
rows = ["Ali,850", "Sara,920", "Hina,780"]
total = 0
for row in rows:
name, marks = row.split(",")
total = total + int(marks)
average = total / len(rows)
print("Students:", len(rows))
print("Average:", round(average, 1))
Python
1 automatic check Capstone: five small programs
Code editor
Ctrl + Enter runs
Run your code to see the output and the checks.
Your result
Submit your code to see results
Write your code in the middle column and press Run code.
Next task (pass every check first)
Hint
Ask yourself: Task: Average a column of text data. What does this program print?