In: Computer Science
Provide a formatted printing statement that yields $▯▯323.500 for input 323.5. Note that ▯ means a space.
Formatted Printing Statement: Formatted input/output us very portable. It is a simple process to move formatted data files to various computers,even computers running different operating systems, as long as they all use the ASCII character set ( ASCII is the American Standard Code for Information Interchange , It is the character set used by almost all current computers with the notable exception of large IBM mainframes). Formatted files are human readable and can be typed to the terminal screen or edited with a text editor.
There are several ways to present the output, data can be printed in a human-readable form or written to a file for future use. Sometimes user often wants more control the formatting of output that simply printing space seperated values.
Formatted printing statement in python:
print("$ %5.3f"%(323.5))
You can also take the value from keyword and then replace 323.5 by the value provided by the user.
Here 5
%5.3f is used to represent that it is decimal number.
If we use %5.2f then the outpur is $ 323.50
If we use %5.4f then the outpur is $ 323.5000