We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac6ffa7 commit 7995671Copy full SHA for 7995671
Roadmap/17 - ITERACIONES/python/ycanas.py
@@ -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
22
23
24
+# ------ Extra
25
26
+# 4). recursive
27
28
+def recursive(n):
29
+ if n == 10:
30
+ print(n)
31
+ return
32
33
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
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