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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Concept of Parenthesis
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education