Skip to content

Commit c2ba27a

Browse files
committed
Youtube-PewDiePie
1 parent d6afc00 commit c2ba27a

File tree

2 files changed

+61
-7
lines changed

2 files changed

+61
-7
lines changed

notebooks/python_problems/Python_problems_for_beginners_1.ipynb

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@
189189
"\n",
190190
"Example n=4\n",
191191
"\n",
192-
"0\n",
193-
" 1\n",
194-
" 2\n",
195-
" 3\n",
196-
" 4"
192+
" 0\n",
193+
" 1\n",
194+
" 2\n",
195+
" 3\n",
196+
" 4"
197197
]
198198
},
199199
{
@@ -216,7 +216,61 @@
216216
"execution_count": null,
217217
"metadata": {},
218218
"outputs": [],
219-
"source": []
219+
"source": [
220+
"0 - 1\n",
221+
"1 - 3\n",
222+
"2 - 5\n",
223+
"\n",
224+
"2 * i + 1"
225+
]
226+
},
227+
{
228+
"cell_type": "code",
229+
"execution_count": 64,
230+
"metadata": {},
231+
"outputs": [
232+
{
233+
"name": "stdout",
234+
"output_type": "stream",
235+
"text": [
236+
" * \n",
237+
" * * * \n",
238+
"* * * * * \n"
239+
]
240+
}
241+
],
242+
"source": [
243+
"n = 3\n",
244+
"\n",
245+
"for i in range(n):\n",
246+
" row = '* ' * (2 * i + 1) # calc the * for a given row based formula\n",
247+
" print(row.center(n * 3))"
248+
]
249+
},
250+
{
251+
"cell_type": "code",
252+
"execution_count": 70,
253+
"metadata": {},
254+
"outputs": [
255+
{
256+
"name": "stdout",
257+
"output_type": "stream",
258+
"text": [
259+
" *\n",
260+
" ***\n",
261+
" *****\n",
262+
" *******\n",
263+
"*********\n"
264+
]
265+
}
266+
],
267+
"source": [
268+
"n = 5\n",
269+
"\n",
270+
"for i in range(n):\n",
271+
" print( ' ' * (n-i-1), end='')\n",
272+
" print('*' * (2 * i + 1))"
273+
]
220274
}
221275
],
222276
"metadata": {

notebooks/youtube/Youtube-PewDiePie.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 1,
5+
"execution_count": null,
66
"metadata": {},
77
"outputs": [],
88
"source": [

0 commit comments

Comments
 (0)