Skip to content

Commit 6a82647

Browse files
committed
Module 5
1 parent bfe3e8d commit 6a82647

6 files changed

Lines changed: 38 additions & 207 deletions

05-Methods_and_functions/01_define_and_call_functions.ipynb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,10 @@
5151
},
5252
{
5353
"cell_type": "code",
54-
"execution_count": 3,
54+
"execution_count": null,
5555
"id": "a5fefb4d",
5656
"metadata": {},
57-
"outputs": [
58-
{
59-
"name": "stdout",
60-
"output_type": "stream",
61-
"text": [
62-
"Hello, welcome!\n"
63-
]
64-
}
65-
],
57+
"outputs": [],
6658
"source": [
6759
"greet()"
6860
]

05-Methods_and_functions/02_scope_and_global_keyword.ipynb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,10 @@
8282
},
8383
{
8484
"cell_type": "code",
85-
"execution_count": 1,
85+
"execution_count": null,
8686
"id": "8722c9da",
8787
"metadata": {},
88-
"outputs": [
89-
{
90-
"name": "stdout",
91-
"output_type": "stream",
92-
"text": [
93-
"20\n"
94-
]
95-
}
96-
],
88+
"outputs": [],
9789
"source": [
9890
"x = 10\n",
9991
"\n",

05-Methods_and_functions/05_exercises.ipynb

Lines changed: 18 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,9 @@
2121
},
2222
{
2323
"cell_type": "code",
24-
"execution_count": 1,
25-
"metadata": {},
26-
"outputs": [
27-
{
28-
"name": "stdout",
29-
"output_type": "stream",
30-
"text": [
31-
"Hello, welcome!\n"
32-
]
33-
}
34-
],
24+
"execution_count": null,
25+
"metadata": {},
26+
"outputs": [],
3527
"source": []
3628
},
3729
{
@@ -45,18 +37,9 @@
4537
},
4638
{
4739
"cell_type": "code",
48-
"execution_count": 2,
49-
"metadata": {},
50-
"outputs": [
51-
{
52-
"name": "stdout",
53-
"output_type": "stream",
54-
"text": [
55-
"100\n",
56-
"40\n"
57-
]
58-
}
59-
],
40+
"execution_count": null,
41+
"metadata": {},
42+
"outputs": [],
6043
"source": []
6144
},
6245
{
@@ -70,17 +53,9 @@
7053
},
7154
{
7255
"cell_type": "code",
73-
"execution_count": 3,
74-
"metadata": {},
75-
"outputs": [
76-
{
77-
"name": "stdout",
78-
"output_type": "stream",
79-
"text": [
80-
"30\n"
81-
]
82-
}
83-
],
56+
"execution_count": null,
57+
"metadata": {},
58+
"outputs": [],
8459
"source": []
8560
},
8661
{
@@ -126,17 +101,9 @@
126101
},
127102
{
128103
"cell_type": "code",
129-
"execution_count": 4,
130-
"metadata": {},
131-
"outputs": [
132-
{
133-
"name": "stdout",
134-
"output_type": "stream",
135-
"text": [
136-
"8\n"
137-
]
138-
}
139-
],
104+
"execution_count": null,
105+
"metadata": {},
106+
"outputs": [],
140107
"source": []
141108
},
142109
{
@@ -150,17 +117,9 @@
150117
},
151118
{
152119
"cell_type": "code",
153-
"execution_count": 6,
154-
"metadata": {},
155-
"outputs": [
156-
{
157-
"name": "stdout",
158-
"output_type": "stream",
159-
"text": [
160-
"120\n"
161-
]
162-
}
163-
],
120+
"execution_count": null,
121+
"metadata": {},
122+
"outputs": [],
164123
"source": []
165124
},
166125
{
@@ -174,17 +133,9 @@
174133
},
175134
{
176135
"cell_type": "code",
177-
"execution_count": 5,
178-
"metadata": {},
179-
"outputs": [
180-
{
181-
"name": "stdout",
182-
"output_type": "stream",
183-
"text": [
184-
"8\n"
185-
]
186-
}
187-
],
136+
"execution_count": null,
137+
"metadata": {},
138+
"outputs": [],
188139
"source": []
189140
}
190141
],

05-Methods_and_functions/06_solutions.ipynb

Lines changed: 12 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,9 @@
2121
},
2222
{
2323
"cell_type": "code",
24-
"execution_count": 1,
24+
"execution_count": null,
2525
"metadata": {},
26-
"outputs": [
27-
{
28-
"name": "stdout",
29-
"output_type": "stream",
30-
"text": [
31-
"Hello, welcome!\n"
32-
]
33-
}
34-
],
26+
"outputs": [],
3527
"source": [
3628
"def greet():\n",
3729
" print(\"Hello, welcome!\")\n",
@@ -50,18 +42,9 @@
5042
},
5143
{
5244
"cell_type": "code",
53-
"execution_count": 2,
45+
"execution_count": null,
5446
"metadata": {},
55-
"outputs": [
56-
{
57-
"name": "stdout",
58-
"output_type": "stream",
59-
"text": [
60-
"100\n",
61-
"40\n"
62-
]
63-
}
64-
],
47+
"outputs": [],
6548
"source": [
6649
"def calculate_area(length=10, width=10):\n",
6750
" area = length * width\n",
@@ -82,17 +65,9 @@
8265
},
8366
{
8467
"cell_type": "code",
85-
"execution_count": 3,
68+
"execution_count": null,
8669
"metadata": {},
87-
"outputs": [
88-
{
89-
"name": "stdout",
90-
"output_type": "stream",
91-
"text": [
92-
"30\n"
93-
]
94-
}
95-
],
70+
"outputs": [],
9671
"source": [
9772
"def add_numbers(num1, num2, num3):\n",
9873
" sum = num1 + num2 + num3\n",
@@ -163,17 +138,9 @@
163138
},
164139
{
165140
"cell_type": "code",
166-
"execution_count": 4,
141+
"execution_count": null,
167142
"metadata": {},
168-
"outputs": [
169-
{
170-
"name": "stdout",
171-
"output_type": "stream",
172-
"text": [
173-
"8\n"
174-
]
175-
}
176-
],
143+
"outputs": [],
177144
"source": [
178145
"count = 0\n",
179146
"\n",
@@ -199,17 +166,9 @@
199166
},
200167
{
201168
"cell_type": "code",
202-
"execution_count": 6,
169+
"execution_count": null,
203170
"metadata": {},
204-
"outputs": [
205-
{
206-
"name": "stdout",
207-
"output_type": "stream",
208-
"text": [
209-
"120\n"
210-
]
211-
}
212-
],
171+
"outputs": [],
213172
"source": [
214173
"def apply_operation(a, b, operation):\n",
215174
" result = operation(a, b)\n",
@@ -242,17 +201,9 @@
242201
},
243202
{
244203
"cell_type": "code",
245-
"execution_count": 5,
204+
"execution_count": null,
246205
"metadata": {},
247-
"outputs": [
248-
{
249-
"name": "stdout",
250-
"output_type": "stream",
251-
"text": [
252-
"8\n"
253-
]
254-
}
255-
],
206+
"outputs": [],
256207
"source": [
257208
"numbers = [1, 2, 3, 4, 5]\n",
258209
"squared_numbers = list(map(lambda x: x**2, numbers))\n",

05-Methods_and_functions/08_milestone_project_grade_solution.ipynb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,9 @@
3838
},
3939
{
4040
"cell_type": "code",
41-
"execution_count": 1,
41+
"execution_count": null,
4242
"metadata": {},
43-
"outputs": [
44-
{
45-
"name": "stdout",
46-
"output_type": "stream",
47-
"text": [
48-
"\n",
49-
"Average Grade: 4.92\n",
50-
"Letter Grade: F\n"
51-
]
52-
}
53-
],
43+
"outputs": [],
5444
"source": [
5545
"def calculate_average_grade():\n",
5646
" num_subjects = int(input(\"Enter the number of subjects: \"))\n",

05-Methods_and_functions/10_milestone_project_calculator_solution.ipynb

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -37,54 +37,9 @@
3737
},
3838
{
3939
"cell_type": "code",
40-
"execution_count": 6,
40+
"execution_count": null,
4141
"metadata": {},
42-
"outputs": [
43-
{
44-
"name": "stdout",
45-
"output_type": "stream",
46-
"text": [
47-
"\n",
48-
"---- Simple Calculator ----\n",
49-
"1. Addition (+)\n",
50-
"2. Subtraction (-)\n",
51-
"3. Multiplication (*)\n",
52-
"4. Division (/)\n",
53-
"5. Exponentiation (^)\n",
54-
"6. Exit\n",
55-
"Result: 5.0 ^ 8.0 = 390625.0\n",
56-
"\n",
57-
"---- Simple Calculator ----\n",
58-
"1. Addition (+)\n",
59-
"2. Subtraction (-)\n",
60-
"3. Multiplication (*)\n",
61-
"4. Division (/)\n",
62-
"5. Exponentiation (^)\n",
63-
"6. Exit\n",
64-
"Result: 5.0 + 8.0 = 13.0\n",
65-
"\n",
66-
"---- Simple Calculator ----\n",
67-
"1. Addition (+)\n",
68-
"2. Subtraction (-)\n",
69-
"3. Multiplication (*)\n",
70-
"4. Division (/)\n",
71-
"5. Exponentiation (^)\n",
72-
"6. Exit\n"
73-
]
74-
},
75-
{
76-
"ename": "ValueError",
77-
"evalue": "could not convert string to float: ''",
78-
"output_type": "error",
79-
"traceback": [
80-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
81-
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
82-
"Cell \u001b[1;32mIn[6], line 53\u001b[0m\n\u001b[0;32m 50\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m 51\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39mInvalid choice. Please try again.\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m---> 53\u001b[0m calculator()\n",
83-
"Cell \u001b[1;32mIn[6], line 32\u001b[0m, in \u001b[0;36mcalculator\u001b[1;34m()\u001b[0m\n\u001b[0;32m 29\u001b[0m \u001b[39mprint\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39mExiting calculator...\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m 30\u001b[0m \u001b[39mbreak\u001b[39;00m\n\u001b[1;32m---> 32\u001b[0m num1 \u001b[39m=\u001b[39m \u001b[39mfloat\u001b[39;49m(\u001b[39minput\u001b[39;49m(\u001b[39m\"\u001b[39;49m\u001b[39mEnter the first number: \u001b[39;49m\u001b[39m\"\u001b[39;49m))\n\u001b[0;32m 33\u001b[0m num2 \u001b[39m=\u001b[39m \u001b[39mfloat\u001b[39m(\u001b[39minput\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39mEnter the second number: \u001b[39m\u001b[39m\"\u001b[39m))\n\u001b[0;32m 35\u001b[0m \u001b[39mif\u001b[39;00m choice \u001b[39m==\u001b[39m \u001b[39m'\u001b[39m\u001b[39m1\u001b[39m\u001b[39m'\u001b[39m:\n",
84-
"\u001b[1;31mValueError\u001b[0m: could not convert string to float: ''"
85-
]
86-
}
87-
],
42+
"outputs": [],
8843
"source": [
8944
"def add(a, b):\n",
9045
" return a + b\n",

0 commit comments

Comments
 (0)