Skip to content

Commit 7995671

Browse files
committed
#17 - Python
1 parent ac6ffa7 commit 7995671

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# ------ I. Ejercicio
2+
3+
# 1). for
4+
5+
for i in range(1, 11):
6+
print(i)
7+
8+
# 2). while
9+
10+
c: int = 1
11+
12+
while c < 11:
13+
print(c)
14+
c = c + 1
15+
16+
# 3).
17+
18+
c: list[int] = range(1, 11)
19+
20+
for i in c:
21+
print(i)
22+
23+
24+
# ------ Extra
25+
26+
# 4). recursive
27+
28+
def recursive(n):
29+
if n == 10:
30+
print(n)
31+
return
32+
33+
print(n)
34+
recursive(n + 1)
35+
36+
37+
recursive(1)
38+
39+
# 5). iter
40+
numbers = iter(range(1, 11))
41+
print(*numbers)
42+
43+
# 6). iter - next
44+
45+
numbers = iter(range(1, 11))
46+
47+
while True:
48+
try:
49+
print(next(numbers))
50+
except StopIteration:
51+
break
52+
53+
# 7). list comprehension
54+
55+
[print(i) for i in range(1, 11)]

0 commit comments

Comments
 (0)