sábado, 18 de maio de 2013

Python Language

Brincado um pouco de Python hoje...

Do básico...

a=3
print(type(a))
a=3.14
print(type(a))
a="fab"
print(type(a))


print("number is " + str(3))

print ("number is %(number)s" % dict(number=3))

for i in "hello":
    print(i)
   
a = [1, 2, 3]
print (type(a))
a.append(5)
a.append(6)
a.append(7)

print(a)

print (a[:3])   
print (a[3:])   
del a[0]

print (len(a))

b = [2, 3, 4]

print (a + b)

c = a  + b



c = [ 2, 4, 5, 6, 7, 8]
b = []
for x in c:
     if x % 2 == 0:
             b.append(x + 3)

print( b)




a = [1,2,3,4,5]
b = [ x  for x in a if x %2 == 0 ]



>>>> python hello.py




Postar um comentário