Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- b = int(input())
- binary_list = []
- while n > 0:
- remainder = n % 2
- binary_list.insert(0, remainder)
- n = n // 2
- binary_str = ''.join(map(str, binary_list))
- count_b_digit = binary_str.count(str(b))
- print(binary_str) # Hex
- print(count_b_digit) # count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement