When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period: d=½(gt)^2 The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time, in seconds, that the object has been falling. Design a function named fallingDistance that accepts an object’s falling time (in seconds) as an argument. The function should return the distance, in meters, that the object has fallen during that time interval. Design a program that calls the function in a loop that passes the values 1 through 10 as arguments and displays the return value.

Respuesta :

Answer:

# main function is defined

def main():

# for loop to count 1 - 10

for t in range(1, 11):

# the distance is printed for each time 1 - 10. And the fallingDistance function is called with t as argument

print("Distance fall is: ", fallingDistance(t))

# the value of g is initialized to 9.8 as a constant

G = 9.8

# fallingDistance function is defined and it takes time as parameter. The distance is calculated inside the function. The calculated distance is returned when called.

def fallingDistance(time):

distance = (1 / 2) * G * (time ** 2)

return distance

# the call the program's main function to begin execution

if __name__ == "__main__":

main()

Explanation:

The program is written in Python and is well commented.

A sample image of program output during execution is attached.

Ver imagen ibnahmadbello
RELAXING NOICE
Relax