Advertisement
Buzzbow

den to bin conversion

Aug 27th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #Bin conversion
  2.  
  3. value = int(input("Please enter a denary number to convert to binary "))
  4. convert_value = value
  5. binary_string = ""
  6.  
  7. while convert_value != 0:
  8. result = convert_value % 2
  9. binary_string = str(result) + binary_string
  10. convert_value = convert_value // 2
  11. print("The denary number {0} in binary is {1}.".format(value, binary_string))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement