Put the lesson While Loops into practice by writing a program yourself.
A radioactive sample starts at 100 g. After each half-life, half of what remains decays.
Use a while loop to keep halving the amount until less than 10 g is left, counting how many half-lives that takes.
10 g or more.Half-life 1: 50.0 g.Below 10 g after 4 half-lives.Half-life 1: 50.0 g Half-life 2: 25.0 g Half-life 3: 12.5 g Half-life 4: 6.25 g Below 10 g after 4 half-lives
Write your program below and press Run. Each run is checked against the expected output.
Press Run to see what your program prints.
One possible solution. Other programs that print the same output are correct too.
amount = 100.0 # gramshalf_lives = 0while amount >= 10: amount = amount / 2 half_lives = half_lives + 1 print(f"Half-life {half_lives}: {amount} g")print(f"Below 10 g after {half_lives} half-lives")