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

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,...
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.
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 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...
PYTHON PYTHON Recursive Functions. In this problem, you are asked to write three recursive functions. Implement...
PYTHON PYTHON Recursive Functions. In this problem, you are asked to write three recursive functions. Implement all functions in a module called problem1.py. (10 points) Write a recursive function called remove char with two parameters: a string astr and a character ch. The function returns a string in which all occurrences of ch in astr are removed. For example, remove char("object oriented", ’e’) returns the string "objct orintd". Your implementation should not contain any loops and may use only 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...
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...
Write a Python script that takes an input image and output's the name of the dominant...
Write a Python script that takes an input image and output's the name of the dominant color in that image(i.e. red, green, blue).  
Write a Flask app in which a Python script prompts the user to enter a string...
Write a Flask app in which a Python script prompts the user to enter a string and then that string, as entered, gets displayed on an otherwise blank HTML file, called output.html. Show the Python/Flask code and the html code of the output.html file, one below the other as part of your answer.
The school bookstore wants you to write a Python script to calculate the point of sale...
The school bookstore wants you to write a Python script to calculate the point of sale (total cost) of their new 25$ gift cards. They are also running a special, if a customer buys a gift card they can buy all books for 5$ dollars each. The gift card cost is $25.00 plus $5.00 per book. In addition, there is a sales tax which should be applied to the subtotal and it is 8% (multiply the subtotal by 0.08.) Requirements:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT