मराठी
तामिळनाडू बोर्ड ऑफ सेकेंडरी एज्युकेशनएचएससी विज्ञान इयत्ता १२

What is the use of format( )? Give an example.

Advertisements
Advertisements

प्रश्न

What is the use of format( )? Give an example.

टीपा लिहा
Advertisements

उत्तर

The format( ) function used with strings is a very versatile and powerful function used for formatting strings. The curly braces { } are used as placeholders or replacement fields which get replaced along with format( ) function.

Example:

num1 = int (input (“Number 1:“))
num2 = int (input (“Number 2:“))
print (“The sum of { } and { } is { }”.format (num1, num2,(num1 + num2)))
OutPut:
Number 1 : 34
Number 2 : 54
The sum of 34 and 54 is 88.
shaalaa.com
The Format( ) Function
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 8: Strings and String manipulation - Evaluation [पृष्ठ १३१]

APPEARS IN

सामाचीर कलवी Computer Science [English] Class 12 TN Board
पाठ 8 Strings and String manipulation
Evaluation | Q 4. | पृष्ठ १३१
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×