Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3c30f91

Browse files
committed
added bounce.py code
1 parent 2f0ab9b commit 3c30f91

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Work/bounce.py

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
# bounce.py
22
#
33
# Exercise 1.5
4+
'''
5+
A rubber ball is dropped from a height of 100 meters and each time it hits the ground, it bounces back up to 3/5 the height it fell.
6+
Write a program bounce.py that prints a table showing the height of the first 10 bounces.
7+
'''
8+
9+
height = 100 # meters
10+
bounceBack = 0.6 # 3/5 meters
11+
bounce = 1
12+
13+
while bounce <= 10:
14+
height = height * bounceBack
15+
print(bounce, round(height, 4))
16+
bounce += 1

0 commit comments

Comments
 (0)