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

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...
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
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.
PROGRAM IN C++ The distance a vehicle travels can be calculated using the following equation: distance...
PROGRAM IN C++ The distance a vehicle travels can be calculated using the following equation: distance = speed * time For example, if a train travels 40 miles per hour for 3 hours, the distance traveled is 120 miles. Write a program that asks the user for the speed of a vehicle (in miles per hour) and how many hours it has traveled. The program should then use a loop to display the distance the vehicle has traveled for each...
When an object is placed at a distance greater than the focal length but less than twice the focal length from a convex lense
When an object is placed at a distance greater than the focal length but less than twice the focal length from a convex lense the image is diminished.the image is virtual.All of the other choices are not correct.the image is inverted.the image is formed on the same side as theobject.For an object placed in front of a concave lense,the image is always realthe image may be erect or inverted.the image is formed on the other side of thelense.the image may be...
When studying the motion of an object, we can analyze it using kinematic equations or energy...
When studying the motion of an object, we can analyze it using kinematic equations or energy equations. Both types of equations give information about position and velocity. Kinematic equations give information about the motion of an object from moment to moment, while energy equations typically detail the initial and final points of the motion. Consider a car traveling at 6 m/s. When the driver breaks the car travels 18 meters before coming to a stop. (This is one question, just...
Write code in Python that does the following : An anagram is when the order of...
Write code in Python that does the following : An anagram is when the order of a word can be changed to create a new word (evil, live, and vile for example). Using the dictionary provided, find all of the anagram groups. Which words contain the most anagrams? How large is this group? Here is another example: Alert, alter, and later have 3 in their group. Use the provided dict.txt as your word list, solution must also finish in less...
how to find intial velocity when you are given distance and acceleration? can you give an...
how to find intial velocity when you are given distance and acceleration? can you give an example and answer?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT