Skip to content

Commit 0715b4b

Browse files
committed
Checking collapsed cell persistence with new ex format
1 parent 261a82e commit 0715b4b

File tree

1 file changed

+38
-21
lines changed

1 file changed

+38
-21
lines changed

Python Lessons/Python Lesson 1.ipynb

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295
"metadata": {},
296296
"outputs": [],
297297
"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"
299299
]
300300
},
301301
{
@@ -542,8 +542,10 @@
542542
"\n",
543543
"Remember to print a statement to ask what your user should enter into the space.\n",
544544
"\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",
547549
"OR \n",
548550
"`fav_colour = input(\"Please enter your favourite colour: \")`"
549551
]
@@ -641,23 +643,35 @@
641643
"cell_type": "markdown",
642644
"metadata": {},
643645
"source": [
644-
"\n",
645646
"# Exercise 3 -- Roll the dice\n",
646647
"\n",
648+
"<img src=\"Images/die.png\" alt=\"A red die, with 6 shown on top.\" />\n",
647649
"\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",
649651
"\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",
659667
"\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."
661675
]
662676
},
663677
{
@@ -668,10 +682,9 @@
668682
},
669683
"outputs": [],
670684
"source": [
671-
"# Some ideas to help you along\n",
685+
"# To help you along...\n",
672686
"\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",
675688
"roll_2 = None\n",
676689
"# ...\n",
677690
"total = None"
@@ -689,7 +702,7 @@
689702
"metadata": {},
690703
"source": [
691704
"\n",
692-
"# Conditionals\n",
705+
"# Conditions\n",
693706
"\n",
694707
"<img src=\"images/conditionals.png\" alt=\"A road sign, directing left for True and right for False.\" /> \n",
695708
"\n",
@@ -744,10 +757,14 @@
744757
"\n",
745758
"# Exercise 4 -- True or false?\n",
746759
"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",
748763
"b = 10 a-b == b-a \n",
749764
"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",
751768
"What do you expect them to be (True or False)? \n",
752769
"Feel free to experiment with some other comparisons."
753770
]

0 commit comments

Comments
 (0)