Skip to content

Commit 4af21d9

Browse files
committed
Fixed Potential warning and errors
1 parent 1ea9bfe commit 4af21d9

File tree

2 files changed

+49
-39
lines changed

2 files changed

+49
-39
lines changed

1-Data-types/4-sets/set.ipynb

+17-10
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,18 @@
7676
},
7777
{
7878
"cell_type": "code",
79-
"execution_count": 10,
79+
"execution_count": 1,
8080
"metadata": {},
8181
"outputs": [
8282
{
83-
"name": "stdout",
84-
"output_type": "stream",
85-
"text": [
86-
"['Lahore', 'Karachi', 'Peshawar']\n"
87-
]
83+
"data": {
84+
"text/plain": [
85+
"['Lahore', 'Karachi', 'Peshawar', 'Islamabad']"
86+
]
87+
},
88+
"execution_count": 1,
89+
"metadata": {},
90+
"output_type": "execute_result"
8891
}
8992
],
9093
"source": [
@@ -96,6 +99,8 @@
9699
" {\"name\": \"Nauman\", \"city\": \"Karachi\"},\n",
97100
" {\"name\": \"Akhtar\", \"city\": \"Peshawar\"},\n",
98101
" {\"name\": \"Mehboob\", \"city\": \"Lahore\"},\n",
102+
" {\"name\": \"Shahzain\", \"city\": \"Islamabad\"},\n",
103+
" {\"name\": \"Imran\", \"city\": \"Peshawar\"},\n",
99104
"]\n",
100105
"\n",
101106
"unique_cities: list[str] = []\n",
@@ -118,16 +123,16 @@
118123
},
119124
{
120125
"cell_type": "code",
121-
"execution_count": 16,
126+
"execution_count": 2,
122127
"metadata": {},
123128
"outputs": [
124129
{
125130
"data": {
126131
"text/plain": [
127-
"{'Karachi', 'Lahore', 'Peshawar'}"
132+
"{'Islamabad', 'Karachi', 'Lahore', 'Peshawar'}"
128133
]
129134
},
130-
"execution_count": 16,
135+
"execution_count": 2,
131136
"metadata": {},
132137
"output_type": "execute_result"
133138
}
@@ -139,6 +144,8 @@
139144
" {\"name\": \"Nauman\", \"city\": \"Karachi\"},\n",
140145
" {\"name\": \"Akhtar\", \"city\": \"Peshawar\"},\n",
141146
" {\"name\": \"Mehboob\", \"city\": \"Lahore\"},\n",
147+
" {\"name\": \"Shahzain\", \"city\": \"Islamabad\"},\n",
148+
" {\"name\": \"Imran\", \"city\": \"Peshawar\"},\n",
142149
"]\n",
143150
"\n",
144151
"cities: set[str] = set()\n",
@@ -257,7 +264,7 @@
257264
"name": "python",
258265
"nbconvert_exporter": "python",
259266
"pygments_lexer": "ipython3",
260-
"version": "3.12.0"
267+
"version": "3.12.6"
261268
}
262269
},
263270
"nbformat": 4,

1-Data-types/5-dictionary-methods/dict.ipynb

+32-29
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@
99
},
1010
{
1111
"cell_type": "code",
12-
"execution_count": 1,
12+
"execution_count": 7,
1313
"metadata": {},
1414
"outputs": [
1515
{
1616
"name": "stdout",
1717
"output_type": "stream",
1818
"text": [
19-
"{'name': 'Sarmad', 'email': '[email protected]', 'age': 19}\n"
19+
"{'name': 'Sarmad', 'email': '[email protected]', 'age': 20}\n"
2020
]
2121
}
2222
],
2323
"source": [
2424
"from typing import Union\n",
2525
"\n",
26-
"type_user_dict = Union[dict[str, str | int], dict[str, str]]\n",
26+
"UserDictType = Union[dict[str, str | int]]\n",
2727
"\n",
28-
"user: type_user_dict = {\"name\": \"Sarmad\", \"email\": \"[email protected]\", \"age\": 19}\n",
28+
"user: UserDictType = {\"name\": \"Sarmad\", \"email\": \"[email protected]\", \"age\": 20}\n",
2929
"\n",
3030
"print(user)"
3131
]
@@ -39,7 +39,7 @@
3939
},
4040
{
4141
"cell_type": "code",
42-
"execution_count": 2,
42+
"execution_count": 8,
4343
"metadata": {},
4444
"outputs": [
4545
{
@@ -48,7 +48,7 @@
4848
"'Male'"
4949
]
5050
},
51-
"execution_count": 2,
51+
"execution_count": 8,
5252
"metadata": {},
5353
"output_type": "execute_result"
5454
}
@@ -68,7 +68,7 @@
6868
},
6969
{
7070
"cell_type": "code",
71-
"execution_count": 3,
71+
"execution_count": 9,
7272
"metadata": {},
7373
"outputs": [
7474
{
@@ -77,7 +77,7 @@
7777
7878
]
7979
},
80-
"execution_count": 3,
80+
"execution_count": 9,
8181
"metadata": {},
8282
"output_type": "execute_result"
8383
}
@@ -97,7 +97,7 @@
9797
},
9898
{
9999
"cell_type": "code",
100-
"execution_count": 4,
100+
"execution_count": 10,
101101
"metadata": {},
102102
"outputs": [
103103
{
@@ -106,7 +106,7 @@
106106
107107
]
108108
},
109-
"execution_count": 4,
109+
"execution_count": 10,
110110
"metadata": {},
111111
"output_type": "execute_result"
112112
}
@@ -126,7 +126,7 @@
126126
},
127127
{
128128
"cell_type": "code",
129-
"execution_count": 5,
129+
"execution_count": 11,
130130
"metadata": {},
131131
"outputs": [
132132
{
@@ -135,7 +135,7 @@
135135
"dict_keys(['name', 'email', 'age', 'gender'])"
136136
]
137137
},
138-
"execution_count": 5,
138+
"execution_count": 11,
139139
"metadata": {},
140140
"output_type": "execute_result"
141141
}
@@ -153,16 +153,16 @@
153153
},
154154
{
155155
"cell_type": "code",
156-
"execution_count": 6,
156+
"execution_count": 12,
157157
"metadata": {},
158158
"outputs": [
159159
{
160160
"data": {
161161
"text/plain": [
162-
"dict_values(['Sarmad', '[email protected]', 19, 'Male'])"
162+
"dict_values(['Sarmad', '[email protected]', 20, 'Male'])"
163163
]
164164
},
165-
"execution_count": 6,
165+
"execution_count": 12,
166166
"metadata": {},
167167
"output_type": "execute_result"
168168
}
@@ -180,16 +180,16 @@
180180
},
181181
{
182182
"cell_type": "code",
183-
"execution_count": 7,
183+
"execution_count": 13,
184184
"metadata": {},
185185
"outputs": [
186186
{
187187
"data": {
188188
"text/plain": [
189-
"{'name': 'Sarmad', 'email': '[email protected]', 'age': 19}"
189+
"{'name': 'Sarmad', 'email': '[email protected]', 'age': 20}"
190190
]
191191
},
192-
"execution_count": 7,
192+
"execution_count": 13,
193193
"metadata": {},
194194
"output_type": "execute_result"
195195
}
@@ -209,7 +209,7 @@
209209
},
210210
{
211211
"cell_type": "code",
212-
"execution_count": 8,
212+
"execution_count": 14,
213213
"metadata": {},
214214
"outputs": [
215215
{
@@ -218,7 +218,7 @@
218218
"{}"
219219
]
220220
},
221-
"execution_count": 8,
221+
"execution_count": 14,
222222
"metadata": {},
223223
"output_type": "execute_result"
224224
}
@@ -238,14 +238,14 @@
238238
},
239239
{
240240
"cell_type": "code",
241-
"execution_count": 9,
241+
"execution_count": 24,
242242
"metadata": {},
243243
"outputs": [
244244
{
245245
"name": "stdout",
246246
"output_type": "stream",
247247
"text": [
248-
"Six Seven Two Nine One Seven Eight Three Nine Two One \n"
248+
"Seven One Nine Eight One Six Three One \n"
249249
]
250250
}
251251
],
@@ -268,7 +268,10 @@
268268
"user_input = input(\"Phone Number: \")\n",
269269
"\n",
270270
"for ch in user_input:\n",
271-
" output += characters.get(ch, \"\") + \" \"\n",
271+
" if not ch in characters:\n",
272+
" pass\n",
273+
" else:\n",
274+
" output += characters.get(ch, \"\") + \" \" # Adding a space after each character\n",
272275
"print(output)"
273276
]
274277
},
@@ -283,25 +286,25 @@
283286
},
284287
{
285288
"cell_type": "code",
286-
"execution_count": 6,
289+
"execution_count": 26,
287290
"metadata": {},
288291
"outputs": [
289292
{
290293
"name": "stdout",
291294
"output_type": "stream",
292295
"text": [
293-
"Name :Sarmad\n",
294-
"Email [email protected]\n",
296+
"Name : Sarmad\n",
297+
"Email: [email protected]\n",
295298
"Age: 19\n"
296299
]
297300
}
298301
],
299302
"source": [
300-
"user: type_user_dict = {\"name\": \"Sarmad\", \"email\": \"[email protected]\", \"age\": 19}\n",
303+
"user: UserDictType = {\"name\": \"Sarmad\", \"email\": \"[email protected]\", \"age\": 19}\n",
301304
"\n",
302305
"\n",
303306
"def user_details(name: str, email: str, age: int) -> None:\n",
304-
" print(f\"Name :{name}\\nEmail {email}\\nAge: {age}\")\n",
307+
" print(f\"Name : {name}\\nEmail: {email}\\nAge: {age}\")\n",
305308
"\n",
306309
"\n",
307310
"user_details(**user)"
@@ -383,7 +386,7 @@
383386
"name": "python",
384387
"nbconvert_exporter": "python",
385388
"pygments_lexer": "ipython3",
386-
"version": "3.12.0"
389+
"version": "3.12.6"
387390
}
388391
},
389392
"nbformat": 4,

0 commit comments

Comments
 (0)