Double until it passes 100
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
This one builds on a lesson you haven't finished yet. Do that lesson first:
Python Basics · While loops →
Double until it passes 100
n starts at 1. Keep doubling it while it is 100 or less. Store the first value over 100 in n.
Here the value being tested is the value being changed, so the loop needs no separate counter. It stops the moment the question turns false — and n keeps the value that made it false.
n starts at 1. Keep doubling it while it is 100 or less. Store the first value over 100 in n.
Click Run to see the output here.