f string float format
>>> a = 10.1234
>>> f'{a:.2f}'
'10.12'
f string float format
>>> a = 10.1234
>>> f'{a:.2f}'
'10.12'
How to justify a string in Python f-strings
s1 = 'Python'
s2 = 'ython'
s3 = 'thon'
s4 = 'hon'
s5 = 'on'
s6 = 'n'
print(f'{s1:>6}')
print(f'{s2:>6}')
print(f'{s3:>6}')
print(f'{s4:>6}')
print(f'{s5:>6}')
print(f'{s6:>6}')
...
Python
ython
thon
hon
on
n
....
python f-string padding
#!/usr/bin/env python3
name = 'Peter'
age = 23
print('%s is %d years old' % (name, age))
print('{} is {} years old'.format(name, age))
print(f'{name} is {age} years old')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us