'''
Created on 2012/9/4
Third Python program - numeral
@author: Andy Liu
'''
import math
if __name__ == '__main__':
print(3) #int
print(math.pi,int(math.pi)) #real
n=1.1+2.2j #complex
p=n+2 #complex add
print(n,n.real,n.imag) #complex,real,imagine
print(p)
# ??
print(1.0-0.8,(1.0-0.8),(1.0-0.8).__repr__())# repr function
print(1.0-0.8,(1.0-0.8))
import decimal
print((decimal.Decimal('1.0')-decimal.Decimal('0.8')))
print((decimal.Decimal(1.0)-decimal.Decimal(0.8)))
print(1.0-0.8)
print((1.0-0.8))
# ??
print(oct(10),hex(10),bin(10))#numeral conversion
print(2**8)
print(10/3,10//3,10%3)
執行結果
3
(3.141592653589793, 3)
((1.1+2.2j), 1.1, 2.2)
(3.1+2.2j)
(0.19999999999999996, 0.19999999999999996, '0.19999999999999996')
(0.19999999999999996, 0.19999999999999996)
0.2
0.1999999999999999555910790150
0.2
0.2
('012', '0xa', '0b1010')
256
(3, 3, 1)
沒有留言:
張貼留言