Title: Formatted Output Statement
Course: CPS 120: Introduction to Computer Science ~ Master (Aug/2015) OLD > Section: Learning Units

Formatted Output Statement

- Enables formatted output to be sent to a screen.
- Below is a description and explanation of the formatted print syntax:

print (
“<repl-field-1><repl-field-2>…<repl-field-n>".
format(<value-1>, <value-2>, …, <value-n>),
<sep=’ ‘>, end=’\n’)

Where ...

<repl-fielded-n> is a replacement field of the form:
{<filed-number>:<format-specifier>}

Where …
<field-number> where each one is assigned a unique number beginning with zero
<format-specifier> consists of:

- An optional alignment character
  - < left-justify data in output field
  - ^ center data in output field
  - > right-justify data in output field
- A field width
  - Whole number for string and integer data
  - Real number for real data
- A data type
  - s For string data
  - d For integer data
  - f For real-number data