Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # comment: convert a number from denary to binary
- print('Give the integer positive number to be converted to binary')
- value = int(input ('What is number? '))
- div_value=value
- bin_string=''
- while (div_value!=0):
- if (div_value%2):
- bin_string= '1'+bin_string
- else:
- bin_string= '0'+bin_string
- div_value=div_value//2
- print ('The denary number is: ',value,' the binary string is: ', bin_string )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement