May 2017
Intermediate to advanced
280 pages
6h 2m
English
Consider an example where you would want to print the name, marks, and the age of the person:
print "Name", "Marks", "Age" print "John Doe", 80.67, "27" print "Bhaskar", 76.908, "27"print "Mohit", 56.98, "25"
The output will be as follows:
C:pydev>python hello.pyName Marks AgeJohn Doe 80.67 27Bhaskar 76.908 27Mohit 56.98 25
You can see the output, but the output that is displayed is not formatted. Python allows you to set the formatted output. If you have done some coding in C language, then you should be familiar with %d, %f, %s. In order to represent an integer %d is used, %f is used for float, and %s is used for string. If you used %5d, it means 5 spaces. If you used %5.2f, it means 5 spaces and .2 means precision. ...
Read now
Unlock full access