Python Decimal places
Python program to get a fractional number from user and display the same in two digit precision
Sample Input 1:
56.3426
Sample Output 1:
56.34
Program or Solution
num=float(input("Enter a Number:"))
print("{:.2f}".format(num))
Program Explanation
In python format specifiers are mentioned inside {} and value for the specifiers are passed through the format() method.
Here :.2f specifies float value with 2 decimal point.
Comments
Related Programs
- Python Hello World
- Python get input
- Python get Integer input
- Python get float input
- Python New Line
- Python without new line
- Python tab Space
- Python Tuple Assignment
- Python Integer to Character
- Python Decimal to HexaDecimal
- Python Hexa Decimal to Decimal
- Python Decimal to Octal
- Python Octal to Decimal
- python Exponent representation
coming Soon
coming Soon