निम्नलिखित प्रोग्राम का आउटपुट क्या है?
What is the output of the following program?
a = 2
b= '3.77'
c = - 8
str1= '{0:4f} {0:3d} {2} {1}'. format(a, b, c)
print(str1)
A)
B)
C)
D)
Explanation:
The given program formats the string using the format()
method:
{0:4f}
: Formatsa
(which is 2) as a float with 4 decimal places →2.0000
{0:3d}
: Formatsa
(which is 2) as an integer with a width of 3 →2
{2}
: Printsc
(which is -8){1}
: Printsb
(which is'3.77'
)
So, the output is:
(A) 2.0000 2 -8 3.77