Question

In: Computer Science

Python 3 Write the definition of a function that take one number, that represents a temperature...

Python 3

  1. Write the definition of a function that take one number, that represents a temperature in Fahrenheit and prints the equivalent temperature in degrees Celsius.
  2. Write the definition of another function that takes one number, that represents speed in miles/hour and prints the equivalent speed in meters/second.
  3. Write the definition of a function named main. It takes no input, hence empty parenthesis, and does the following:
    - prints Enter 1 to convert Fahrenheit temperature to Celsius
    - prints on the next line, Enter 2 to convert speed from miles per hour to meters per second.
    -take the input, lets call this main input, and if it is 1, get one input then call the function of step 1 and pass it the input.
    - if main input is 2, get one more input and call the function of step 2.
    - if main input is neither 1 or 2, print an error message.
  4. After you complete the definition of the function main, write a statement to call main.

Below is an example of how the code should look like:

#Sample Code by Student Name
#Created on Some Date
#Last Edit on Another Date

def func1(x):
print(x)
  
def func2(y):
print(y)
print(' ')
print(y)

def main():
func1('hello world')
func2('hello again')

#below we start all the action
main()

Remember to add comments, and that style and best practices will counts towards the points.
A program that just "works" is not a guarantee for full credit.

Solutions

Expert Solution

Program Code Screenshot:

Sample Output

Program Code to Copy

def func1(f):
#Convert Fahrenheit to Degrees
print(str(f)+'F is '+str((f-32)*100/180)+'C')

def func2(m):
#Convert miles to meter per second
print(str(m)+'miles per hour is '+str(m*1.6*5/18)+' meter per second')

def main():
print('Enter 1 to convert Fahrenheit temperature to Celsius')
print('Enter 2 to convert speed from miles per hour to meters per second')
#Prompt for choice
c = int(input())
if c is 1:
#Prompt for fahrenheit
f = float(input())
func1(f)
elif c is 2:
#Prompt for miles per hour
m = float(input())
func2(m)
else:
print('Invalid input')


main()


Related Solutions

Using Python 1. #Now, let's improve our steps() function to take one parameter #that represents the...
Using Python 1. #Now, let's improve our steps() function to take one parameter #that represents the number of 'steps' to print. It should #then return a string that, when printed, shows output like #the following: # #print(steps(3)) #111 #   222 #       333 # #print(steps(6)) #111 #   222 #       333 #           444 #               555 #                   666 # #Specifically, it should start with 1, and show three of each #number from...
Write a function in Python 3 (v. 6175+) called multiplicity00794. The function should receive alimit number...
Write a function in Python 3 (v. 6175+) called multiplicity00794. The function should receive alimit number and return: • how many multiples of 3 or 5 or 7 there are that are less than or equal to the specified limit. • the sum of the multiples of 3 or 5 or 7 that are less than or equal to the specified limit. • the product of the multiples of 3 or 5 or 7 that are less than or equal...
This is python: #Write a function called count_positive_evens. This function #should take as input a list...
This is python: #Write a function called count_positive_evens. This function #should take as input a list of integers, and return as #output a single integer. The number the function returns #should be the count of numbers from the list that were both #positive and even. # #For example: # # count_positive_evens([5, 7, 9, 8, -1, -2, -3]) -> 1 # count_positive_evens([2, 4, 6, 8, 10, 12, 15]) -> 6 # count_positive_evens([-2, -4, -6, -8, -10, 1]) -> 0 # #0...
PYTHON: Write a function insertInOrder that takes in a list and a number. This function should...
PYTHON: Write a function insertInOrder that takes in a list and a number. This function should assume that the list is already in ascending order. The function should insert the number into the correct position of the list so that the list stays in ascending order. It should modify the list, not build a new list. It does not need to return the list, because it is modifying it.   Hint: Use a whlie loop and list methods lst = [1,3,5,7]...
Python: Write a function that receives a one dimensional array of integers and returns a Python...
Python: Write a function that receives a one dimensional array of integers and returns a Python tuple with two values - minimum and maximum values in the input array. You may assume that the input array will contain only integers and will have at least one element. You do not need to check for those conditions. Restrictions: No built-in Python data structures are allowed (lists, dictionaries etc). OK to use a Python tuple to store and return the result. Below...
Write a python program that will take in the number of call minutes used. Your program...
Write a python program that will take in the number of call minutes used. Your program will calculate the amount of charge for the first 200 minutes with a rate of $0.25; the remaining minutes with a rate of $0.35. The tax amount is calculated as 13% on top of the total. The customer could have a credit that also has to be considered in the calculation process. Finally, the program displays all this information. Below is a sample run:...
USING PYTHON Write a program to create a number list. It will call a function to...
USING PYTHON Write a program to create a number list. It will call a function to calculate the average values in the list. Define main ():                        Declare variables and initialize them                        Create a list containing numbers (int/float)                        Call get_avg function that will return the calculated average values in the list.                                       Use a for loop to loop through the values in the list and calculate avg                        End main()
In Python Create a function called ????. The function receives a "string" that represents a year...
In Python Create a function called ????. The function receives a "string" that represents a year (the variable with this "String" will be called uve) and a list containing "strings" representing bank accounts (call this list ????). • Each account is represented by 8 characters. The format of each account number is "** - ** - **", where the asterisks are replaced by numeric characters. o For example, “59-04-23”. • The two central characters of the "string" of each account...
Python(please take a screen shot!): 1. hamming distance: write a function distance that take two bits...
Python(please take a screen shot!): 1. hamming distance: write a function distance that take two bits strings, you can assume each strings only contains 0's and 1's. (Note: the two strings might have the same length or not!) for example: hamming('010001001111', '01010100') should return 5(1 bit changed plus 4 bits "lost" from the end). 2. write a main function that ask user for two file names, open files and read the 1st line of each, and compares them using Hamming...
write a python program that include a function named activity_selection() and take in two arguments, first...
write a python program that include a function named activity_selection() and take in two arguments, first one would be the number of tasks and the second argument would be a list of activities. Each activity would have an activity number, start time and finish time. Example activity_selection input and output: activity_selection (11, [[1, 1, 4 ], [2, 3, 5], [3, 0, 6], [4, 5, 7], [5, 3, 9], [6, 5, 9],[7, 6, 10], [ 8, 8, 11], [ 9, 8,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT