Introduction
Placeholders
Numbers
Date and time
Padding and Alignment
Summary
15. Summary

Instruction

Good job! It's time to wrap things up. This time, we'll use a simple table:

Code Output
Hi, {0}. You are {1}, {0}!'.format('Mike',28) 'Hi, Mike. You are 28, Mike!'
'Your number is {:04d}.'.format(78) 'Your number is 0078.'
'December sales: {:010.2f} USD'.format(212347) 'December sales: 0212347.00 USD'
from datetime import datetime
'The date and time now: {:%Y-%m-%d %H:%M:%S}'.format(datetime(2018, 10, 3, 16, 0, 0))
'The date and time now: 2018-10-03 16:00:00'
'{:^14}'.format('Report') '    Report    '
'{:_>10}'.format('John') '______John'

How about a short quiz?

Exercise

Click Next exercise to continue.