Home | | Computer Science 12th Std | The format( ) function

Python - The format( ) function | 12th Computer Science : Chapter 8 : Core Python : Strings and String Manipulation

Chapter: 12th Computer Science : Chapter 8 : Core Python : Strings and String Manipulation

The format( ) function

The format( ) function used with strings is very versatile and powerful function used for formatting strings.

The format( ) function

The format( ) function used with strings is 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)))

Out Put

Number 1: 34

Number 2: 54

The sum of 34 and 54 is 88

 

Tags : Python , 12th Computer Science : Chapter 8 : Core Python : Strings and String Manipulation
Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
12th Computer Science : Chapter 8 : Core Python : Strings and String Manipulation : The format( ) function | Python


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.