Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input('digite o numero que deseja:\n'))
- n1 = int(input('1 = binario\n2 = octal\n3 = hexadecimal\n4 = octal P/decimal\n'))
- total = int(0)
- totalteste = int(0)
- expoente = int(0)
- total1 = str()
- lista = []
- if n1 == 1:
- while True:
- if n >= 2:
- total = n % 2
- lista = lista + [total]
- n = n // 2
- if n <= 1:
- total = n % 2
- lista = lista + [total]
- print(lista[::-1])
- break
- if n1 == 2:
- while True:
- if n >= 8:
- total = n % 8
- lista = lista + [total]
- n = n // 8
- if n <= 7:
- total = n % 8
- lista = lista + [total]
- print(lista[::-1])
- break
- if n1 == 3:
- while True:
- if n >= 16:
- total = n % 16
- if total == 10:
- total1 = 'A'
- elif total == 11:
- total1 = 'B'
- elif total == 12:
- total1 = 'C'
- elif total == 13:
- total1 = 'D'
- elif total == 14:
- total1 = 'E'
- elif total == 15:
- total1 = 'F'
- else:
- total1 = total
- lista = lista + [total1]
- n = n // 16
- if n <= 15:
- total = n % 16
- total1 = total
- if total == 10:
- total1 = 'A'
- elif total == 11:
- total1 = 'B'
- elif total == 12:
- total1 = 'C'
- elif total == 13:
- total1 = 'D'
- elif total == 14:
- total1 = 'E'
- elif total == 15:
- total1 = 'F'
- else:
- total1 = total
- lista = lista + [total1]
- print(lista[::-1])
- break
- if n1 == 4:
- while True:
- if n >= 10:
- total = n % 10
- totalteste += total * (8**expoente)
- n = n // 10
- elif n <= 9:
- total = n % 10
- totalteste += total * (8**expoente)
- print(totalteste)
- break
- expoente += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement