Sunteți pe pagina 1din 5

26/7/23, 10:03 Untitled4 - Jupyter Notebook

In [1]:

num = 1
con = 0
while(num <= 100):
if(num % 10 == 0):
print("")
p = num
i = 1
while(i <= p):
r = p % i
if (r == 0):
con = con + 1
i = i + 1
if(con <= 2):
print("\t",p,end=" ")
con = 0
i = 0
num = num + 1

1 2 3 5 7
11 13 17 19
23 29
31 37
41 43 47
53 59
61 67
71 73 79
83 89
97

In [3]:

for i in range(501, 551):


print(i, end=" ")
if(i % 10 == 0):
print()

501 502 503 504 505 506 507 508 509 510
511 512 513 514 515 516 517 518 519 520
521 522 523 524 525 526 527 528 529 530
531 532 533 534 535 536 537 538 539 540
541 542 543 544 545 546 547 548 549 550

localhost:8888/notebooks/Untitled4.ipynb?kernel_name=python3 1/5
26/7/23, 10:03 Untitled4 - Jupyter Notebook

In [6]:

n = int(input("Ingrese un numeero"))
for i in range (0, 13):
print(i," ",i,"por",n,"es",(i*n))
else:
print("Finalizamos")

Ingrese un numeero7
0 0 por 7 es 0
1 1 por 7 es 7
2 2 por 7 es 14
3 3 por 7 es 21
4 4 por 7 es 28
5 5 por 7 es 35
6 6 por 7 es 42
7 7 por 7 es 49
8 8 por 7 es 56
9 9 por 7 es 63
10 10 por 7 es 70
11 11 por 7 es 77
12 12 por 7 es 84
Finalizamos

In [9]:

n = int(input("Ingrese n: "))
a = -1
b = 1
for i in range(1, n+1):
c = a + b
print(c, end=" // ")
a = b
b = c

Ingrese n: 100
0 // 1 // 1 // 2 // 3 // 5 // 8 // 13 // 21 // 34 // 55 // 89 // 144 // 23
3 // 377 // 610 // 987 // 1597 // 2584 // 4181 // 6765 // 10946 // 17711
// 28657 // 46368 // 75025 // 121393 // 196418 // 317811 // 514229 // 8320
40 // 1346269 // 2178309 // 3524578 // 5702887 // 9227465 // 14930352 // 2
4157817 // 39088169 // 63245986 // 102334155 // 165580141 // 267914296 //
433494437 // 701408733 // 1134903170 // 1836311903 // 2971215073 // 480752
6976 // 7778742049 // 12586269025 // 20365011074 // 32951280099 // 5331629
1173 // 86267571272 // 139583862445 // 225851433717 // 365435296162 // 591
286729879 // 956722026041 // 1548008755920 // 2504730781961 // 40527395378
81 // 6557470319842 // 10610209857723 // 17167680177565 // 27777890035288
// 44945570212853 // 72723460248141 // 117669030460994 // 190392490709135
// 308061521170129 // 498454011879264 // 806515533049393 // 13049695449286
57 // 2111485077978050 // 3416454622906707 // 5527939700884757 // 89443943
23791464 // 14472334024676221 // 23416728348467685 // 37889062373143906 //
61305790721611591 // 99194853094755497 // 160500643816367088 // 2596954969
11122585 // 420196140727489673 // 679891637638612258 // 110008777836610193
1 // 1779979416004714189 // 2880067194370816120 // 4660046610375530309 //
7540113804746346429 // 12200160415121876738 // 19740274219868223167 // 319
40434634990099905 // 51680708854858323072 // 83621143489848422977 // 13530
1852344706746049 // 218922995834555169026 //

localhost:8888/notebooks/Untitled4.ipynb?kernel_name=python3 2/5
26/7/23, 10:03 Untitled4 - Jupyter Notebook

In [10]:

def fibonacci(n):
if (n==0):
return 0
if (n==1):
return 1
return(fibonacci(n-1)+fibonacci(n-2))

n = int(input("Ingrese n: "))
for i in range(0, n):
print(fibonacci(i),end=" ")

Ingrese n: 13
0 1 1 2 3 5 8 13 21 34 55 89 144

In [12]:

n = int(input("Ingrese un numero: "))


acum = 1
for i in range(0,n):
print((i+1),end=" ")
acum = acum * (i+1)
print(" = ", acum)

Ingrese un numero: 5
1 2 3 4 5 = 120

In [14]:

def factorial(n):
if (n>0):
return (n *factorial(n-1))
else:
return 1
n = int(input("Ingrese n: "))
for i in range(1, n+1):
print(factorial(i), end=" ")

Ingrese n: 5
1 2 6 24 120

In [17]:

num1 = 4
if(num1>=0 and num1<=5):
print("Buen ingreso")
else:
print("Mal ingreso")
if(num1<0 or num1>5):
print("Mal ingreso")
else:
print("Buen ingreso")

Buen ingreso
Buen ingreso

localhost:8888/notebooks/Untitled4.ipynb?kernel_name=python3 3/5
26/7/23, 10:03 Untitled4 - Jupyter Notebook

In [18]:

if(num>=0 and num1>=5):


print("Buen ingreso")
else:
print("Mal ingreso")
if(num1<0 or num1>5):
print("Mal ingreso")
else:
print("Buen ingreso")
## bloque 2
if(num1>=-1 and num1<6):
print("Buen ingreso")
else:
print("Mal ingreso")
if(num1<=-1 or num1>6):
print("Mal ingreso")
else:
print("Buen ingreso")
## bloque 3
if not(num1>-1 and num1<6):
print("Mal ingreso")
else:
print("Buen ingreso")
if not(num1<0 or num1<5):
print("Buen ingreso")
else:
print("Mal ingreso")

Mal ingreso
Buen ingreso
Buen ingreso
Buen ingreso
Buen ingreso
Mal ingreso

In [19]:

print("LIBRETA ESCOLAR")
print("ASIGNATURA : PROGRAMACION")
acum = 0
i = 0
promedio = 0.0
while(i<3):
print("nota [",(i+1),"]", end=" ")
nota = int(input("Ingrese: "))
acum = acum + nota
i = i + 1
promedio = acum / i
print("Promedio: ",promedio)

LIBRETA ESCOLAR
ASIGNATURA : PROGRAMACION
nota [ 1 ] Ingrese: 20
nota [ 2 ] Ingrese: 18
nota [ 3 ] Ingrese: 19
Promedio: 19.0

localhost:8888/notebooks/Untitled4.ipynb?kernel_name=python3 4/5
26/7/23, 10:03 Untitled4 - Jupyter Notebook

In [24]:

print("LIBRETA ESCOLAR")
print("Asignatura: Progrmación")
acum, i = (0, 0)
nota, promedio = (0, 0.0)
print("Ingrese las notas a continuacion, -99 para finalizar")
print("nota [",(i+1),"]", end=" ")
nota = int(input("Ingrese: "))
while(nota!=-99):
acum = acum + nota
i = i + 1
print("nota [",(i+1),"]", end=" ")
nota = int(input("Ingrese: "))
if(i>0):
promedio = acum / i
print("Promedio: ",promedio)
else:
print("Finalizo el programa")

LIBRETA ESCOLAR
Asignatura: Progrmación
Ingrese las notas a continuacion, -99 para finalizar
nota [ 1 ] Ingrese: 19
nota [ 2 ] Ingrese: 18
nota [ 3 ] Ingrese: 20
nota [ 4 ] Ingrese: -99
Promedio: 19.0

In [25]:

print("forma 1")
i = 1
acum1 = 0
while(i<=10):
acum1 = acum1 + i
i = i + 1
print(acum1, end=" ")
print(" ")
print("forma 2")
acum2 = 0
for i in range (1, 11, 1):
acum2 = acum2 + i
print(acum2, end= " ")

forma 1
1 3 6 10 15 21 28 36 45 55
forma 2
1 3 6 10 15 21 28 36 45 55

In [ ]:

localhost:8888/notebooks/Untitled4.ipynb?kernel_name=python3 5/5

S-ar putea să vă placă și