Skip to content

Commit 6b2a5ce

Browse files
committed
dia 2
1 parent e91798b commit 6b2a5ce

5 files changed

+96
-0
lines changed

11-Bucles.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
edad =0
2+
while edad<=20:
3+
if edad == 15:
4+
edad= +1
5+
#continue
6+
break
7+
print 'Tienes '+ str(edad)
8+
edad= edad+1

11-Bucles2.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
lista=["elemento 1", "elemento 2","elemento 3"]
2+
3+
for item in lista:
4+
print item
5+
6+
for item in "Cadene":
7+
print item

12-Funciones.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
def mi_funciones(num1=0,num2=0):
2+
print num1 + num2
3+
4+
mi_funciones(1, 2)
5+
mi_funciones()
6+
mi_funciones(3)
7+
8+
def mi_funciones2(cad,v=2):
9+
print cad*v
10+
11+
mi_funciones2("Python")
12+
mi_funciones2("Python",5)
13+
#funciones con tuplas
14+
def mi_funciones3(cad,v=2,*algomas):
15+
print cad*v
16+
for cadena in algomas:
17+
print cadena
18+
19+
#funciones con tuplas
20+
mi_funciones3("Python",5,"hola","adios", "como estas")
21+
#funciones con diccionario
22+
def mi_funciones4(cad,v=2,**algomas):
23+
print cad*v
24+
print algomas['Cadena1']
25+
print algomas['Cadena2']
26+
print algomas['Cadena3']
27+
28+
29+
mi_funciones4("Python",5,Cadena1="hola",Cadena2="adios",Cadena3="como estas")
30+
31+
#funciones con return
32+
def mi_funciones5(num1=0,num2=0):
33+
return num1 + num2
34+
print mi_funciones5(1, 2)
35+
36+

13-ClasesyObjetos.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Humano:
2+
def __init__(self,edad=25):
3+
self.edad =edad
4+
print "Soy nuevo objecto"
5+
6+
def hablar(self,mensaje):
7+
print self.edad
8+
print mensaje
9+
10+
pedro = Humano(26)
11+
raul = Humano()
12+
13+
print 'Soy Pedro y tengo ', pedro.edad
14+
print 'Soy Raul y tengo ', raul.edad
15+
16+
pedro.hablar("hola")
17+
raul.hablar("hola pedro")

14-Henrencias.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class Humano:
2+
def __init__(self,edad=25):
3+
self.edad =edad
4+
5+
def hablar(self,mensaje):
6+
print self.edad
7+
print mensaje
8+
9+
class IngSistemas(Humano):
10+
def __init__(self):
11+
Humano.__init__(self,10)
12+
13+
def programar(self,lenguaje):
14+
print 'voy programa en',lenguaje
15+
16+
class LicDerecho(Humano):
17+
def estudiarCaso(self,de):
18+
print 'debo estudiar el caso de ',de
19+
20+
21+
pedro = IngSistemas()
22+
raul = LicDerecho()
23+
24+
pedro.hablar("hola")
25+
pedro.programar("Python")
26+
27+
raul.hablar("hola pedro")
28+
raul.estudiarCaso("pedro")

0 commit comments

Comments
 (0)