Showing posts with label Excretory System. Show all posts
Showing posts with label Excretory System. Show all posts

Write the definition of a function power_to, which receives two parameters. The first is a double and the second is an int. The function returns a double.

Write the definition of a function power_to, which receives two parameters. The first is a double and the second is an int. The function returns a double.




If the second parameter is negative, the function returns zero. Otherwise it returns the value of the first parameter raised to the power of the second.
def power_to(adouble, aint):
if aint<0:
return 0
else:
return adouble**aint

Write the definition of a function typing_speed, that receives two parameters. The first is the number of words that a person has typed (an int greater than or equal to zero) in a particular time interval. The second is the length of the time interval in seconds (an int greater than zero). The function returns the typing speed of that person in words per minute (a float).

Write the definition of a function typing_speed, that receives two parameters. The first is the number of words that a person has typed (an int greater than or equal to zero) in a particular time interval. The second is the length of the time interval in seconds (an int greater than zero). The function returns the typing speed of that person in words per minute (a float).




Answer:


def typing_speed(num_words,time_interval):
num_words>=0
time_interval>0
result=float(60*num_words/time_interval)
return result