1#!/usr/bin/env python3
2
3val = 12.3
4
5print(f'{val:.2f}')
6print(f'{val:.5f}')
7
1#!/usr/bin/env python3
2
3s1 = 'a'
4s2 = 'ab'
5s3 = 'abc'
6s4 = 'abcd'
7
8print(f'{s1:>10}')
9print(f'{s2:>10}')
10print(f'{s3:>10}')
11print(f'{s4:>10}')
12
1#!/usr/bin/env python3
2
3a = 300
4
5# hexadecimal
6print(f"{a:x}")
7
8# octal
9print(f"{a:o}")
10
11# scientific
12print(f"{a:e}")
13
1#!/usr/bin/env python3
2
3for x in range(1, 11):
4 print(f'{x:02} {x*x:3} {x*x*x:4}')
5
1#!/usr/bin/env python3
2
3import datetime
4
5now = datetime.datetime.now()
6
7print(f'{now:%Y-%m-%d %H:%M}')
8