Please written by computer source PYTHON (all is one code question) a1. Define a function named to_kph which has two inputs. Both of these inputs will have float values. This first input represents the number of miles traveled. The second input represents the number of hours the travel required and will NOT be 0. Your function must calculate and return a float. The returned value represents the speed traveled in kilometers per hour. Your function should start by multiplying the first parameter by 1.60934 (1 mile is 1.60934 kilometers). That product should then be divided by the second input. Your function must return the result of that division. a2. Define a function named ck_to_r which has two inputs. The two inputs are floats representing the cyan and black levels, respectively, of a color represented using CMYK. Your function will calculate and return a string stating the red level of this color (for the much more common RGB format). Your function should calculate 255 * (1 - cyan level) * (1 - black level). Because RGB colors are always reported as a whole number, your function should then use whole-number division to divide the result of the multiplication by 1. The function needs to return a str with the text Red level is red level the function calculated. b. For this question you will need to use the following library function: str_val.replace(x,y) returns a new string containing the text from str_val, but with all instances of x replaced by y Define a function named defunk which has one input. The input is a str and the value of this input are lyrics appropriate for a song by Prince. Define your defunk function so that it returns this text in normal English. To do this, start by replacing all of input's instances of "4" with "for". Use the result of that initial call to replace, when replacing all instances of "U" with "you". Your function should return a no-longer-funky str. c. Define a function to_metric that has three inputs. The first input will have a float value which represents the circumference of a tire (as a fraction of a mile). The second input will have an int value which represents the number of times the tire has rotated. The third input will have a float value which represents the number of hours traveled. First, multiply the first two parameters to calculate the distance travelled (in miles). It is expected, but not required, you then call your to_kph function from part A1 using the calculated distance travelled and the third parameter as the arguments. However it is calculated, your function should return the tire's velocity in kilometers per hour.
Please written by computer source
PYTHON (all is one code question)
a1. Define a function named to_kph which has two inputs. Both of these inputs will have float values. This first input represents the number of miles traveled. The second input represents the number of hours the travel required and will NOT be 0. Your function must calculate and return a float. The returned value represents the speed traveled in kilometers per hour. Your function should start by multiplying the first parameter by 1.60934 (1 mile is 1.60934 kilometers). That product should then be divided by the second input. Your function must return the result of that division.
a2. Define a function named ck_to_r which has two inputs. The two inputs are floats representing the cyan and black levels, respectively, of a color represented using CMYK. Your function will calculate and return a string stating the red level of this color (for the much more common RGB format). Your function should calculate 255 * (1 - cyan level) * (1 - black level). Because RGB colors are always reported as a whole number, your function should then use whole-number division to divide the result of the multiplication by 1. The function needs to return a str with the text Red level is red level the function calculated.
b. For this question you will need to use the following library function:
str_val.replace(x,y) returns a new string containing the text from str_val, but with all instances of x replaced by y
Define a function named defunk which has one input. The input is a str and the value of this input are lyrics appropriate for a song by Prince. Define your defunk function so that it returns this text in normal English. To do this, start by replacing all of input's instances of "4" with "for". Use the result of that initial call to replace, when replacing all instances of "U" with "you". Your function should return a no-longer-funky str.
c. Define a function to_metric that has three inputs. The first input will have a float value which represents the circumference of a tire (as a fraction of a mile). The second input will have an int value which represents the number of times the tire has rotated. The third input will have a float value which represents the number of hours traveled. First, multiply the first two parameters to calculate the distance travelled (in miles). It is expected, but not required, you then call your to_kph function from part A1 using the calculated distance travelled and the third parameter as the arguments. However it is calculated, your function should return the tire's velocity in kilometers per hour.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images