Answer:
I am writing the program in Python.
def words_typed(typing_speed,time_interval):
typing_speed>=0
time_interval>0
no_of_words=int(typing_speed*(time_interval/60))
return no_of_words
output=words_typed(20,30)
print(output)
Step-by-step explanation:
I will explain the code line by line.
First the statement def words_typed(typing_speed,time_interval) is the definition of a function named words_typed which has two parameters typing_speed and time_interval.
typing_speed variable of integer type in words per minute.
time_interval variable of int type in seconds
The statements typing_speed>=0 and time_interval>0 means that value of typing_speed is greater than or equal to zero and value of time_interval is greater than zero as specified in the question.
The function words_typed is used to return the number of words that a person with typing speed would type in that time interval. In order to compute the words_typed, the following formula is used:
no_of_words=int(typing_speed*(time_interval/60))
The value of typing_speed is multiplied by value of time_interval in order to computer number of words and the result of the multiplication is stored in no_of_words. Here the time_interval is divided by 60 because the value of time_interval is in seconds while the value of typing_speed is in minutes. So to convert seconds into minutes the value of time_interval is divided by 60 because 1 minute = 60 seconds.
return no_of_words statement returns the number of words.
output=words_typed(20,30) statement calls the words_typed function and passed two values i.e 20 for typing_speed and 30 for time_interval.
print(output) statement displays the number of words a person with typing speed would type in that time interval, on the output screen.