Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Exercise 3.4 Python: A standard science experiment is to drop a ball and see how high it bounces. Once the bounciness of the ball

Programming Exercise 3.4 Python:

A standard science experiment is to drop a ball and see how high it bounces. Once the bounciness of the ball has been determined, the ratio gives a bounciness index.

For example, if a ball dropped from a height of 10 feet bounces 6 feet high, the index is 0.6, and the total distance traveled by the ball is 16 feet after one bounce. If the ball were to continue bouncing, the distance after two bounces would be 10 ft + 6 ft +6 ft + 3.6 ft = 25.6 ft. Note that the distance traveled for each successive bounce is the distance to the floor plus 0.6 of that distance as the ball comes back up.

Write a program that lets the user enter the initial height from which the ball is dropped, the bounciness index, and the number of times the ball is allowed to continue bouncing. Output should be the total distance traveled by the ball.

Below is an example of the program input and output:

Enter the height from which the ball is dropped: 25 Enter the bounciness index of the ball: .5 Enter the number of times the ball is allowed to continue bouncing: 3 Total distance traveled is: 65.625 units. 

image text in transcribed

Enter the height from which th e ball is dropped: 25 Enter the bounciness index of the ball: .5 Enter the nunb of times the ball is allowed to continue bo uncing: 3 Total distance traveled is 4:3 75e bounce.py 1# Put your code here 2 3 # # getting the height 4 height-float (input( Enter the height from which the ball is dropped:) 5 6 # # getting the bouciness index from the user 7 bounci index float (input( Enter the bounciness index of the ball: ")) # getting the number of bounces 1 bounces-int(input( "Enter the number of tines the ball is allowed to continue bouncing:")) 12 # variable to store the distance 13 distance-0 14 15 while bounces > : 16 17 18 height-height bounci index 19 20 21 # calculating the new height # calculating the distance before bouncing distance-distance+height 23 24| # calculting the distance after bouncing 25 26 27 28 29 39#displaying the result 31 32 print( "Total distance traveled is %.3f" % distance) distance-distance height # decrementing the bounces bounces--1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions