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
sveticcg [70]
3 years ago
12

Write a Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom fu

nctions, f_to_c and c_to_f, to perform the conversions. Both of these functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter. It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places. Custom function f_to_c should be a value-returning function defined to take a Fahrenheit temperature as a parameter. This function should calculate the equivalent Celsius temperature and return it. In the main function, your program should:
Computers and Technology
1 answer:
Klio2033 [76]3 years ago
4 0

A Python program that can convert a Fahrenheit temperature to Celsius, or vice versa. The program should use two custom functions, f_to_c and c_to_f, to perform the conversions.

Explanation:

  • Functions should be defined in a custom module named temps. Custom function c_to_f should be a void function defined to take a Celsius temperature as a parameter.
  • It should calculate and print the equivalent Fahrenheit temperature accurate to three decimal places.
  • Custom function f_to_c should be a value-returning function defined to take a Fahrenheit temperature as a parameter.
  • This function should calculate the equivalent Celsius temperature and return it.

The code is given below :

def c_to_f(tempCelsius):

  tempFahrenheit = ((9/5)*tempCelsius) + 32;

  print("\n %.3f Celsius is %.3f Fahrenheit \n" %(tempCelsius, tempFahrenheit));

def f_to_c(tempFahrenheit):

  tempCelsius = (tempFahrenheit - 32) * (5/9);

  return tempCelsius;

(Import modules)

import temps;  

def main():

  temperature = float(input("\n Enter a temperature: "));

  scale = input("\n Was that input Fahrenheit or Celsius c/f? ");

  if scale.lower() == 'c':

      temps.c_to_f(temperature);

  else:

 tempCel = temps.f_to_c(temperature);

      print("\n %.1f Fahrenheit equals %.3f Celsius \n" %(temperature, tempCel));

main();

You might be interested in
You created the following dictionary relationships = {'Jimmy':'brother', 'Carol':'sister'}. You then executed the following code
dybincka [34]

Answer:

This is because the key in relationships['jimmy'] is wrong. The first letter "j" should be uppercase. The key in the given dictionary is "Jimmy" and therefore a lowercase "j" will result in a KeyError exception. The key is case sensitive and therefore a minor mistake in a single letter either in lowercase or uppercase will cause the error. The correct usage of key to address the value should be relationships["Jimmy"].

3 0
4 years ago
What part of a computer is the most important?
Nikitich [7]
The CPU is the most important. It is the brains of the Computer.
3 0
3 years ago
Read 2 more answers
What is a flowchart​
serious [3.7K]

a diagram of the sequence of movements or actions of people or things involved in a complex system or activity.

4 0
3 years ago
In which type of market do farmers sell their produce directly to village traders in rural areas?
Anna007 [38]

Answer:

Local Market or Primary Market.

Explanation:

The farmers sell their products to big traders in the bigger market in the urban areas. However, they also sell a part of their products to various village traders, who are located in the rural areas and can be found in local or primary markets. It's not so that they are not useful as well, as small farmers, in fact, sell the whole of their produce in the local or primary market as we know them by name. And the farmer gets a reasonable return there as well.

8 0
4 years ago
How did mechanical clocks assist in completing work? How was work done previously?
lozanna [386]

Answer

Timekeeping has been a part of society since Ancient Egypt. The use of spring-powered mechanisms allowed clocks to be made smaller ... Essentially, the church bells and the mechanical clock now became the monitor of the working day.

Explanation:

4 0
3 years ago
Other questions:
  • Which statement describes the word "iterative"?
    7·2 answers
  • In three to five sentences, describe how technology helps business professionals to be more efficient. Include examples of hardw
    10·1 answer
  • Which encryption standard goes with the WPA2 protocol?<br> AES<br> DES<br> TKIP<br> WPS
    10·1 answer
  • In terms of object-oriented programming, after a class is defined,
    11·1 answer
  • What type of account provides the same functions as managed service accounts but can be managed across multiple servers as in a
    8·1 answer
  • Use the_____icon to insert a new record.<br><br> A. *<br> B. X<br> C. =<br> D. &amp;
    11·1 answer
  • Hi All,
    12·2 answers
  • Hi<br>is it right?<br>"I think there is a small mistake in the quotation(second not first)"​
    5·1 answer
  • Where are 'if' and 'else' statements shown when printing a document in a word processor?
    8·1 answer
  • When designers follow accepted standards and protocols, which of the four basic characteristics of network architecture is achie
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!