Skip to content

Commit

Permalink
uses colabturtleplus instead of mobilechelonian
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbubbleman committed Oct 23, 2023
1 parent 3b860c0 commit 5f0d363
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 63 deletions.
150 changes: 87 additions & 63 deletions CallystoAndComputationalThinking/Turtles-Exercise.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"\n",
"We can have fun and create art by commanding turtles to move around the screen.\n",
"\n",
"This uses a Python library called **mobilechelonian**, which is based on code written by students at [MacEwan University](https://www.macewan.ca/) in Edmonton."
"This uses a Python library called [ColabTurtlePlus](https://pypi.org/project/ColabTurtlePlus/), which is an extension of the original **ColabTurtle** by Tolga Atam. "
]
},
{
Expand All @@ -25,7 +25,7 @@
"## Turtle Commands\n",
"\n",
"`t.speed(integer)`\n",
"* Speed of your turtle, 1-10 (hint set your speed to 10) \n",
"* Speed of your turtle, 1-13 (hint set your speed to 13) \n",
"\n",
"`t.pendown()` or `t.penup()`\n",
"* For drawing lines or not \n",
Expand Down Expand Up @@ -60,23 +60,23 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from mobilechelonian import Turtle #import the Turtle module from the mobilechelonian library\n",
"import math #this library will come in handy when making the roof, hint math.sqrt()\n",
"\n",
"t = Turtle()\n",
"t.speed(10)\n",
"### enter your code below, use the turtle commands above such as t.forward(100) and t.right(90)\n",
"t.forward(100) #hint\n",
"\n",
"# import the drawing library, ColabTurtlePlus as cTurtle\n",
"import ColabTurtlePlus.Turtle as cTurtle \n",
"# this library will come in handy when making the roof, hint math.sqrt()\n",
"import math \n",
"\n",
"cTurtle.clearscreen()\n",
"cTurtle.setup(400, 400)\n",
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.shape(\"turtle\")\n",
"t.speed(13)\n",
"\n",
"\n",
"\n"
"### enter your code below, use the turtle commands above such as t.forward(100) and t.right(90)\n",
"t.forward(100) #hint"
]
},
{
Expand All @@ -103,18 +103,23 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from mobilechelonian import Turtle\n",
"t = Turtle()\n",
"t.speed(10)\n",
"import ColabTurtlePlus.Turtle as cTurtle \n",
"cTurtle.clearscreen()\n",
"cTurtle.setup(400, 400)\n",
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.shape(\"turtle\")\n",
"t.speed(13)\n",
"\n",
"for i in range(): #enter a value for range, how many times do we need to repeat to draw a box?\n",
" t.forward() #enter a unit value\n",
" t.right() #enter a degree value"
"# enter a value for range, how many times do we need to repeat to draw a box?\n",
"for i in range(4): \n",
" # enter a unit value\n",
" t.forward() \n",
" # enter a degree value\n",
" t.right() "
]
},
{
Expand All @@ -127,21 +132,27 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from mobilechelonian import Turtle\n",
"t = Turtle()\n",
"t.speed(10)\n",
"import ColabTurtlePlus.Turtle as cTurtle \n",
"cTurtle.clearscreen()\n",
"cTurtle.setup(400, 400)\n",
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.shape(\"turtle\")\n",
"t.speed(13)\n",
"\n",
"def box(units): #def means define function, in this case our function is called box\n",
" for i in range(): #enter a value for range. hint: how many times do we need to repeat to draw a box? \n",
"# def means define function, in this case our function is called box\n",
"def box(units): \n",
" # enter a value for range. hint: how many times do we need to repeat to draw a box? \n",
" for i in range(4): \n",
" t.forward(units)\n",
" t.right() #enter a degree value\n",
" \n",
"box() #enter a unit value for our box function. hint: how many units did we use above?"
" # enter a degree value\n",
" t.right(90)\n",
"\n",
"# enter a unit value for our box function. hint: how many units did we use above?\n",
"box()"
]
},
{
Expand All @@ -154,22 +165,28 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from mobilechelonian import Turtle\n",
"t = Turtle()\n",
"t.speed(10)\n",
"import ColabTurtlePlus.Turtle as cTurtle \n",
"cTurtle.clearscreen()\n",
"cTurtle.setup(400, 400)\n",
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.shape(\"turtle\")\n",
"t.speed(13)\n",
"\n",
"def box(units):\n",
" for i in range(): #enter a value for range\n",
" # enter a value for range\n",
" for i in range(4): \n",
" t.forward(units)\n",
" t.right() #enter a degree value\n",
" # enter a degree value\n",
" t.right(90)\n",
"\n",
"for i in range(18): #do you know why we repeat our loop 18 times and use 20 degrees for our right turn below?\n",
" box() #enter a unit value\n",
"# do you know why we repeat our loop 18 times and use 20 degrees for our right turn below?\n",
"for i in range(18):\n",
" # enter a unit value\n",
" box() \n",
" t.right(20)"
]
},
Expand All @@ -188,8 +205,8 @@
},
"outputs": [],
"source": [
"colours = [\"red\", \"blue\", \"purple\"] #this is a python list\n",
"colours[2] #let's call a list item, try changing the number to return blue"
"colours = [\"red\", \"blue\", \"purple\"] # this is a python list\n",
"colours[2] # let's call a list item, try changing the number to return blue"
]
},
{
Expand All @@ -200,33 +217,40 @@
},
"outputs": [],
"source": [
"#let's print what this looks like.\n",
"for i in range(18): #remember our loop with 18 iterations?\n",
" print(colours[i % 3], i % 3) #we use 3 because we have 3 colours. the % sign is for the modulo math operator. "
"# let's print what this looks like, remember our loop with 18 iterations?\n",
"for i in range(18): \n",
" # we use 3 because we have 3 colours. the % sign is for the modulo math operator. \n",
" print(colours[i % 3], i % 3)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"#now let's put it all together\n",
"from mobilechelonian import Turtle\n",
"t = Turtle()\n",
"t.speed(10)\n",
"# now let's put it all together\n",
"import ColabTurtlePlus.Turtle as cTurtle \n",
"cTurtle.clearscreen()\n",
"cTurtle.setup(400, 400)\n",
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.shape(\"turtle\")\n",
"t.speed(13)\n",
"\n",
"def box(units):\n",
" for i in range(): #enter a value for range\n",
" # enter a value for range\n",
" for i in range(): \n",
" t.forward(units)\n",
" t.right() #enter a degree value\n",
" # enter a degree value\n",
" t.right(90) \n",
"\n",
"colours = [\"red\", \"green\", \"purple\"] \n",
"colours = [\"purple\", \"blue\", \"red\"] \n",
"for i in range(18):\n",
" t.pencolor(colours[i % 3]) #new turtle command\n",
" box() #enter a unit value\n",
" # new turtle command\n",
" t.pencolor(colours[i % 3]) \n",
" # enter a unit value\n",
" box() \n",
" t.right(20)"
]
},
Expand Down Expand Up @@ -286,7 +310,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.10.8"
}
},
"nbformat": 4,
Expand Down
6 changes: 6 additions & 0 deletions CallystoAndComputationalThinking/Turtles-Solution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.speed(13)\n",
"t.shape(\"turtle\")\n",
"\n",
"### enter your code below, use the turtle commands above such as t.forward(100) and t.right(90)\n",
"t.forward(100) #hint\n",
Expand Down Expand Up @@ -127,6 +128,7 @@
"cTurtle.setup(400, 400)\n",
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.shape(\"turtle\")\n",
"t.speed(13)\n",
"\n",
"# enter a value for range, how many times do we need to repeat to draw a box?\n",
Expand Down Expand Up @@ -157,6 +159,7 @@
"cTurtle.setup(400, 400)\n",
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.shape(\"turtle\")\n",
"t.speed(13)\n",
"\n",
"# def means define function, in this case our function is called box\n",
Expand Down Expand Up @@ -191,6 +194,7 @@
"cTurtle.setup(400, 400)\n",
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.shape(\"turtle\")\n",
"t.speed(13)\n",
"\n",
"def box(units):\n",
Expand Down Expand Up @@ -254,6 +258,7 @@
"cTurtle.setup(400, 400)\n",
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.shape(\"turtle\")\n",
"t.speed(13)\n",
"\n",
"def box(units):\n",
Expand Down Expand Up @@ -300,6 +305,7 @@
"cTurtle.setup(400, 400)\n",
"cTurtle.showborder()\n",
"t = cTurtle.Turtle()\n",
"t.shape(\"turtle\")\n",
"t.speed(13)\n",
"\n",
"\n",
Expand Down

0 comments on commit 5f0d363

Please sign in to comment.