|
40 | 40 | },
|
41 | 41 | {
|
42 | 42 | "cell_type": "code",
|
43 |
| - "execution_count": 120, |
| 43 | + "execution_count": 146, |
44 | 44 | "metadata": {},
|
45 | 45 | "outputs": [],
|
46 | 46 | "source": [
|
|
66 | 66 | },
|
67 | 67 | {
|
68 | 68 | "cell_type": "code",
|
69 |
| - "execution_count": 121, |
| 69 | + "execution_count": 161, |
70 | 70 | "metadata": {},
|
71 | 71 | "outputs": [
|
72 | 72 | {
|
73 | 73 | "name": "stdout",
|
74 | 74 | "output_type": "stream",
|
75 | 75 | "text": [
|
76 |
| - "Welcome to Python!\n", |
77 | 76 | "Hello, World!\n",
|
78 | 77 | "Hello, World !\n",
|
79 |
| - "Learn python in 2019\n", |
| 78 | + "Welcome to Python!\n", |
| 79 | + "Learn python in 2019\n", |
80 | 80 | "Welcome to Python for Everyone\n",
|
81 | 81 | "Welcome to Python for Everyone\n"
|
82 | 82 | ]
|
|
85 | 85 | "source": [
|
86 | 86 | "# Printing in Python\n",
|
87 | 87 | "\n",
|
88 |
| - "print(\"Welcome to Python!\")\n", |
| 88 | + "\n", |
89 | 89 | "print('Hello, World!')\n",
|
90 | 90 | "print('Hello,', \"World\", \"!\")\n",
|
91 |
| - "print('Learn python in ', 2019)\n", |
| 91 | + "print(\"Welcome to Python!\")\n", |
| 92 | + "print('Learn python in', 2019)\n", |
92 | 93 | "print('Welcome to Python for Everyone')\n",
|
93 |
| - "print('Welcome','to', 'Python','for','Everyone')" |
| 94 | + "print('Welcome','to', 'Python','for','Everyone')\n" |
94 | 95 | ]
|
95 | 96 | },
|
96 | 97 | {
|
|
117 | 118 | },
|
118 | 119 | {
|
119 | 120 | "cell_type": "code",
|
120 |
| - "execution_count": 122, |
| 121 | + "execution_count": 162, |
121 | 122 | "metadata": {},
|
122 | 123 | "outputs": [
|
123 | 124 | {
|
124 | 125 | "name": "stdout",
|
125 | 126 | "output_type": "stream",
|
126 | 127 | "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" |
132 | 133 | ]
|
133 | 134 | }
|
134 | 135 | ],
|
|
140 | 141 | "country = \"Helsinki\"\n",
|
141 | 142 | "age = 250\n",
|
142 | 143 | "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)" |
148 | 185 | ]
|
149 | 186 | },
|
150 | 187 | {
|
|
161 | 198 | "7. Declare a city variable and assign a value to it\n",
|
162 | 199 | "8. Declare a variable is_married and assign a value to it\n",
|
163 | 200 | "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" |
165 | 203 | ]
|
166 | 204 | },
|
167 | 205 | {
|
|
174 | 212 | },
|
175 | 213 | {
|
176 | 214 | "cell_type": "code",
|
177 |
| - "execution_count": 123, |
| 215 | + "execution_count": 164, |
178 | 216 | "metadata": {},
|
179 | 217 | "outputs": [
|
180 | 218 | {
|
|
246 | 284 | },
|
247 | 285 | {
|
248 | 286 | "cell_type": "code",
|
249 |
| - "execution_count": 124, |
| 287 | + "execution_count": 165, |
250 | 288 | "metadata": {},
|
251 | 289 | "outputs": [
|
252 | 290 | {
|
|
328 | 366 | "metadata": {},
|
329 | 367 | "source": [
|
330 | 368 | "#### Exerciese: Numbers\n",
|
| 369 | + "\n", |
331 | 370 | "1. Declare an integer variable\n",
|
332 | 371 | "2. Declare a float number variable\n",
|
333 | 372 | "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." |
340 | 380 | ]
|
341 | 381 | },
|
342 | 382 | {
|
|
396 | 436 | },
|
397 | 437 | {
|
398 | 438 | "cell_type": "code",
|
399 |
| - "execution_count": 126, |
| 439 | + "execution_count": 160, |
400 | 440 | "metadata": {},
|
401 | 441 | "outputs": [
|
402 | 442 | {
|
403 | 443 | "name": "stdout",
|
404 | 444 | "output_type": "stream",
|
405 | 445 | "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" |
408 | 449 | ]
|
409 | 450 | }
|
410 | 451 | ],
|
|
417 | 458 | "country = \"Finland\"\n",
|
418 | 459 | "city = 'Helsinki'\n",
|
419 | 460 | "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", |
422 | 466 | "\n"
|
423 | 467 | ]
|
424 | 468 | },
|
|
0 commit comments