Example Function Calls:
mtok(2) # should print: 2 mile(s) equals 3.0 km
mtok(10) # should print: 10 mile(s) equals 15 km
def mtok(m):
print(m,"mile(s) equals",m*1.5,"km")
# Testing
mtok(2) # should print: 2 mile(s) equals 3.0 km
mtok(10) # should print: 10 mile(s) equals 15 km

Define a function called “mtok” that takes one input parameter representing a distance in miles and...
#function to covert kilometer to miles #takes km input as an argument and return the calculation def kilometer_to_miles(km): return km * 0.6214 #function to covert miles to kilometer #takes miles input as an argument and return the calculation def miles_to_kilometer(miles): return miles/0.6214 #Main function to find the distance #by calling either of the two functions #prompt the user to enter his/her choice of distance conversion restart = 0 while (restart == 'y'): user_input = input ("Enter k to convert kilometer...
Define a function called collapse() which takes a list as input. Each element of the list will either be an integer, or a list of integers. The function should modify the input list by replacing all of the elements which themselves are lists with the sum of their elements. For example: Test Result vals = [1, 2, 3, 4, 5] collapse(vals) print(vals) [1, 2, 3, 4, 5] vals = [1, [2, 3], 4, 5] collapse(vals) print(vals) [1, 5, 4, 5]...
python Define a function called print_values which takes a dictionary object as a parameter. The function should print all values in the dictionary. However, the order is based on the sorted keys in the dictionary. For example, if we have the following dictionary: {'b':36, 'a':12, 'c':24} The output is: 12 36 24 A faulty solution has been provided below. Identify the fault and submit a corrected version of this code. def print_values(dict1): for k in list(dict1.keys()).sort(): print(dict1[k], end=" ") For...
C++ Write a function that takes as an input parameter a matrix of integers, and 2 integers representing the matrix’s dimensions. Print out the transposed version of the matrix. Input: [[1 2 3] 3,3 ->1 4 7 [4 5 6] 2 5 8 [7 8 9]] 3 6 9
Write a function called productEven that takes as its parameter an input file. The function should read two integers and calculate the total product of only even numbers between them. Return the answer to the calling function. c++ program
Write a function called printStars. The function receives a parameter containing an integer value. If the parameter is positive, the funciton prints (to standard output) the given number of asterisks. Otherwise the function does nothing. The function does not return a value. Thus, if printStars(8) is called, ******** (8 asterisks) will be printed. The function must not use a loop of any kind (for, while, do-while) to accomplish its job. Instead, it should examine its parameter, returning if the parameters...
Define a function called repeat_middle which receives as parameter one string (with at least one character), and it should return a new string which will have the middle character/s in the string repeated as many times as the length of the input (original) string. Notice that if the original string has an odd number of characters there is only one middle character. If, on the other hand, if the original string has an even number of characters then there will...
C++ ONLY Write a function calculator that takes two floating numbers and one operator and prints out the answer based on arithmetic. Assume that there are no overflow, underflow and division by zero cases. Your function should be named calculator Your function takes three input parameter: two double numbers and one char operator Your function does not return anything Your function prints answer in the format specified below Your function should set precision point to 2 Note: You must use...
Define a function called get_n_largest(numbers, n) which takes a
list of integers and a value n as parameters and returns a
NEW list which contains the n
largest values in the parameter list. The values in the
returned list should be in increasing order. The
returned list must always be of length n. If the number of values
in the original list is less than n, the value
None should be repeated at the end of the returned list to...
Write a function that takes as an input parameter an integer that will represent the length of the array and a second integer that represents the range of numbers the random number should generate (in other words, if the number is 50, the random number generator should generate numbers between 0 and 49 including 49. The function then sorts the list by traversing the list, locating the smallest number, and printing out that smallest number, then replacing that number in...