All problems

The One-Line CSV

easyPythonData CleaningStrings

Bexley Metals receives each furnace's readings for the day as a single comma-separated line — the whole day arrives on one line of text rather than one reading per line. The shift report quotes the day's total and the day's average side by side, and the two are written to different precisions because the total is reported in whole tonnes while the average is reported to the nearest hundredth.

Task: Print the total and the mean of the readings on the line.

Input

One single line holding one or more numbers separated by commas, with no spaces anywhere around them. A number may carry a decimal point. There is no line saying how many readings to expect, and a line holding only one reading contains no comma at all.

Output

Two lines, total first. The first reads sum, one space, then the total with exactly one digit after the decimal point. The second reads mean, one space, then the mean with exactly two digits after the decimal point. Both labels are lowercase.

Example:

Input:
10,20,30,40

Output:
sum 100.0
mean 25.00

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…