Pure Programmer
Blue Matrix


Cluster Map

Project: Aligning Characters and Strings with format()

Write a program that demonstrates the formatting of characters and strings using format() style output. Your program should reproduce the output shown using the following variables:

  • c1 = "C" (or 'C' in C++)
  • c2 = "-"
  • c3 = 51
  • c4 = 80
  • c5 = 0x4f
  • s = "Boba Fett"

Output
$ python3 AligningCharactersAndStringsWithFormat.py c1: C c2: - c3: 3 c4: P c5: O s: Boba Fett s: Boba s: |Boba | s: | Boba| s: | Boba |

Solution