Menu Close

Decimal equivalent value Conversion (bin,oct,hex) in Python…..FTC

Chris was given a task by his friend rajesh. When rajesh tells a number then chris needs to convert the value in binary, octal, hexadecimal for the decimal equivalent value told by his friend rajesh.

Help them to achieve this task

a=int(input("Value: "))

print("The Binary Value: " + str(bin(a)))
print("The octal Value: " + str(oct(a)))
print("The hexadecimal Value: " + str(hex(a)))


INPUT_1:
Value:  65

OUTPUT:
The Binary Value:  0b1000001
The octal Value:  0o101
The hexadecimal Value:  0x41


INPUT_2:
Value:  2

OUTPUT:
The Binary Value:  0b10
The octal Value:  0o2
The hexadecimal Value:  0x2


INPUT_3:
Value: 100

OUTPUT:
The Binary Value:  0b1100100
The octal Value:  0o144
The hexadecimal Value:  0x64


ILLUSTRATION

Executed using python3 in linux terminal