This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Humano: | |
def __init__(self,edad): | |
self.edad = edad | |
def conversar(self,mensaje): | |
print (mensaje) | |
class ISC(Humano): | |
def __init__(self): | |
print("Hola") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gcd (x,y): | |
r = 0 | |
while y > 0: | |
r = y | |
y = x%y | |
x = r | |
return x | |
#main program below | |
print("Problema 10 (Examen)") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_bananas(nombre): | |
abierto = open(nombre,'r') | |
t = 0 | |
for line in abierto: | |
print("looking at: ",line) | |
line = line.lower() | |
index = line.find('banana') | |
while index > -1: | |
t = t + 1 | |
index = line.find("banana",index+1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Babilonia(n): | |
a = n | |
b = 0 | |
while b > (n-.00001) or b < (n+.00001): | |
a = n/a | |
b = a*a | |
if b > (n-.00001) and b < (n+.00001): | |
return a | |
else: | |
a = (n/a+a)/2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sumsquares_list(l): | |
t = 0 | |
for i in l: | |
i = i * i | |
t = t + i | |
return t | |
#main program below | |
print("Problema 7 (Examen)") | |
l = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibonacci(n): | |
if n == 0: | |
return 0 | |
elif n == 1: | |
return 1 | |
else: | |
f = (fibonacci(n-1))+(fibonacci(n-2)) | |
return f | |
#main program below |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def smallest_of_four(l): | |
m = min(l) | |
return m | |
#main program below | |
print("Problema 5(Examen)") | |
ñ = 4 | |
l = [] | |
for i in range(ñ): | |
v = float(input("Ingresa un número")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def promedio_lista(l): | |
p = 0 | |
for i in l: | |
p = p + i | |
t = p/x | |
return t | |
#main program below | |
l = [] | |
print("Problema 4 (Examen)") | |
x = int(input("Ingresa el número de valores que quieres que existan en tu lista ")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial(x): | |
a = x | |
while a > 1: | |
a = a - 1 | |
x = x * a | |
return x | |
#main program below | |
print("Problema 3 (Examen)") | |
x = int(input("Ingresa un número")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def triangulo(t): | |
z = "" | |
a = 0 | |
n = t | |
while t>0: | |
l.append(t) | |
t = t - 1 | |
pass | |
for element in l: | |
a = a + 1 |
NewerOlder