Please answer in python coding L10-01) (10 points) Write a program to read the rainfall.txt file and then write out a n

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Please answer in python coding L10-01) (10 points) Write a program to read the rainfall.txt file and then write out a n

Post by answerhappygod »

Please answer in python coding
L10-01) (10 points)
Write a program to read the rainfall.txt file and then write out
a new file called rainfallfmt.txt The new file should format each
line so that the city is right-justified in a field that is 25
characters wide, and the rainfall data should be printed in a field
that is 5 characters wide with 1 digit to the right of the decimal
point., e.g.
If rainfall.txt contains:
Akron 25.81
Albia 37.65
Algona 30.69
Allison 33.64
Alton 27.43
...
rainfallfmt.txt should contain:
Akron 25.8
Albia 37.6
Algona 30.7
Allison 33.6
Alton
27.4
AmesW 34.1
AmesSE 34.0
Anamosa 35.3
Ankeny 33.4
Atlantic 34.8
Audubon 33.4
Beaconsfield 35.3
...
L10-02) (10 points)
Write a function that writes a temperature conversion table
called tempconv.txt. The table should
include temperatures from -300 to 212 degrees Fahrenheit and their
Celsius equivalents, presented in two columns with appropriate
headings. Each column should be 10 characters wide, and each
temperature should have 3 digits to the right of the decimal point,
e.g.
File tempconv.txt should contain:
Fahrenheit Celsius
-300.000
-184.444
-299.000
-183.889
-298.000
-183.333
-297.000
-182.778
-296.000
-182.222
-295.000
-181.667
... ...
L10-03) (2 points)
Open the rainfall.txt file during a
Python interactive session. Call the readline method
twice on that file, then call the readlines method.
What lines does the list returned by readlines include?
L10-04) (3 points)
Open the file in L10-03 in the
interactive Python session again, but call readlines
immediately. Compare the lines returned in this
exercise with the previous one.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply