(Solved):Write a while loop in Python that prints user_num divided by 2 until user_num is less than 1. Sample output for the given program: 10.0 ,5.0, 2.5 .1.25 ,0.625 View Answer…

 

Question

Write a while loop in Python that prints user_num divided by 2 until user_num is less than 1.

Sample output for the given program: 10.0 ,5.0, 2.5 .1.25 ,0.625

 

EXPERT ANSWER

For this problem, we first need to get the user’s input, and convert it to a floating point number, this is easily done using Python’s float() function, which we can wrap around the input function right away.

The while loop is

Scroll to top