Skip to content

Commit c4209c6

Browse files
committed
exercise added
1 parent 60f5758 commit c4209c6

File tree

1 file changed

+76
-32
lines changed

1 file changed

+76
-32
lines changed

python_for_everyone.ipynb

Lines changed: 76 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
{
4242
"cell_type": "code",
43-
"execution_count": 120,
43+
"execution_count": 146,
4444
"metadata": {},
4545
"outputs": [],
4646
"source": [
@@ -66,17 +66,17 @@
6666
},
6767
{
6868
"cell_type": "code",
69-
"execution_count": 121,
69+
"execution_count": 161,
7070
"metadata": {},
7171
"outputs": [
7272
{
7373
"name": "stdout",
7474
"output_type": "stream",
7575
"text": [
76-
"Welcome to Python!\n",
7776
"Hello, World!\n",
7877
"Hello, World !\n",
79-
"Learn python in 2019\n",
78+
"Welcome to Python!\n",
79+
"Learn python in 2019\n",
8080
"Welcome to Python for Everyone\n",
8181
"Welcome to Python for Everyone\n"
8282
]
@@ -85,12 +85,13 @@
8585
"source": [
8686
"# Printing in Python\n",
8787
"\n",
88-
"print(\"Welcome to Python!\")\n",
88+
"\n",
8989
"print('Hello, World!')\n",
9090
"print('Hello,', \"World\", \"!\")\n",
91-
"print('Learn python in ', 2019)\n",
91+
"print(\"Welcome to Python!\")\n",
92+
"print('Learn python in', 2019)\n",
9293
"print('Welcome to Python for Everyone')\n",
93-
"print('Welcome','to', 'Python','for','Everyone')"
94+
"print('Welcome','to', 'Python','for','Everyone')\n"
9495
]
9596
},
9697
{
@@ -117,18 +118,18 @@
117118
},
118119
{
119120
"cell_type": "code",
120-
"execution_count": 122,
121+
"execution_count": 162,
121122
"metadata": {},
122123
"outputs": [
123124
{
124125
"name": "stdout",
125126
"output_type": "stream",
126127
"text": [
127-
"Asabeneh\n",
128-
"Yetayeh\n",
129-
"Helsinki\n",
130-
"250\n",
131-
"True\n"
128+
"First name: Asabeneh\n",
129+
"Last name: Yetayeh\n",
130+
"Country: Helsinki\n",
131+
"Age: 250\n",
132+
"Married: True\n"
132133
]
133134
}
134135
],
@@ -140,11 +141,47 @@
140141
"country = \"Helsinki\"\n",
141142
"age = 250\n",
142143
"is_married = True\n",
143-
"print(first_name)\n",
144-
"print(last_name)\n",
145-
"print(country)\n",
146-
"print(age)\n",
147-
"print(is_married)"
144+
"# Printing the values stored in the variables\n",
145+
"print('First name:', first_name)\n",
146+
"print('Last name: ', last_name)\n",
147+
"print('Country: ', country)\n",
148+
"print('Age: ', age)\n",
149+
"print('Married: ', is_married)"
150+
]
151+
},
152+
{
153+
"cell_type": "markdown",
154+
"metadata": {},
155+
"source": [
156+
"Variable can also be declared in one line:"
157+
]
158+
},
159+
{
160+
"cell_type": "code",
161+
"execution_count": 163,
162+
"metadata": {},
163+
"outputs": [
164+
{
165+
"name": "stdout",
166+
"output_type": "stream",
167+
"text": [
168+
"Asabeneh Yetayeh Helsink 250 True\n",
169+
"First name: Asabeneh\n",
170+
"Last name: Yetayeh\n",
171+
"Country: Helsink\n",
172+
"Age: 250\n",
173+
"Married: True\n"
174+
]
175+
}
176+
],
177+
"source": [
178+
"first_name, last_name, country, age, is_married = 'Asabeneh', 'Yetayeh', 'Helsink', 250, True\n",
179+
"print(first_name, last_name, country, age, is_married)\n",
180+
"print('First name:', first_name)\n",
181+
"print('Last name: ', last_name)\n",
182+
"print('Country: ', country)\n",
183+
"print('Age: ', age)\n",
184+
"print('Married: ', is_married)"
148185
]
149186
},
150187
{
@@ -161,7 +198,8 @@
161198
"7. Declare a city variable and assign a value to it\n",
162199
"8. Declare a variable is_married and assign a value to it\n",
163200
"9. Declare a variable is_true and assign a value to it\n",
164-
"10. Declare a variable is_light_on and assign a value to it"
201+
"10. Declare a variable is_light_on and assign a value to it\n",
202+
"11. Declare multiple variable on one line"
165203
]
166204
},
167205
{
@@ -174,7 +212,7 @@
174212
},
175213
{
176214
"cell_type": "code",
177-
"execution_count": 123,
215+
"execution_count": 164,
178216
"metadata": {},
179217
"outputs": [
180218
{
@@ -246,7 +284,7 @@
246284
},
247285
{
248286
"cell_type": "code",
249-
"execution_count": 124,
287+
"execution_count": 165,
250288
"metadata": {},
251289
"outputs": [
252290
{
@@ -328,15 +366,17 @@
328366
"metadata": {},
329367
"source": [
330368
"#### Exerciese: Numbers\n",
369+
"\n",
331370
"1. Declare an integer variable\n",
332371
"2. Declare a float number variable\n",
333372
"3. Declare a complex number variable\n",
334-
"4. Calcaulate an area of a triangle (area = 0.5 * b * h)\n",
335-
"5. Calaculate the primeter of triangle (p = a + b +c)\n",
336-
"6. Calaculate the of area rectangle (area = lenght * width)\n",
337-
"7. Calaculate the primeter of rectangle (p = 2 * (length + width))\n",
338-
"8. Calculate the area of a circle (area = 3.14 * r * r)\n",
339-
"9. Calculate the circumference of a circle(c = 2* pi * r)"
373+
"4. Calcaulate an area of a triangle (area = 0.5 x b x h)\n",
374+
"5. Calaculate the primeter of triangle (p = a + b + c)\n",
375+
"6. Calaculate the of area rectangle (area = lenght x width)\n",
376+
"7. Calaculate the primeter of rectangle (p = 2 x (length + width))\n",
377+
"8. Calculate the area of a circle (area = 3.14 x r x r)\n",
378+
"9. Calculate the circumference of a circle(c = 2 x pi x r)\n",
379+
"10. Calculate the value of y (y = x2 + 6x + 9). Try to use different x value and figure out at what x value y is 0."
340380
]
341381
},
342382
{
@@ -396,15 +436,16 @@
396436
},
397437
{
398438
"cell_type": "code",
399-
"execution_count": 126,
439+
"execution_count": 160,
400440
"metadata": {},
401441
"outputs": [
402442
{
403443
"name": "stdout",
404444
"output_type": "stream",
405445
"text": [
406-
"Asabeneh Yetayeh\n",
407-
"I am Asabeneh Yetayeh. I live in Finland, Helsinki.\n"
446+
"Full name: Asabeneh Yetayeh\n",
447+
"Person Information: I am Asabeneh Yetayeh. I live in Finland, Helsinki.\n",
448+
"Git repository: Python for Everyone\n"
408449
]
409450
}
410451
],
@@ -417,8 +458,11 @@
417458
"country = \"Finland\"\n",
418459
"city = 'Helsinki'\n",
419460
"full_name = first_name + space + last_name\n",
420-
"print(full_name)\n",
421-
"print('I am ' + full_name + '. I live in ' + country + ', '+ city + '.')\n",
461+
"git_repo= 'Python ' + ' for ' + ' Everyone'\n",
462+
"person_info = 'I am ' + full_name + '. I live in ' + country + ', '+ city + '.'\n",
463+
"print('Full name: ', full_name)\n",
464+
"print('Person Information:', person_info)\n",
465+
"print('Git repository: ', git_repo)\n",
422466
"\n"
423467
]
424468
},

0 commit comments

Comments
 (0)