Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Conversión Más Difícil | Revelación
Sistemas Numerales 101

book
Conversión Más Difícil

¡Ahora ya sabes mucho! Puedes convertir un montón de números de diferentes sistemas numéricos, pero aquí vamos a profundizar en las funciones incorporadas de python para la conversión. Vamos a empezar con la conversión a un decimal. Aquí es la función int() es útil.

Por ejemplo, para convertir números binarios a la representación decimal debe comenzar con 0b. Como int(0b10011010010), donde 10011010010 número debe ser convertido.

Para hacer lo mismo con el sistema numérico octal hay que utilizar una sintaxis similar int(0o2322) donde 2322 debe ser convertido.

Supongo que has adivinado la sintaxis para convertir de un sistema numérico hexadecimal: int(0X4D2), donde 4D2 número debe ser convertido. ``python número_decimal1 = int(0b10011010010) número_decimal2 = int(0o2322) número_decimal3 = int(0X4D2)

Se puede implementar no sólo con int(), dicha sintaxis está disponible para otros sistemas numéricos también: ``python

Сonverting from binary numeral system to the octal

oct(0b1010)

Сonverting from octal numeral system to the hexadecimal

hex(0o237)

Сonversión del sistema numérico hexadecimal al binario

bin(0x8ea)

Tarea

Swipe to start coding

Le deseo buena suerte con esta tarea, por favor, siga el algoritmo:

  1. Convertir el número 4EAF del sistema numérico hexadecimal al octal.
    1. Convertir el número 2547 del sistema numérico octal al binario.
  2. Convertir el número 1101011 del sistema numérico binario al decimal.
  3. Convertir el número 2001 del sistema numérico decimal al hexadecimal.

Solución

octal_number = oct(0X4EAF)
binary_number = bin(0o2547)
decimal_number = int(0b1101011)
hexadecimal_number = hex(2001)

print("4EAF->:", octal_number)
print("2547->:", binary_number)
print("1101011->:", decimal_number)
print("2001->:", hexadecimal_number)
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 4. Capítulo 2
# Convert number 4EAF from the hexadecimal numeral system to the octal
octal_number = ___
# Convert number 2547 from the octal numeral system to the binary
binary_number = ___
# Convert number 1101011 from the binary numeral system to the decimal
decimal_number = ___
# Convert number 2001 from the decimal numeral system to the hexadecimal
hexadecimal_number = ___

# Output the result
# Output converted octal number
print("4EAF->:", ___)
# Output converted binary number
print("2547->:", ___)
# Output converted decimal number
print("1101011->:", ___)
# Output converted hexadecimal number
print("2001->:", ___)
toggle bottom row
some-alt