|
57 | 57 | "cell_type": "markdown", |
58 | 58 | "metadata": {}, |
59 | 59 | "source": [ |
60 | | - "To print a value to the screen, we use the command 'print'\n", |
| 60 | + "To print a value to the screen, we use the function 'print()'\n", |
61 | 61 | "\n", |
62 | | - "e.g. print 1" |
| 62 | + "e.g. print(1)" |
63 | 63 | ] |
64 | 64 | }, |
65 | 65 | { |
|
70 | 70 | }, |
71 | 71 | "outputs": [], |
72 | 72 | "source": [ |
73 | | - "print \"Hello World\"" |
| 73 | + "print(\"Hello World\")" |
74 | 74 | ] |
75 | 75 | }, |
76 | 76 | { |
|
122 | 122 | "cell_type": "markdown", |
123 | 123 | "metadata": {}, |
124 | 124 | "source": [ |
125 | | - "Notice that when you ran that, nothing printed out. To print a variable, you use the same statement you would use to print the value. e.g. print WHALE" |
| 125 | + "Notice that when you ran that, nothing printed out. To print a variable, you use the same statement you would use to print the value. e.g. print(WHALE)" |
126 | 126 | ] |
127 | 127 | }, |
128 | 128 | { |
|
133 | 133 | }, |
134 | 134 | "outputs": [], |
135 | 135 | "source": [ |
136 | | - "print number_of_whales" |
| 136 | + "print(number_of_whales)" |
137 | 137 | ] |
138 | 138 | }, |
139 | 139 | { |
|
201 | 201 | "source": [ |
202 | 202 | "apples = 15\n", |
203 | 203 | "apples_left = 15 - 3\n", |
204 | | - "print apples_left" |
| 204 | + "print(apples_left)" |
205 | 205 | ] |
206 | 206 | }, |
207 | 207 | { |
|
212 | 212 | }, |
213 | 213 | "outputs": [], |
214 | 214 | "source": [ |
215 | | - "print 3 * 2.1" |
| 215 | + "print(3 * 2.1)" |
216 | 216 | ] |
217 | 217 | }, |
218 | 218 | { |
|
234 | 234 | }, |
235 | 235 | "outputs": [], |
236 | 236 | "source": [ |
237 | | - "print 5 / 2" |
| 237 | + "print(5 / 2)" |
238 | 238 | ] |
239 | 239 | }, |
240 | 240 | { |
|
274 | 274 | "source": [ |
275 | 275 | "number_of_whales = 8\n", |
276 | 276 | "number_of_whales = number_of_whales + 2 \n", |
277 | | - "print number_of_whales" |
| 277 | + "print(number_of_whales)" |
278 | 278 | ] |
279 | 279 | }, |
280 | 280 | { |
|
378 | 378 | }, |
379 | 379 | "outputs": [], |
380 | 380 | "source": [ |
381 | | - "print 'Hello ' + 'Coding Circle'" |
| 381 | + "print('Hello ' + 'Coding Circle')" |
382 | 382 | ] |
383 | 383 | }, |
384 | 384 | { |
|
389 | 389 | }, |
390 | 390 | "outputs": [], |
391 | 391 | "source": [ |
392 | | - "print \"The \" + WHALE + \" lives in the sea.\"" |
| 392 | + "print(\"The \" + WHALE + \" lives in the sea.\")" |
393 | 393 | ] |
394 | 394 | }, |
395 | 395 | { |
|
407 | 407 | }, |
408 | 408 | "outputs": [], |
409 | 409 | "source": [ |
410 | | - "print \"My name is\" + \"Charlotte\"" |
| 410 | + "print(\"My name is\" + \"Charlotte\")" |
411 | 411 | ] |
412 | 412 | }, |
413 | 413 | { |
|
446 | 446 | }, |
447 | 447 | "outputs": [], |
448 | 448 | "source": [ |
449 | | - "my_name = raw_input()\n", |
450 | | - "print my_name" |
| 449 | + "my_name = input()\n", |
| 450 | + "print(my_name)" |
451 | 451 | ] |
452 | 452 | }, |
453 | 453 | { |
|
469 | 469 | }, |
470 | 470 | "outputs": [], |
471 | 471 | "source": [ |
472 | | - "favorite_ocean_animal = raw_input(\"What is your favorite sea creature?\\n\")\n", |
473 | | - "print \"The \" + favorite_ocean_animal + \" is so cool!\"" |
| 472 | + "favorite_ocean_animal = input(\"What is your favorite sea creature?\\n\")\n", |
| 473 | + "print(\"The \" + favorite_ocean_animal + \" is so cool!\")" |
474 | 474 | ] |
475 | 475 | }, |
476 | 476 | { |
|
492 | 492 | }, |
493 | 493 | "outputs": [], |
494 | 494 | "source": [ |
495 | | - "number_of_apples = raw_input(\"How many apples do you want?\\n\")\n", |
| 495 | + "number_of_apples = input(\"How many apples do you want?\\n\")\n", |
496 | 496 | "number_of_apples_int = int(number_of_apples)\n", |
497 | | - "print int(number_of_apples_int) * 1.05" |
| 497 | + "print(int(number_of_apples_int) * 1.05)" |
498 | 498 | ] |
499 | 499 | }, |
500 | 500 | { |
|
533 | 533 | "outputs": [], |
534 | 534 | "source": [ |
535 | 535 | "# Calculate the price of apples that a user wants\n", |
536 | | - "number_of_apples = raw_input(\"How many apples do you want?\\n\") # Ask user for quantity of apples\n", |
| 536 | + "number_of_apples = input(\"How many apples do you want?\\n\") # Ask user for quantity of apples\n", |
537 | 537 | "number_of_apples_int = int(number_of_apples) # raw_input returns string, so convert to integer\n", |
538 | | - "print number_of_apples_int * 1.05 # multiply by price of apples" |
| 538 | + "print(number_of_apples_int * 1.05) # multiply by price of apples" |
539 | 539 | ] |
540 | 540 | }, |
541 | 541 | { |
|
585 | 585 | ], |
586 | 586 | "metadata": { |
587 | 587 | "kernelspec": { |
588 | | - "display_name": "Python 2", |
| 588 | + "display_name": "Python 3", |
589 | 589 | "language": "python", |
590 | | - "name": "python2" |
| 590 | + "name": "python3" |
591 | 591 | }, |
592 | 592 | "language_info": { |
593 | 593 | "codemirror_mode": { |
594 | 594 | "name": "ipython", |
595 | | - "version": 2 |
| 595 | + "version": 3 |
596 | 596 | }, |
597 | 597 | "file_extension": ".py", |
598 | 598 | "mimetype": "text/x-python", |
599 | 599 | "name": "python", |
600 | 600 | "nbconvert_exporter": "python", |
601 | | - "pygments_lexer": "ipython2", |
602 | | - "version": "2.7.10" |
| 601 | + "pygments_lexer": "ipython3" |
603 | 602 | } |
604 | 603 | }, |
605 | 604 | "nbformat": 4, |
|
0 commit comments