-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ejrcicio 4 Repetitivass.txt
63 lines (48 loc) · 1.24 KB
/
Ejrcicio 4 Repetitivass.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 4
def funcionDecimalBinario(decimal):
listaBinario =[]
while decimal > 0:
binario = int(decimal % 2)
decimal = int(decimal / 2)
listaBinario.append(binario)
return listaBinario
def funcionDecimalOctal(decimal):
listaOctal =[]
while decimal > 0:
octal = int(decimal % 8)
decimal = int(decimal / 8)
listaOctal.append(octal) //hshs
return listaOctal
def funcionDecimalHexa(decimal):
listaHexa =[]
while decimal > 0:
hexal = (decimal % 16)
print(hexal)
if hexal == 10:
hexal = "A"
elif hexal == 11:
hexal = "B"
elif hexal == 12:
hexal = "C"
elif hexal == 13:
hexal = "D"
elif hexal == 14:
hexal = "E"
elif hexal == 15:
hexal = "F"
decimal = int(decimal/16)
listaHexa.append(hexal)
return listaHexa
def main():
decimal = int(input("Ingrese el numero a convertir: "))
print("El numero decimal: ",decimal)
binario = funcionDecimalBinario(decimal)
binario.reverse()
octal = funcionDecimalOctal(decimal)
octal.reverse()
hexal = funcionDecimalHexa(decimal)
hexal.reverse
print("Convertido a Binario es: ", binario)
print("Convertido a Octal es: ", octal)
print("Convertido a Hexadecimal es: ", hexal)
main()