1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kenny6666 [7]
3 years ago
14

Write a program that will take a file named Celsius.dat that contains a list of temperatures in Celsius (one per line), and will

create a file Fahrenheit.dat that contains the same temperatures (one per line, in the same order) in Fahrenheit. Note: You may create Celsius.dat using a word processor or any other text editor rather than writing Python code to create the file. It simply needs to be a text file.
Computers and Technology
1 answer:
dedylja [7]3 years ago
5 0

Answer:

celciusFile=open("celcius.dat","r")

fahrenheitFile=open("fahrenheit.dat","w")

# Iterate over each line in the file

for line in celciusFile.readlines():

# Calculate the  fahrenheit

   fahrenheit = 9.0 / 5.0 * float(line) + 32

#write the  Fahrenheit values to the  Fahrenheit file

   fahrenheitFile.write("%.1f\n" % fahrenheit)

# Release used resources

celciusFile.close()

fahrenheitFile.close()

Explanation:

<em></em>

<em>celciusFile=open("celcius.dat","r") </em>

<em>fahrenheitFile=open("fahrenheit.dat","w") </em>

open the Celsius file in the read mode and assign it to a variable.

open the  Fahrenheit file in the write mode and assign it to a variable.

read mode means you can only use/read the content in the file but cannot alter it.

write mode means you can write new data to the file.

<em> </em>

<em />

  • <em># Iterate over each line in the file </em>

<em>for line in celciusFile.readlines(): </em>

The values contained in the Celsius file are collected.

  • <em># Calculate the  fahrenheit </em>

<em>    fahrenheit = 9.0 / 5.0 * float(line) + 32 </em>

The values are then converted to Fahrenheit.

  • <em>#write the  Fahrenheit values to the  Fahrenheit file</em>

<em>    fahrenheitFile.write("%.1f\n" % fahrenheit) </em>

The Fahrenheit values are written to the  Fahrenheit file

<em>%.1f</em><em>  is used to specify the number of digits after decimal. and </em><em>\n </em><em>adds a new line.</em>

<em />

  • <em># Release used resources </em>

<em>celciusFile.close() </em>

<em>fahrenheitFile.close() </em>

All files are closed

<em />

You might be interested in
What kind of sampling does a quasi experiment use?
Andrej [43]
A quasi experiment does not use completely randomized sampling where every participant in a certain sample would be allocated completely by chance and would have the same chance of becoming the member of a sample. Rather, quasi experiments have selective sampling where participants have been allocated to a certain sample by a certain criteria which makes the sample not completely random. 
5 0
4 years ago
Please help me asapppp!​
pychu [463]

of which class is this question

6 0
3 years ago
Read 2 more answers
Online banking tools allow you to pay bills from your computer. <br> a. True<br> b. False
Vaselesa [24]
On your online bank you can add bills from your computer. 
5 0
3 years ago
Read 2 more answers
This career applies mathematical and theoretical knowledge in order to compare and produce computational solutions.
ipn [44]

Answer:

Why does love.com redirect to Verizon.

Explanation:

4 0
3 years ago
Read 2 more answers
Why can't I register for Brainly?? I've been trying for months, too! I've noticed this question has been asked so many times, bu
Alenkasestr [34]

Answer:

Just click view profile and go to preferences

Heres a screenshot :

4 0
3 years ago
Other questions:
  • Side mirror using convex mirror or concave mirror?​
    5·2 answers
  • Which of the following statements will assign the contents of the Text property of a Textbox control named txtInput into the Tex
    10·1 answer
  • A video-streaming Web site uses 32-bit integers to count the number of times each video has been played. In anticipation of some
    11·1 answer
  • "Packet switches have multiple links attached to them. For each attached link the packet switch has a/an ____________, which sto
    7·1 answer
  • Quiero borrar mi cuenta como le hago ?
    6·1 answer
  • In a singing competition, there are 34 more men than women
    5·2 answers
  • Jeremy is working with a team that is creating an application using attributes and associated methods. What type of programming
    8·1 answer
  • What is the output?<br> &gt;&gt;&gt; password = "sdf#_356"<br> &gt;&gt;&gt; password.isalnum()
    8·2 answers
  • Read a sentence from the console.
    6·1 answer
  • Which attributes does not come in tag?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!