|
295 | 295 | "metadata": {},
|
296 | 296 | "outputs": [],
|
297 | 297 | "source": [
|
298 |
| - "# Print at least one variable to show they're remembered by Python.\n" |
| 298 | + "# Print at least one variable to show they're remembered by Python across cells.\n" |
299 | 299 | ]
|
300 | 300 | },
|
301 | 301 | {
|
|
542 | 542 | "\n",
|
543 | 543 | "Remember to print a statement to ask what your user should enter into the space.\n",
|
544 | 544 | "\n",
|
545 |
| - "`print(\"Please enter your favourite colour: \")\n", |
546 |
| - "fav_colour = input()` \n", |
| 545 | + "```\n", |
| 546 | + "print(\"Please enter your favourite colour: \") \n", |
| 547 | + "fav_colour = input()\n", |
| 548 | + "```\n", |
547 | 549 | "OR \n",
|
548 | 550 | "`fav_colour = input(\"Please enter your favourite colour: \")`"
|
549 | 551 | ]
|
|
641 | 643 | "cell_type": "markdown",
|
642 | 644 | "metadata": {},
|
643 | 645 | "source": [
|
644 |
| - "\n", |
645 | 646 | "# Exercise 3 -- Roll the dice\n",
|
646 | 647 | "\n",
|
| 648 | + "<img src=\"Images/die.png\" alt=\"A red die, with 6 shown on top.\" />\n", |
647 | 649 | "\n",
|
648 |
| - "Now that we've asked the user for their name and information, let's add a random die roll to that code.\n", |
| 650 | + "Now that we've asked the user for their name and some information, let's add some dice rolls to that code. \n", |
649 | 651 | "\n",
|
650 |
| - "Some extra things you can add:\n", |
651 |
| - " - Add multiple dice, or change the number of sides on the dice\n", |
652 |
| - " - Display the results of these dice, added together (use of `str()`)\n", |
653 |
| - " - Ask the user for input about the type or number of dice (use of `int()`)\n", |
654 |
| - " \n", |
655 |
| - "<img src=\"Images/die.png\" alt=\"A red die, with 6 shown on top.\" />\n", |
656 |
| - " \n", |
657 |
| - " \n", |
658 |
| - "And remember! You can only concatenate strings (`str()`) and only use integers (`int()`) in maths functions.\n", |
| 652 | + "There's a new structure for exercises here: a short description of the desired outcome, and if you get stuck there's a step-by-step cell collapsed below.\n", |
| 653 | + "\n", |
| 654 | + "Roll some dice and do something with the results of these dice. What you do is up to you!\n", |
| 655 | + "\n", |
| 656 | + "As an extension, ask the user for input on what size each die should be. Get the average of the rolls and print it out.\n", |
| 657 | + "\n", |
| 658 | + "Remember, you can only concatenate strings (`str()`) and can only use integers (`int()`) in maths functions. \n", |
| 659 | + "We'll need this random number generation later on, so you'll either want to really commit it to memory or be ready to come back here another time to grab it!" |
| 660 | + ] |
| 661 | + }, |
| 662 | + { |
| 663 | + "cell_type": "markdown", |
| 664 | + "metadata": {}, |
| 665 | + "source": [ |
| 666 | + "Step-by-Step\n", |
659 | 667 | "\n",
|
660 |
| - "We'll need this random number generation in later lessons, so you'll either want to *really* commit it to memory or be ready to come back here at another time to grab it!" |
| 668 | + "1) In three separate variables, store three random integers. \n", |
| 669 | + "2) Display the results of these rolls. Then add the results together and display that too.\n", |
| 670 | + "\n", |
| 671 | + "Extension\n", |
| 672 | + "\n", |
| 673 | + "1) Take the user input, convert it to an integer and use it as an argument in randint(). \n", |
| 674 | + "2) The average is the sum of the rolls divided by how many there are." |
661 | 675 | ]
|
662 | 676 | },
|
663 | 677 | {
|
|
668 | 682 | },
|
669 | 683 | "outputs": [],
|
670 | 684 | "source": [
|
671 |
| - "# Some ideas to help you along\n", |
| 685 | + "# To help you along...\n", |
672 | 686 | "\n",
|
673 |
| - "# sensible_name = int(input(\"How many sides to your die? \")) # to make sides an integer\n", |
674 |
| - "roll_1 = random.randint(1, 10) # or between 1 and input, (1, sensible_name)\n", |
| 687 | + "roll_1 = random.randint(1, 10)\n", |
675 | 688 | "roll_2 = None\n",
|
676 | 689 | "# ...\n",
|
677 | 690 | "total = None"
|
|
689 | 702 | "metadata": {},
|
690 | 703 | "source": [
|
691 | 704 | "\n",
|
692 |
| - "# Conditionals\n", |
| 705 | + "# Conditions\n", |
693 | 706 | "\n",
|
694 | 707 | "<img src=\"images/conditionals.png\" alt=\"A road sign, directing left for True and right for False.\" /> \n",
|
695 | 708 | "\n",
|
|
744 | 757 | "\n",
|
745 | 758 | "# Exercise 4 -- True or false?\n",
|
746 | 759 | "Try some of the following statements: \n",
|
747 |
| - "`a = 5 a+b == b+a \n", |
| 760 | + "\n", |
| 761 | + "```\n", |
| 762 | + "a = 5 a+b == b+a \n", |
748 | 763 | "b = 10 a-b == b-a \n",
|
749 | 764 | "a > b a*b == b*a \n",
|
750 |
| - "a < b a/b != b/a ` \n", |
| 765 | + "a < b a/b != b/a\n", |
| 766 | + "``` \n", |
| 767 | + "\n", |
751 | 768 | "What do you expect them to be (True or False)? \n",
|
752 | 769 | "Feel free to experiment with some other comparisons."
|
753 | 770 | ]
|
|
0 commit comments