Script
#!/usr/local/bin/python3.4
decimal = int(input("Enter an integer: "))
print ("This is", bin(decimal), " in Binary.")
print ("It becomes ", hex(decimal), " in Hexadecimal.")
Execution
Enter an integer: 995
This is 0b1111100011 in Binary.
It becomes 0x3e3 in Hexadecimal.
Enter an integer: 65536
This is 0b10000000000000000 in Binary.
It becomes 0x10000 in Hexadecimal.
Enter an integer: 248
This is 0b11111000 in Binary.
It becomes 0xf8 in Hexadecimal.
Enter an integer: 777
This is 0b1100001001 in Binary.
It becomes 0x309 in Hexadecimal.
#!/usr/local/bin/python3.4
decimal = int(input("Enter an integer: "))
print ("This is", bin(decimal), " in Binary.")
print ("It becomes ", hex(decimal), " in Hexadecimal.")
Execution
Enter an integer: 995
This is 0b1111100011 in Binary.
It becomes 0x3e3 in Hexadecimal.
Enter an integer: 65536
This is 0b10000000000000000 in Binary.
It becomes 0x10000 in Hexadecimal.
Enter an integer: 248
This is 0b11111000 in Binary.
It becomes 0xf8 in Hexadecimal.
Enter an integer: 777
This is 0b1100001001 in Binary.
It becomes 0x309 in Hexadecimal.
No comments:
Post a Comment