# 0616.py print (type(77)) # print (isinstance(77,int)) # True print (type([3,5,1])) # print (isinstance([3,5,1],tuple)) # False print (isinstance([3,5,1],(tuple,list))) # True print (type('alfa')) # def f(x): pass print (type(f)) # class vettore (list): def __init__(A,x,y,z): A(x,y,z) def __call__(A,x,y,z): A.extend([x,y,z]) def __add__(A,B): (x,y,z)=A; (u,v,w)=B; return vettore(x+u,y+v,z+w) def __mul__(A,t): (x,y,z)=A; return vettore(t*x,t*y,t*z) def __rmul__(A,t): return A*t def __mod__ (A,B): # prodotto scalare. (x,y,z)=A; (u,v,w)=B; return x*u+y*v+z*w def __and__ (A,B): # prodotto vettoriale. (x,y,z)=A; (u,v,w)=B return vettore(y*w-z*v,z*u-x*w,x*v-y*u) def __str__ (A): return '%.2f %.2f %.2f' %(tuple(A)) def lun (A): (x,y,z)=A; return math.sqrt(x*x+y*y+z*z) a=vettore(8,0,2) print (type(a)) # print (isinstance(a,vettore)) # True