Kodewick
Empieza a aprender →
Básico←→0 / 100

La pelota que rebota

#023Básicowhile height / 2 >= 14 min

Una pelota cae desde height metros y cada bote sube la mitad que el anterior. Escribe bounces(height) para devolver cuántos botes llegan todavía a 1 metro o más.

Ejemplos
bounces(8)→3
bounces(10)→3
main.py
def bounces(height):
    count = 0
    # tu código aquí: mientras el siguiente bote (height / 2)
    # sea al menos 1, divide height a la mitad y suma 1 a count

    return count
Ctrl + Enter también ejecuta
Resultado

Ejecutar prueba los ejemplos. Cuando salgan bien, Enviar.