How to Converting an Integer into Decimals using python Example

11/25/2023
All Articles

#How Converting an Integer into Decimals using python Example

How to Converting an Integer into Decimals using python Example

How to Converting an Integer into Decimals using python

 

import decimal
integer = 100
print(decimal.Decimal(integer))
print(type(decimal.Decimal(integer)))



Conclusion

To convert an integer into decimals in Python, you can easily use the decimal point to represent the decimal part of the number.
you can use alternate method for it decimal_number = round(float(integer_number), 2)  So this can help us to convert into float.

 

 

Article