Question

In: Computer Science

PYTHON Falling Distance When an object is falling because of gravity, the following formula can be...

PYTHON

Falling Distance

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 = ½ gt2

The variables in the formula are as follows:

d is the distance in meters

g is 9.8 (the gravitational constant)

t is the amount of time in seconds the object has been falling

Your program will calculate the distance in meters based on the object’s falling distance.

Modularity: Your program should contain 2 functions:

main – will call the falling_distance function in a loop, passing it the values 1 – 10 as arguments (seconds the object has been falling).   It will display the returned distance.

falling_distance – will be passed one parameter which is the time in seconds the object has been falling and will calculate and return the distance in meters.    falling_distance should be stored in a separate file (module) called distance.py   You will import distance before your main function in your original program file.

Input Validation: None needed

Output: Should look like this:

Time     Falling Distance

-----------------------------

1          4.90

2          19.60

3          44.10

4          78.40

5          122.50

6          176.40

7          240.10

8          313.60

9          396.90

10        490.00

Solutions

Expert Solution

distance.py:

def falling_distance(i):
return 0.5*9.8*i*i
  
  

main.py:

from distance import *
def main():
print("Time Falling Distance")#print on console
print("----------------------------")
for i in range(1,11):
r=falling_distance(i)#call function and print the result
print(i," ",end="")
print("{:.2f}".format(r))
main()#call main function

Screenshots:

Screenshots:

The screenshots are attached below for reference.

Please follow them for output and proper indentation.

Please upvote my answer. Thank you.


Related Solutions

Task 3. Falling distance When an object is falling because of gravity, the following formula can...
Task 3. Falling distance 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=(1/2)gt2 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. 3.1.     Create a method: FallingDistance Parameters:           t, object’s falling time (in seconds). t may or may not...
When an object is falling because of gravity, the following formula can be use to determine...
When an object is falling because of gravity, the following formula can be use to determine the distance that object falls in a specific time period: d = 1/2 g t*t The variables in the formula are as follows: d is the distance in meters g is 9.8 t is the amount of time, in seconds that the object has been falling. Design a function called fallingDistance() that accepts an object's falling time (in seconds) as an argument. The function...
When an object is falling because of gravity, the following formula can be used to determine...
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=1/2 gt^2 The variables in the formula are as follows: d is the distance in meters, g is 9.8, t is the amount of time, in seconds, that the object has been falling. Design a function named calcFallingDistance that accepts an object’s falling time (in seconds) as an argument. The function should return the...
C++ When an object is falling because of gravity, the following formula can be used to...
C++ When an object is falling because of gravity, the following formula can be used to determine the distance that object falls in a specific time period: d = 1/2 g t*t The variables in the formula are as follows: d is the distance in meters g is 9.8 t is the amount of time, in seconds that the object has been falling. Design a function called fallingDistance() that accepts an object's falling time (in seconds) as an argument. The...
Q. 1: The far distance a person can see an object is at a distance of...
Q. 1: The far distance a person can see an object is at a distance of 50 cm from the eye but she wants to see an object at infinity. What types of lens is required to make her vision correction? Calculate the optical power of her lens. Q 2: The near point a person can see an object is at a distance of 50 cm from the eye but he wants to see object at the least distance of...
Newton's law of gravity was inconsistent with Einstein's special relativity because Question 27 options: the distance,...
Newton's law of gravity was inconsistent with Einstein's special relativity because Question 27 options: the distance, and thus the force, depends on the reference frame chosen time dilation slows the apparent acceleration, reducing the force mass, and thus the force, depends on the reference frame chosen Newton didn't know about Einstein
When an object is placed at the proper distance to the left of a converging lens,...
When an object is placed at the proper distance to the left of a converging lens, the image is focused on a screen 31.0 cmto the right of the lens. A diverging lens is now placed 14.2 cm to the right of the converging lens, and it is found that the screen must be moved 19.5 cm farther to the right to obtain a sharp image. What is the focal length of the diverging lens? ......... cm
PYTHON Which of the following are valid ways to create a DNASeq object for the DNA...
PYTHON Which of the following are valid ways to create a DNASeq object for the DNA sequence, GATCGATCGATC? (Select all that apply.) DNA_seq = new Seq("GATCGATCGATC") DNA_seq = Seq(IUPACUnambiguousDNA() ,"GATCGATCGATC") DNA_seq = Seq("GATCGATCGATC") DNA_seq = Seq("GATCGATCGATC", IUPACUnambiguousDNA())
Which of the following is correct?   A. When marginal product is falling, total product must be...
Which of the following is correct?   A. When marginal product is falling, total product must be falling.    B. All of the other answers are incorrect    C. When marginal product is falling, total product must also be falling.    D. Marginal product rises faster than total product and also falls faster than marginal cost.    E. When total product is rising, both average product and marginal cost must also be rising.
Which of the following strategies can be implemented in falling interest rate environment to hedge the...
Which of the following strategies can be implemented in falling interest rate environment to hedge the interest rate risk (select as many as applicable)? Please explain your logic in a concise way. 1. Buy short-term and long-term bonds 2. Sell long term bonds and buy short term 3. Buy long term bonds and sell short term 4. Sell a fixed coupon bond and enter a swap receiver position 5. Buy a fixed coupon bond and enter a swap payer position...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT