Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def tobase(num, base):
- base_num = ""
- if num < 0:
- sign="-"
- num = -num
- else:
- sign = ""
- while num > 0:
- d = int(num % base)
- base_num += str(d) if d < 10 else chr(ord('A')+ d - 10)
- num //= base
- base_num = sign+base_num[::-1]
- return base_num
- num, base = input("Введите десятичное число и основание: ").split()
- print(tobase(int(num),int(base)))
Advertisement
Add Comment
Please, Sign In to add comment