Quick actions

cmd+k|ctrl+k

Navigation

Languages

intfunctionbinfunctionoctfunctionhexfunction

Snippet info

Language

Python

Visibility

public

Author

masterhun

Created

2023-09-20T17:34:21.257591Z

Updated

2023-09-20T17:35:20.457594Z



# int(value, base) converts value (using base base) into a decimal number.
value = "1010"
base = 2
print(int(value, base))
# Output: ????


# Decimal converted to a binary number, an octal number, and a hexadecimal number. 
beans = int(input("Enter a positive integer: "))
print("Decimal: " + str(beans) + " -->   Binary: " + str(bin(beans)) + " -->   Octal: " + str(oct(beans)) + " -->   Hex: " + str(hex(beans)))

INFO