For float output in print statement
Title
Question
Professor,
For float output in print statement somewhere say in line In[9] you are using %3.2f here in line no. In[12], you are using %2.1f. How you are deciding 2 or 3? I understood about .2 or .4 or .1 that they specify the round off to decimal place value.
Python-3.4.3 Input-output 03-04 min 50-60 sec
Answers:
It means print as a floating point at least 3 wide and a precision of 2. This is a format specifier of a floating point number with 2 decimals and at least one digit left of the decimal point
In this Example
print('The value of x is %3.2f' %x)
Here percentage 3.2f specifies the output in float and .2f rounds off the value to two decimal point.
If Still facing issue, Kindly reply
Login to add comment