to decimal python code example

Example 1: how to convert decimal to binary python

a = 5
#this prints the value of "a" in binary
print(bin(a))

Example 2: give answer in 6 decimal python

print("{:.6f}".format(variable_name))

Example 3: what should you call a decimal value in python

x = 13.949999999999999999
g = float("{:.2f}".format(x))

Example 4: decimal conversion python

#Example with binary number 10101100 which is 172 in denary

number = 10101100
print(int(str(number),base=2))

#Prints out the denary value so 172 in this example.

Tags:

Cpp Example