# 0805.py # Algoritmi, 12.10. for x in (0,1,0.0,[],(),[0],None,'','alfa'): print ('{0:<6}{1}'.format(x,bool(x))) # 0 False # 1 True # 0.0 False # [] False # () False # [0] True # None False # False # alfa True m=124; x=87345.99 a='{0:3} {1:<12.4f}'.format(m,x) print (a) # 124 87345.9900 u=50000/4.3; v=20 a='u={u:6.2f}\nv={v:6.2f}'.format(u=u,v=v) print (a) # u=11627.91 # v= 20.00 a=58; b=11; c=6 print ('{a:2x}{b:2x}{c:2x}'.format(a=a,b=b,c=c)) # 3a b 6 print ('{a:02x}{b:02x}{c:02x}'.format(a=a,b=b,c=c)) # 3a0b06 a='Ferrara'; b='Roma'; c='Rovigo' m=max(len(a),len(b),len(c)) print ('|{a:{m}}|\n|{b:{m}}|\n|{c:{m}}|'.format(a=a,b=b,c=c,m=m)) # |Ferrara| # |Roma | # |Rovigo |