Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Python code snippet?
x=3.3456789
‘%-6.2f | %05.2f | %+06.1f’ %(x, x, x)

What will be the output of the following Python code snippet?
x=3.3456789
‘%-6.2f | %05.2f | %+06.1f’ %(x, x, x)
a) ‘3.35 | 03.35 | +003.3’
b) ‘3.3456789 | 03.3456789 | +03.3456789’
c) Error
d) ‘3.34 | 03.34 | 03.34+’

Answer: a
Explanation: The code shown above rounds the floating point value to two decimal places. In this code, a variety of addition formatting features such as zero padding, total field width etc. Hence the output of this code is: ‘3.35 | 03.35 | +003.3’.

Join The Discussion