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
WHO LOVES THE KREW LOOK IT UP ON YOU_TUBE IF UR NOT SURE BUT PLZ SUBSCRIBE TO HER SHE DA BEST "YOOT" the one with pink and golde
kodGreya [7K]

Answer:

i like her mate :3 glad im not alone!

Explanation:

7 0
3 years ago
Read 3 more answers
A(n) _____ is a flexible tool used to analyze data using reports that do not have a predetermined format.
Mandarinka [93]

Answer:

decision support system

Explanation:

4 0
3 years ago
How many panes can Pablo view in a spreadsheet if he chooses the split worksheet option?
ddd [48]
Pablo can be a minimum of two pains and a maximum of four panes in a split screen worksheet.
6 0
3 years ago
Read 2 more answers
Can file extension txt be used in other os
rodikova [14]
Yes, a text file with a .txt extension can be read by Linux/Unix/Mac as they are ASCII unformatted.
6 0
3 years ago
According to the video, what tasks do Carpenters commonly perform? Select four options. supervising Plumbers, Electricians, and
TiliK225 [7]

Answer:

Cutting, shaping, and fastening wood.

Installing rafters, joists, windows, and subflooring.

Setting hardwood floors.

Building kitchen cabinets.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Although the battery on your smartphone is fully charged, it drains quickly. In some instances when the phone shows that the bat
    12·1 answer
  • Write a MATLAB script using the quiver and contour commands to visualize the field and its divergence. Assume the region of inte
    12·1 answer
  • What is the meaning for science?
    14·1 answer
  • What describes the basic transaction data such as its date, purpose, and amount and includes cash receipts, canceled checks, inv
    13·1 answer
  • .in the array based list implementation of the ADT what is the worst case time efficiency of the remove method?
    6·1 answer
  • The assignment symbol can be combined with the arithmetic and concatenation operators to provide augmented assignment operations
    11·1 answer
  • What are the main components of a desktop PC and briefly describe their purposes.​
    14·1 answer
  • What is the best scenerio for
    11·2 answers
  • A _____ software system determines the steps needed to produce components and instructs the machines that do the work.
    15·1 answer
  • Mathematics and computer science share many concepts, such as recursion.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!