# 0622.py import string for x in (3.5,4,6.9,-3.7): print int(x), # 3 4 6 -3 print print int('-345',base=10) # -345 print int('-345',base=8) # -229 # Perche' 3*64+4*8+5=229 print int('kvjm',base=36) # 974002 print string.atoi('kvjm',base=36) # 974002 ####################################### for x in (3,8.88,'6.25','-40'): print float(x), # 3.0 8.88 6.25 -40.0 x=100; y=17 print x/y, float(x)/y # 5 5.88235294118 ####################################### for x in (15,92,187): print hex(x), # 0xf 0x5c 0xbb print for x in (9,13,32): print oct(x), # 011 015 040 ####################################### print print bool(2 and 3 and 8) # True print bool(2 and [] and 7) # False print bool(0 or '' or []) # False print bool(0 or [] or 2 or 5) # True