Question

You are a scientist studying the rainfall in the area. The file attached has a huge...

You are a scientist studying the rainfall in the area. The file attached has a huge list of rainfalls for the past year. Sum the values in the file and print out the result. Recall that you can convert strings to floats using the float function.

0
0
0
0
0
0
0.5
0
0
0
0
0
0.2
0
2.2
1.9
0
0
0
1.5
1.4
1.9
0
0
0.4
0
0
1.1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.7
0
0
0
0
0
0
0
0
0.4
0
0
0
0
0
0
0
0
0
1.5
0
0
0
0
0
0
0.9
0
0
0
1.4
0
2.0
2.1
0
0.2
0
0
0
0
0
0
0
0
0
0
0
1.9
1.7
0
0
0
0
0
0
0
2.9
2.8
2.9
2.6
2.4
2.5
2.6
0
0
0.8
0
1.7
1.6
0
0
0
1.6
1.9
0
0
1.0
0
0
0
0
2.8
2.6
0
0
2.3
1.6
0
0
4.1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.8
0
0
0
0
0
0.6
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.9
0
0
0
2.7
2.5
0
0
0
0.2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1.6
0
0
0
0
0
0
1.5
0
0
0
0
0
0
0
0
0
0
0
0
1.7
0
0
0
0
0
0
0
0
0.2
0
0
0
0
1.6
1.9
1.8
1.7
1.6
1.8
0
0
0
0
0
0
0
0
0
0
0
0
0.2
0
0
0
0
0
0
0
2.6
2.9
2.8
0
0
0
0
2.2
2.5
2.7
0
3.5
2.8
0
2.1
1.8
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.9
0
1.1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2.4
2.9
3.2
2.3
2.5
0
1.2
0
0
0
0
0
0
0
0
0
0
0
0
0
1.6
0
0
0
0.2
0
0
0.5
0
1.9
0
2.1
1.9
2.3
0
0
0
0
0
0.8
0
0
0
0
0
0
0
0
1.7
0
0
0

Close

python

0 0
Add a comment Improve this question Transcribed image text
Answer #1
filename = "rainfall.txt"

try:
    f = open(filename, 'r')
    total = 0
    for line in f:
        total += float(line.strip())
    print("Sum of all rainfall is", total)
    f.close()
except FileNotFoundError:
    print(filename + " does not exists!")
Add a comment
Know the answer?
Add Answer to:
You are a scientist studying the rainfall in the area. The file attached has a huge...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT