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
The function below takes a single string parameter: sentence. Complete the function to return everything but the middle 10 chara
dolphi86 [110]

Answer:

def get_middle_ten(sentence):

   ind = (len(sentence) - 12) // 2

   return sentence[ind:ind + 12]

# Testing the function here. ignore/remove the code below if not required

print(get_middle_twelve("abcdefghijkl"))

print(get_middle_twelve("abcdefghijklmnopqr"))

print(get_middle_twelve("abcdefghijklmnopqrst"))

7 0
3 years ago
PLEASE HELP!!! What are the benefits of online notebooks? Check all that apply.
Kipish [7]

They allow users to store files.

They allow users to share files.

They help users organize assignments.

They allow users to clip information from web pages.

4 0
3 years ago
Read 2 more answers
What are the reason of making computer virus.​
GenaCL600 [577]

Answer:

Some computer experts create computer viruses to prove certain a process will work

Explanation:

6 0
2 years ago
Read 2 more answers
What will happen if you type pseudocode in another language's programming environment and try to run the
wariber [46]

Answer:

You will get compile error

Explanation:

7 0
3 years ago
Saving a file as a new filename can be accomplished through the Save As dialog box? True<br> False
aliina [53]
Your answer would be true, (brainliest answer please)
7 0
3 years ago
Other questions:
  • There are many modes of remote visual communication. Which is the most common mode?
    10·2 answers
  • Janelle is shopping for jeans from Express. She clicks on a style she likes. The site quickly presents her with a close-up view
    5·1 answer
  • What career cluster does a fish and game warden fall in?
    14·1 answer
  • Weakness in software can be more quickly uncovered and exploited with new software tools and techniques.
    6·1 answer
  • PLEASE HELP ANSWER THIS only if you know BOTH ANSWERS!
    9·2 answers
  • Given a int variable named callsReceived and another int variable named operatorsOnCall write the necessary code to read values
    13·1 answer
  • When you open a browser window, it open in a _____. <br> a. fieldb. folderc. menud. window?
    7·1 answer
  • How do you know where the home row of the keyboard is?
    14·2 answers
  • Which activity is the best example of a negative habit that may result from
    12·1 answer
  • What type of access controls allow the owner of a file to grant other users access to it using an access control list
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!