This can be executed by using the str.format() method.
We can use the print() function to get the data as the output on the device.
There are various ways to display the output on the screen, and you can either print it in a human-readable format or write to a file and save it for future usage.
The modulo operator can format the string. It mainly interprets the left argument like the print() style format and then apply it to the right argument.
The format() method got added up in Python 2.6 version. Users can use {} for formatting the string as it requires more human efforts. The {} mark is used where it is required to substitute a variable and can offer detailed formatting further.
In this method, the formatting is done using string slicing and concatenation operations.
Here, the curly braces {} are actually working as placeholders.
We can even use keyword arguments to format any type of string.
NOTE- We can also format strings like printf() style which had been previously used in C programming language. We can always use the % operator to accomplish this.
knowledge2life : 1, Portal : 5.33
Total users : 240, Boys : 120
031
3.561E+02
|