In [ ]:
1+3
In [ ]:
import math
math.cos(pi)
In [ ]:
### Por que sale un solo resultado?
math.sin(pi)
math.tan(3)
In [ ]:
a=math.sqrt(2)
b=a**2
print b
In [ ]:
a=3
b=9.5
c=True
d=1+3.j
In [ ]:
print a,b,c,d
In [ ]:
a=3
b=5
if a>b:
print "{} es mayor a {}".format(a,b)
else:
print "{} no es mayor a {}".format(a,b)
In [ ]:
a=0
while a<10:
print a
a+=1
In [ ]:
#Creando una lista
l=[1,2,3,4,5,6,7,8,9]
In [ ]:
#sacando datos de una lista
print l[1]
In [ ]:
print l[0:4]
In [ ]:
#Cambiando datos de una lista
l[3]="tres"
print l
In [ ]:
#Función range
print range(10)
print range(2,10)
print range(2,10,2)
In [ ]:
for i in range(10):
print i,
In [ ]:
l=[1,2,4,3,5,6,7,"tres","cinco"]
for i in l:
print i,
In [ ]:
#Tuplas
t=(1,2,3,4,5)
print t
In [ ]:
for i in t:
print i,
In [ ]:
t[0]=5
In [ ]:
def func(x,y):
a=0
for i in range(x):
a=a+float(i)/y
return a
In [ ]:
func(7,5)
In [ ]:
range?