Question

In: Computer Science

PYTHON: Write a script that imports the functions in the module below and uses all of...

PYTHON: Write a script that imports the functions in the module below and uses all of the functions.

import math

def _main():

    print("#" * 28, "\n", "Testing...1, 2, 3...testing!\n", "#" * 28, "\n", sep="")

    f = -200

    print("{:.2f} F is {:.2f} C".format(f, f2c(f)))

    f = 125

    print("{:.2f} F is {:.2f} C".format(f, f2c(f)))

    c = 0

    print("{:.2f} C is {:.2f} F".format(c, c2f(c)))

    c = -200

    print("{:.2f} C is {:.2f} F".format(c, c2f(c)))

def f2c(temp):

    #Converts Fahrenheit tempature to Celcius

    if temp < -459.67:

        return False

    c = (temp - 32) * (5 / 9)

    return c

def c2f(temp):

    #Converts Celcius to Fahrenheit

    if temp < -273.15:  

        return False

    f = (temp * 9 / 5) + 32

    return f

if __name__ == '__main__':

    _main()

Solutions

Expert Solution

Python code pasted below.

import math
def _main():
print("#" * 28, "\n", "Testing...1, 2, 3...testing!\n", "#" * 28, "\n", sep="")
f = -200
print("{:.2f} F is {:.2f} C".format(f, f2c(f)))
f = 125
print("{:.2f} F is {:.2f} C".format(f, f2c(f)))
c = 0
print("{:.2f} C is {:.2f} F".format(c, c2f(c)))
c = -200
print("{:.2f} C is {:.2f} F".format(c, c2f(c)))
def f2c(temp):
#Converts Fahrenheit tempature to Celcius
if temp < -459.67:
return False
c = (temp - 32) * (5 / 9)
return c
def c2f(temp):
#Converts Celcius to Fahrenheit
if temp < -273.15:
return False
f = (temp * 9 / 5) + 32
return f
if __name__ == '__main__':
_main()

Python code in IDLE pasted below for better understanding of the indent.

Output Screen


Related Solutions

Using Python write the following script as well as using comments By considering the details below,...
Using Python write the following script as well as using comments By considering the details below, write a class that will work out the body mass index for specific values of weight and height. The design of the actual class is shown below: bmi -weight:float -height:float -bmi:float +set_weight(weight:float) +set_height(height:float) +calc_bmi() +get_bmi():float specific designs of the methods are shown below: set_weight set the weight attribute to the value in the parameter weight set_height set the height attribute to the value in...
Write a Python module that contains functions to calculate the perimeter and area of at least 4 different geometric shapes.
Modules Assignment pythonWrite a Python module that contains functions to calculate the perimeter and area of at least 4 different geometric shapes.Write a separate Python program (in a separate file from you Python module) that imports your above module and uses several of its functions in your program. Make use of the input() and print() functions in this program file. Try to make your program as a real-world application.
How do I write a script for this in python in REPL or atom, NOT python...
How do I write a script for this in python in REPL or atom, NOT python shell Consider the following simple “community” in Python . . . triangle = [ ["top", [0, 1]], ["bottom-left", [0, 0]], ["bottom-right", [2, 0]], ] This is the calling of function. >>> nearestneighbor([0, 0.6], triangle, myeuclidean) 'top' The new point is (0, 0.6) and the distance function is Euclidean. Now let’s confirm this result . . . >>> myeuclidean([0, 0.6], [0, 1]) 0.4 >>> myeuclidean([0,...
I need to write these three functions in Python using turtle module. def line(t, coord1, coord2)...
I need to write these three functions in Python using turtle module. def line(t, coord1, coord2) t is a turtle object passed in coord1 and coord2 are 2-element lists that represent x, y coordinates draws a line from coord1 to cord2 def poly(t, *coords) t is a turtle object passed in *coords is any number of x, y coordinates each as a 2-element list draws a polygon based on coords (will close off polygon by drawing a line from last...
write a python script for rock scissors paper game
write a python script for rock scissors paper game
PYTHON: Complete these functions in the module: f2c, a function to convert Fahrenheit temperatures to Celcius....
PYTHON: Complete these functions in the module: f2c, a function to convert Fahrenheit temperatures to Celcius. c2f, a function to convert Celcius termperatures to Fahrenheit. Write f2c() and c2f() as functions that return a true value or False. In other words, these functions do not print — they return. A "true value", in this case, would be a number that corresponds to a temperature. If the user enters an invalid temperature, the function should return False. Create _main(), a function...
Write the following Python script: Imagine you live in a world without modules in Python! No...
Write the following Python script: Imagine you live in a world without modules in Python! No numpy! No scipy! Write a Python script that defines a function called mat_mult() that takes two lists of lists as parameters and, when possible, returns a list of lists representing the matrix product of the two inputs. Your function should make sure the lists are of the appropriate size first - if not, your program should print “Invalid sizes” and return None. Note: it...
Write the following Python script: Imagine you live in a world without modules in Python! No...
Write the following Python script: Imagine you live in a world without modules in Python! No numpy! No scipy! Write a Python script that defines a function called mat_mult() that takes two lists of lists as parameters and, when possible, returns a list of lists representing the matrix product of the two inputs. Your function should make sure the lists are of the appropriate size first - if not, your program should print “Invalid sizes” and return None. Note: it...
Write a program that uses the defined structure and all the above functions. Suppose that the...
Write a program that uses the defined structure and all the above functions. Suppose that the class has 20 students. Use an array of 20 components of type studentType. Other than declaring the variables and opening the input and output files, the function main should only be a collection of function calls. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the...
All functions are written in python Write a function cube_evens_lc(values) that takes as input a list...
All functions are written in python Write a function cube_evens_lc(values) that takes as input a list of numbers called values, and that uses a list comprehension to create and return a list containing the cubes of the even numbers in values (i.e., the even numbers raised to the third power). For example: >>> cube_evens_lc([2, 5, 6, 4, 1]) result: [8, 216, 64] This version of the function may not use recursion. Write a function cube_evens_rec(values) that takes as input a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT