To convert octal to hexadecimal number in python, you have to ask from user to enter a number in octal format and start converting the given number into hexadecimal format just by using the function hex() as shown here in the program given below.
Following python program ask from user to enter a number in octal format to convert the number in hexadecimal number system:
# Python Program - Convert Octal to Hexadecimal while True: print("Enter 'x' for exit.") octal = input("Enter number in Octal Format: ") if octal == 'x': break else: dec = str(int(octal, 8)) decm = int(dec) print(octal,"in Hexadecimal =",hex(decm),"\n")
Here is the sample run of the above Python program demonstrating how to convert a number from octal number system to hexadecimal number system:
You may also like to learn or practice the same program in other popular programming languages: