AI Computer Science Academy · Faisalabad

Python Programming

Average a column of text data

Task 53 of 56 Python Capstone: five small programs
All tasks
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.

Checks on this task:

  • Check 1

Track progress

0 of 56 tasks complete

Next task unlocks when every check passes.

Sign in to keep your code and certificates.

Next task (pass every check first)