Kodewick
Start learning →
Basic←→0 / 100

Bouncing ball

#023BasicLoopsNumbers4 min

A ball drops from height metres, and each bounce goes half as high as the last. Write bounces(height) to return how many bounces still reach 1 metre or more.

Examples
bounces(8)→3
bounces(10)→3
main.py
def bounces(height):
    count = 0
    # your code here: while the next bounce (height / 2) is
    # at least 1, halve height and add 1 to count

    return count
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.