Respuesta :
Explanation:
The required function in python is written as follows :
user_num = int(input())
#takes an input value and convert to an integer value.
while user_num >= 1 :
#While loops is conditioned to run if user_num is ≥ 1
user_ num = user_num / 2
#divide user_num by 2 and store the result as user_num
print(user_num)
#print user_num
The while loop condition does most of the work here, The while loops is conditioned to run the divison of user_num if the value of user_num is greater than or equal to 1 ; if user_num is lesser than 1, the loop terminates.
Lear more : brainly.com/question/15170131
laminiaduo7 and 9 more users found this answer helpful
THANKS
1
1.5
(8 votes)
Unlocked badge showing two hands making the shape of heart over a pink circle
Found this answer helpful? Say thanks and unlock a badge.
Advertisement
Answer
author link
teobguan2019
Ambitious
613 answers
1.2M people helped
Answer:
user_num = float(input("Enter a number: "))
while(user_num > 1):
user_num = user_num / 2
print(user_num)
Explanation:
Line 1:
Use built-in function input() to prompt user input a number and assign it to the variable user_num.
Since the default data type of the user input is a string, we need to convert it into float data type before assigning it to user_num. We can do the data type conversion by enclosing the user input into the built-in function float().
Line 3:
Create a while loop by setting condition while user_num bigger than 1, the line 4 & 5 should keep running.
Line 4:
Divide user_num by 2 and assign the division result back to the user_num.
Line 5:
Display updated value of user_num using built-in function print()