Answer:
The program to this question can be described as follows:
Program:
num= int(input('Enter a number: ')) #input value by user
st = '' #defining string variable
while num > 0: #define loop to calculte values binary number
val= num % 2 # holding remainder (0 or 1) in val variable
st =st+str(val) # store value in str variable
num = num//2 #calculte quotient value
print("binary number is: ",st)
Output:
Enter a number: 5
binary number is: 101
Explanation:
Program description as follows:
Firstly the "num" variable is declared, for user input, then an "st" variable is declared, to calculates user input value binary number.
In the next step, a while loop is declared, inside the loop, another variable "Val" is declared, that holds value remainders, which is added on the "st" variable.
Outside the loop, the print method is used, that prints st variable holds value.