Skip to content

Commit 9a7af89

Browse files
committed
Add Parcial 1
1 parent 6399833 commit 9a7af89

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/examenes/parcial1.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Examen Parcial 1 Algoritmos y Estructuras 2 Seccion 305C1
2+
3+
# ----- Programacion Modular -----
4+
5+
def factorial(numero):
6+
fact = 1
7+
for i in range (1, numero + 1):
8+
fact *= i
9+
return (fact)
10+
11+
def coseno(num, termino):
12+
bandera = True
13+
result = 1
14+
15+
if(termino % 2 == 0):
16+
for i in range (2, termino + 2, 2):
17+
if(bandera):
18+
result -= pow(num, i) / factorial(i)
19+
bandera = False
20+
else:
21+
result += pow(num, i) / factorial(i)
22+
bandera = True
23+
24+
if((termino % 2 == 1) & (termino > 1)):
25+
for i in range (2, termino + 2, 2):
26+
if(bandera):
27+
result -= pow(num, i) / factorial(i)
28+
bandera = False
29+
else:
30+
result += pow(num, i) / factorial(i)
31+
bandera = True
32+
33+
print('El valor de termino',termino ,'es:', result)
34+
35+
36+
37+
num1 = int(input('Ingrese un termino de la serie: '))
38+
numF = int(input('Coseno de: '))
39+
"""
40+
num2 = int(input('Ingrese la aproximacion de la serie hasta un n dado: '))
41+
num3 = int(input('Ingrese la toleracia hasta donde llegara la serie: ')) """
42+
43+
coseno(numF, num1)

0 commit comments

Comments
 (0)