Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I had to create a program in Python that converts a decimal to a hexadecimal, then from hexadecimal to decimal. I have completed the conversion,

I had to create a program in Python that converts a decimal to a hexadecimal, then from hexadecimal to decimal. I have completed the conversion, but how do I take input from the user for the original "decimal"? Code please. The output right now is "9F1", "2545".

image text in transcribed

def decimal_to_hex(n): hexadecimal = ['0'] * 100; i = 0; while (n !=0): temp = 0; temp = n % 16; n = int(n / 16); if (temp = ): print((hexadecimal[j]), end="); j = j - 1; n = 2545; decimal_to_hex(n); def hex_to_decimal(hex): n = 0 hex = hex[::-1].upper(), p = 1 for c in hex: if c in "ABCDEF": ' n += (ord(c) - ord('A')+10)*p else: n += (ord(c) - ord('0'))*p p *= 16 print(" ") print(n) hex_to_decimal(1991)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions