Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Un Nuevo Desafío de Cifrado | Sistema Numérico Hexadecimal
Sistemas Numerales 101

book
Un Nuevo Desafío de Cifrado

¡Aprecio mucho tus esfuerzos! Aquí vas a profundizar en el cifrado y la última cuestión para ti es convertir un número de un sistema numérico decimal a uno hexadecimal. Intenta hacerlo utilizando cadenas😉.

  1. Tienes que dividir el número entre 16 y anotar el resto de la división.

  2. Si el número es mayor que 9, necesitas encontrar una coincidencia en letras.

  3. Luego debes calcular el número recibido y aplicarle el primer paso.

  4. Puedes detenerte si la división da como resultado 0.

  5. Vuelva a escribir los restos en el orden inverso.

1234567891011121314151617181920212223
# Implementing dictionary, but here the keys are numbers, because we are ciphering dictionary = {0: "0", 1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6", 7: "7", 8: "8", 9: "9", 10:"A" , 11:"B", 12:"C", 13:"D", 14:"E", 15:"F"} # Defining the decimal number 64206 decimal_number = 64206 # The text should be realised here due to the reason that further the decimal number will be changed print("The number in decimal numeral system is:", decimal_number) # Creating a list for storing converted hex number hexadecimal_number = [] # The conformity for 0 in decimal numeration system is 0; hence, this condition implemented # The loop executes till the number is zero while decimal_number != 0: # Counting the remainder of division by 16 remainder = decimal_number % 16 # Appending the converted resulting number for creating hexadecimal number hexadecimal_number.append(str(dictionary[remainder])) # This operation allows to decrease number by 16 an work with integer part of new one decimal_number = decimal_number // 16 # Reversing the string hexadecimal_number = hexadecimal_number[::-1] # Concatenating elements hexadecimal_number = "".join(hexadecimal_number) # Printing the result print("The number in hexadecimal numeral system is:", hexadecimal_number)
copy
Tarea

Swipe to start coding

¡Es hora de perfeccionar tus habilidades! Sigue el algoritmo y rellena los huecos para recibir un número en representación hexadecimal:

  1. Imprime la variable número_decimal.
    1. Crea una lista vacía para almacenar número_hexadecimal.
  2. Definir el bucle que se ejecuta hasta que el número_decimal es 0.
  3. Contar el resto de la división número_decimal por 16.
  4. Hacer que la cadena hexadecimal_number se invierta.
  5. Unir todos los elementos de la cadena hexadecimal_number.

Solución

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 2

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt