निम्नलिखित प्रोग्राम का आउटपुट क्या है?
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
2.0000 2 -8 3.77
B
2 3.77-8 3.77
C
2.000 3 -8 3.77
D
2.000 2 8 3.77
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
{0:4f} संख्या को फ्लोट में बदलता है (डिफ़ॉल्ट 6 डेसिमल), {0:3d} उसे इंटीजर की तरह स्पेस के साथ दिखाता है। (नोट: प्रश्न के विकल्पों में डेसिमल की संख्या में अंतर हो सकता है, लेकिन तर्क यही है)।
Correct Answer: A) 2.0000 2 -8 3.77