In [ ]:
print('Hola mundo!')
In [ ]:
nombre = 'hola'
print(nombre)
In [ ]:
nombre = 'hola'
nombre = 13
print(nombre)
In [ ]:
1 + 1
In [ ]:
1 - 1
In [ ]:
1 * 1
In [ ]:
1 / 1
In [ ]:
1 / 2
In [ ]:
1 // 2
In [ ]:
1 // 1
In [ ]:
2 ** 2
In [ ]:
3 ** 3
In [ ]:
2 ** 0.5
In [ ]:
3 // 2
In [ ]:
3 % 2
In [ ]:
for i in range(20):
print(i % 3)
In [ ]:
'hola' * 5
In [ ]:
'ATGC' * 100
In [ ]:
print('hola ' + "aksdfjlksadf" + """
asdfjlk
lksajdflkj
klkjdlkfj
""")
In [ ]:
'hola{}'.format(1)
In [ ]:
lista = [1, 2, 3, 'platano', 59]
print(lista)
lista.append('manzana')
print(lista)
otra_lista = lista
otra_lista.append(5)
otra_lista[0] = 3
print(lista)
In [ ]:
lista = [1, 2, 3, 'platano', 59]
print(lista)
lista.append('manzana')
print(lista)
otra_lista = lista.copy()
otra_lista.append(5)
print(lista)
In [ ]:
osos = ['grizzly', 'polar', 'de anteojos']
print(osos[0])
print(osos[-1])
for oso in osos:
print(oso)
In [ ]:
for i in range(10):
print(i)
In [ ]:
tupla = ('hola', 'platano')
print(tupla)
otra_tupla = tupla
# otra_tupla[0] = 1
print(tupla)
In [ ]:
osos = ['grizzly', 'polar', 'de anteojos']
# no
for i in range(len(osos)):
print(i+1, osos[i])
print()
# si
for i, oso in enumerate(osos):
print(i + 1, oso)
print()
# si
for i, oso in enumerate(reversed(osos)):
print(i + 1, oso)
# qué pasó
print()
print(list(enumerate(reversed(osos))))
In [ ]:
i, j = (1, 2)
print(j)
In [ ]:
i, *otros = [1, 2, 3]
print(i)
print(otros)
In [ ]:
[x for x in range(0, 100) if x % 3 == 0]
In [ ]:
tuple(x for x in range(0, 100) if x % 3 == 0)
In [ ]:
{x for x in range(0, 100) if x % 3 == 0}
In [ ]:
'hola' is 'hola'
In [ ]:
['hola'] is ['hola']
In [ ]:
list(set([1, 1, 2, 3, 3]))
In [ ]:
mapa = {'hola': 1, 'que': 2, 'hace': 3}
In [ ]:
mapa = {x: x ** 2 for x in range(10)}
print(mapa)
In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt
In [ ]:
x = list(range(100))
y = [i ** 2 for i in x]
plt.figure()
plt.plot(x, y, '-')
plt.show()
Esto es un informe para mi profesor esto es muy importante, por las siguientes razones:
la gráfica anterior es $$ y = x ^ 2 $$
El notebook no es secuencial.
In [ ]:
x = [1]
In [ ]:
x = input()
print(type(x))
print(x)
try:
print(float(x) ** 2)
except ValueError:
print('valor incorrecto')
In [ ]:
from mpl_toolkits.mplot3d import Axes3D
x = list(range(100))
y = list(i ** 2 for i in x)
z = list(i ** 0.5 for i in x)
plt.subplot(111, projection='3d')
plt.plot(x, y, z)
plt.show()
In [ ]: