Skip to content

Commit 136dd2d

Browse files
committed
Update Loop
1 parent 68d190b commit 136dd2d

File tree

2 files changed

+270
-78
lines changed

2 files changed

+270
-78
lines changed

00 Examples/lecture09/loop.ipynb renamed to 00 Examples/lecture09/.ipynb_checkpoints/04 Loop-checkpoint.ipynb

Lines changed: 63 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,18 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 2,
6-
"id": "46d1a4f3",
5+
"execution_count": 5,
6+
"id": "71952932-c31a-4c96-9d85-1bb841b57dfc",
77
"metadata": {},
8-
"outputs": [
9-
{
10-
"name": "stdout",
11-
"output_type": "stream",
12-
"text": [
13-
"w\n",
14-
"e\n",
15-
"l\n",
16-
"c\n",
17-
"o\n",
18-
"m\n",
19-
"e\n"
20-
]
21-
}
22-
],
8+
"outputs": [],
239
"source": [
24-
"data = \"welcome\"\n",
25-
"# print(data)\n",
26-
"\n",
27-
"for i in data:\n",
28-
" print(i)"
10+
"# Date 22 july 2025"
2911
]
3012
},
3113
{
3214
"cell_type": "code",
3315
"execution_count": 4,
34-
"id": "d78d42bb",
16+
"id": "42365ad5-8e08-4c88-9052-f59e47a85541",
3517
"metadata": {},
3618
"outputs": [
3719
{
@@ -47,146 +29,149 @@
4729
"6\n",
4830
"7\n",
4931
"8\n",
50-
"9\n"
32+
"9\n",
33+
"10\n"
5134
]
5235
}
5336
],
5437
"source": [
55-
" # range(endvalue) start 0\n",
56-
" \n",
57-
"for i in range(10):\n",
38+
"# for variable in range(start,end,steps):\n",
39+
" # print output\n",
40+
"\n",
41+
"# print 0 to 10\n",
42+
"\n",
43+
"for i in range(11):\n",
5844
" print(i)"
5945
]
6046
},
6147
{
6248
"cell_type": "code",
63-
"execution_count": 5,
64-
"id": "51b2e9a2",
49+
"execution_count": 6,
50+
"id": "2bcff2d4-e15a-4a55-a84d-66aceea2bc50",
6551
"metadata": {},
6652
"outputs": [
6753
{
6854
"name": "stdout",
6955
"output_type": "stream",
7056
"text": [
71-
"10\n",
72-
"11\n",
7357
"12\n",
7458
"13\n",
7559
"14\n",
7660
"15\n",
7761
"16\n",
7862
"17\n",
7963
"18\n",
80-
"19\n"
64+
"19\n",
65+
"20\n",
66+
"21\n",
67+
"22\n"
8168
]
8269
}
8370
],
8471
"source": [
85-
"# range(startvalue,endvalue)\n",
86-
"for i in range(10,20):\n",
72+
"# range(start,end)\n",
73+
"\n",
74+
"for i in range(12,23):\n",
8775
" print(i)"
8876
]
8977
},
9078
{
9179
"cell_type": "code",
9280
"execution_count": 7,
93-
"id": "c346d721",
81+
"id": "2ea2a7db-67a8-4e39-b6c9-ec2c498ffee2",
9482
"metadata": {},
9583
"outputs": [
9684
{
9785
"name": "stdout",
9886
"output_type": "stream",
9987
"text": [
10088
"1\n",
101-
"4\n",
89+
"3\n",
90+
"5\n",
10291
"7\n",
103-
"10\n",
92+
"9\n",
93+
"11\n",
10494
"13\n",
105-
"16\n",
106-
"19\n"
95+
"15\n",
96+
"17\n"
10797
]
10898
}
10999
],
110100
"source": [
111-
"# range(startvalue,endvalue,step)\n",
112-
"for i in range(1,21,3):\n",
101+
"# range(start,end,step)\n",
102+
"\n",
103+
"for i in range(1,19,2):\n",
113104
" print(i)"
114105
]
115106
},
116107
{
117108
"cell_type": "code",
118109
"execution_count": 11,
119-
"id": "52e27d7f",
110+
"id": "6ee36a57-7fdc-43c3-9203-a732dc3aa4fe",
120111
"metadata": {},
121112
"outputs": [
113+
{
114+
"name": "stdin",
115+
"output_type": "stream",
116+
"text": [
117+
"Enter start number 45\n",
118+
"Enter End Number 55\n"
119+
]
120+
},
122121
{
123122
"name": "stdout",
124123
"output_type": "stream",
125124
"text": [
126-
"b\n",
127-
"86\n"
125+
"45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | "
128126
]
129127
}
130128
],
131129
"source": [
132-
"# chr() number to ascii value\n",
133-
"\n",
134-
"x = 98\n",
135-
"print(chr(x))\n",
136-
"\n",
137-
"# ord() ascii value to number\n",
138-
"\n",
139-
"c = \"V\"\n",
140-
"print(ord(c))"
130+
"# how to take use input\n",
131+
"start = int(input(\"Enter start number \"))\n",
132+
"end = int(input(\"Enter End Number \"))\n",
133+
"for i in range(start,end+1):\n",
134+
" print(i,end=\" | \")"
141135
]
142136
},
143137
{
144138
"cell_type": "code",
145-
"execution_count": 15,
146-
"id": "b281f7b8",
139+
"execution_count": 14,
140+
"id": "91011686-b0dc-4bb7-ba4e-e425e46ade66",
147141
"metadata": {},
148142
"outputs": [
149143
{
150144
"name": "stdout",
151145
"output_type": "stream",
152146
"text": [
153-
"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z "
147+
"a\n",
148+
"116\n"
154149
]
155150
}
156151
],
157152
"source": [
158-
"for i in range(65,91):\n",
159-
" print(chr(i),end=\" \")"
153+
"# https://theasciicode.com.ar/ascii-table-characters.pdf\n",
154+
"# chr() ascii code to char\n",
155+
"print(chr(97))\n",
156+
"# ord() char to ascii code \n",
157+
"print(ord(\"t\"))"
160158
]
161159
},
162160
{
163161
"cell_type": "code",
164-
"execution_count": 18,
165-
"id": "ae1ec09b",
162+
"execution_count": null,
163+
"id": "e011d6a4-a3f2-4509-8962-54e52a1ee13e",
166164
"metadata": {},
167-
"outputs": [
168-
{
169-
"name": "stdout",
170-
"output_type": "stream",
171-
"text": [
172-
"45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|"
173-
]
174-
}
175-
],
165+
"outputs": [],
176166
"source": [
177-
"# how to take user input \n",
178-
"\n",
179-
"start = int(input('enter start value ..'))\n",
180-
"end = int(input('enter end value..'))\n",
181-
"\n",
182-
"for i in range(start,end+1):\n",
183-
" print(i,end=\"|\")"
167+
"start_char = input('Enter Start char - ')\n",
168+
"end_char = input('Enter Start char - ')"
184169
]
185170
}
186171
],
187172
"metadata": {
188173
"kernelspec": {
189-
"display_name": "Python 3",
174+
"display_name": "Python 3 (ipykernel)",
190175
"language": "python",
191176
"name": "python3"
192177
},
@@ -200,7 +185,7 @@
200185
"name": "python",
201186
"nbconvert_exporter": "python",
202187
"pygments_lexer": "ipython3",
203-
"version": "3.12.1"
188+
"version": "3.12.7"
204189
}
205190
},
206191
"nbformat": 4,

0 commit comments

Comments
 (0)