Syncfusion Interview Question

Write a python program to convert the octal number to hexadecimal number

Interview Answer

Anonymous

Aug 20, 2025

# Convert Octal to Hexadecimal # Take octal input as a string octal_num = input("Enter an octal number: ") # Convert octal to decimal decimal_num = int(octal_num, 8) # Convert decimal to hexadecimal hexadecimal_num = hex(decimal_num)[2:].upper() # [2:] removes '0x' prefix, .upper() for uppercase print(f"Octal Number: {octal_num}") print(f"Hexadecimal Number: {hexadecimal_num}")