← Back to Loops
Question 382
Halve Until Below One
Halve Until Below One
Read a decimal number and keep halving it with a while loop, printing each value that is 1 or more (the value itself first, then half of it, then a quarter, and so on); stop once the value drops below 1 and do not print that value. Input: one number, no prompt. Print the values as Python shows them, with no formatting.
Expected Output:
10.0 5.0 2.5 1.25
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Loops
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.