|
23 | 23 | "outputs": [], |
24 | 24 | "source": [ |
25 | 25 | "print(\"The cost of the meal will be:\")\n", |
26 | | - "print(100 + 100 * 8.875/100 + 100 * 20/100)" |
| 26 | + "print(100 + 100 * 8.875 / 100 + 100 * 20 / 100)" |
27 | 27 | ] |
28 | 28 | }, |
29 | 29 | { |
|
40 | 40 | "outputs": [], |
41 | 41 | "source": [ |
42 | 42 | "print(\"The cost of the meal will be:\")\n", |
43 | | - "print(75 + 75 * 8.875/100 + 75 * 20/100)" |
| 43 | + "print(75 + 75 * 8.875 / 100 + 75 * 20 / 100)" |
44 | 44 | ] |
45 | 45 | }, |
46 | 46 | { |
|
59 | 59 | "outputs": [], |
60 | 60 | "source": [ |
61 | 61 | "food = 75\n", |
62 | | - "tax = 8.875/100\n", |
63 | | - "tip = 20/100\n", |
| 62 | + "tax = 8.875 / 100\n", |
| 63 | + "tip = 20 / 100\n", |
64 | 64 | "cost = food + food * tax + food * tip\n", |
65 | 65 | "print(\"The cost of the meal will be:\")\n", |
66 | 66 | "print(cost)" |
|
105 | 105 | "metadata": {}, |
106 | 106 | "outputs": [], |
107 | 107 | "source": [ |
108 | | - "message = 'I love Python...'\n", |
| 108 | + "message = \"I love Python...\"\n", |
109 | 109 | "print(message)\n", |
110 | 110 | "print(message)\n", |
111 | 111 | "print(message)\n", |
|
120 | 120 | "source": [ |
121 | 121 | "males = 7\n", |
122 | 122 | "females = 10\n", |
123 | | - "fraction = males/(males+females)\n", |
| 123 | + "fraction = males / (males + females)\n", |
124 | 124 | "print(\"Percentage of men:\")\n", |
125 | | - "print(100*fraction)" |
| 125 | + "print(100 * fraction)" |
126 | 126 | ] |
127 | 127 | }, |
128 | 128 | { |
|
146 | 146 | "outputs": [], |
147 | 147 | "source": [ |
148 | 148 | "food = 75\n", |
149 | | - "tax = 8.875/100\n", |
150 | | - "tip = 20/100\n", |
| 149 | + "tax = 8.875 / 100\n", |
| 150 | + "tip = 20 / 100\n", |
151 | 151 | "cost = food + food * tax + food * tip\n", |
152 | 152 | "print(\"The cost of the meal will be:\")\n", |
153 | 153 | "print(cost)" |
|
251 | 251 | "outputs": [], |
252 | 252 | "source": [ |
253 | 253 | "# Base scenario\n", |
254 | | - "yearly_value = base_salary + expected_bonus*base_salary + equity/years_vesting\n", |
| 254 | + "yearly_value = base_salary + expected_bonus * base_salary + equity / years_vesting\n", |
255 | 255 | "print(\"The yearly value of this offer is\", yearly_value)" |
256 | 256 | ] |
257 | 257 | }, |
|
270 | 270 | "source": [ |
271 | 271 | "# Same computation as above, but in three steps\n", |
272 | 272 | "# We start by adding the base_salary in the yearly_value\n", |
273 | | - "yearly_value = base_salary \n", |
| 273 | + "yearly_value = base_salary\n", |
274 | 274 | "# then we add the expected bonus\n", |
275 | | - "yearly_value = yearly_value + expected_bonus*base_salary \n", |
| 275 | + "yearly_value = yearly_value + expected_bonus * base_salary\n", |
276 | 276 | "# and then we add the value of equity\n", |
277 | | - "yearly_value = yearly_value + equity/years_vesting \n", |
| 277 | + "yearly_value = yearly_value + equity / years_vesting\n", |
278 | 278 | "print(\"The yearly value of this offer is\", yearly_value)" |
279 | 279 | ] |
280 | 280 | }, |
|
298 | 298 | "outputs": [], |
299 | 299 | "source": [ |
300 | 300 | "# Same computation as above, but using the += shorthand\n", |
301 | | - "yearly_value = base_salary \n", |
302 | | - "yearly_value += expected_bonus*base_salary \n", |
303 | | - "yearly_value += 0* equity/years_vesting\n", |
| 301 | + "yearly_value = base_salary\n", |
| 302 | + "yearly_value += expected_bonus * base_salary\n", |
| 303 | + "yearly_value += 0 * equity / years_vesting\n", |
304 | 304 | "print(\"The yearly value of this offer is\", yearly_value)" |
305 | 305 | ] |
306 | 306 | }, |
|
350 | 350 | "metadata": {}, |
351 | 351 | "outputs": [], |
352 | 352 | "source": [ |
353 | | - "s = 150000 # salary\n", |
354 | | - "b = 0.25 # bonus percentage\n", |
355 | | - "e = 400000 # value of promised equity\n", |
356 | | - "y = 4 # years for vesting equity\n", |
357 | | - "v = s + b*s + e/y # compute the yearly value\n", |
| 353 | + "s = 150000 # salary\n", |
| 354 | + "b = 0.25 # bonus percentage\n", |
| 355 | + "e = 400000 # value of promised equity\n", |
| 356 | + "y = 4 # years for vesting equity\n", |
| 357 | + "v = s + b * s + e / y # compute the yearly value\n", |
358 | 358 | "print(\"The yearly value of this offer is\", v)" |
359 | 359 | ] |
360 | 360 | }, |
|
375 | 375 | "b = 0.25\n", |
376 | 376 | "e = 400000\n", |
377 | 377 | "y = 4\n", |
378 | | - "v = s + b*s + e/y\n", |
| 378 | + "v = s + b * s + e / y\n", |
379 | 379 | "print(\"The yearly value of this offer is\", v)" |
380 | 380 | ] |
381 | 381 | }, |
|
396 | 396 | "beer = 0.25\n", |
397 | 397 | "gin = 400000\n", |
398 | 398 | "vodka = 4\n", |
399 | | - "rum = whiskey + beer*whiskey + gin/vodka\n", |
| 399 | + "rum = whiskey + beer * whiskey + gin / vodka\n", |
400 | 400 | "print(\"The yearly value of this offer is\", rum)" |
401 | 401 | ] |
402 | 402 | }, |
|
427 | 427 | "metadata": {}, |
428 | 428 | "outputs": [], |
429 | 429 | "source": [ |
430 | | - "# 76trombones is illegal because it begins with a number. \n", |
| 430 | + "# 76trombones is illegal because it begins with a number.\n", |
431 | 431 | "# REMOVE THE COMMENT CHARACTER IN THE NEXT LINE TO ATTEMPT\n", |
432 | 432 | "# 76trombones = 'big parade'" |
433 | 433 | ] |
|
470 | 470 | "metadata": {}, |
471 | 471 | "outputs": [], |
472 | 472 | "source": [ |
473 | | - "# What’s wrong with class? It turns out that class is one of Python’s keywords. \n", |
| 473 | + "# What’s wrong with class? It turns out that class is one of Python’s keywords.\n", |
474 | 474 | "# REMOVE THE COMMENT CHARACTER IN THE NEXT LINE TO ATTEMPT\n", |
475 | 475 | "# class = 'Introduction to Programming'" |
476 | 476 | ] |
|
536 | 536 | "metadata": {}, |
537 | 537 | "outputs": [], |
538 | 538 | "source": [ |
539 | | - "# print = 100 \n", |
| 539 | + "# print = 100\n", |
540 | 540 | "# print(\"What happened?\")" |
541 | 541 | ] |
542 | 542 | }, |
|
589 | 589 | "name": "python", |
590 | 590 | "nbconvert_exporter": "python", |
591 | 591 | "pygments_lexer": "ipython3", |
592 | | - "version": "3.5.2" |
| 592 | + "version": "3.8.2" |
593 | 593 | } |
594 | 594 | }, |
595 | 595 | "nbformat": 4, |
|
0 commit comments