From 1c2670602259453b0675849fb8c1d32b0021ffb2 Mon Sep 17 00:00:00 2001 From: whiteaj2 Date: Wed, 30 Aug 2017 22:28:23 -0400 Subject: [PATCH 1/6] I added my name --- src/m3_turtles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m3_turtles.py b/src/m3_turtles.py index df507f3..2739c42 100644 --- a/src/m3_turtles.py +++ b/src/m3_turtles.py @@ -10,7 +10,7 @@ -- ASSIGNING a VALUE to a NAME (VARIABLE). Authors: David Mutchler, Dave Fisher, Valerie Galluzzi, Amanda Stouder, - their colleagues and PUT_YOUR_NAME_HERE. + their colleagues and Andrew White. """ ######################################################################## # From 812f52d18459b415b7349968fb9d71d5aa7d836f Mon Sep 17 00:00:00 2001 From: whiteaj2 Date: Wed, 30 Aug 2017 23:17:09 -0400 Subject: [PATCH 2/6] Committed as per directions of TODO #5 --- src/m1e_comments_strings_print.py | 1 + src/m2_hello_world.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/m1e_comments_strings_print.py b/src/m1e_comments_strings_print.py index 18eb8a0..4a5cc91 100644 --- a/src/m1e_comments_strings_print.py +++ b/src/m1e_comments_strings_print.py @@ -10,6 +10,7 @@ ######################################################################## print('Hello, World') +print('andrew',3) print('hi there') print('one', 'two', 'buckle my shoe') print(3 + 9) diff --git a/src/m2_hello_world.py b/src/m2_hello_world.py index aaa506a..390a054 100644 --- a/src/m2_hello_world.py +++ b/src/m2_hello_world.py @@ -1,4 +1,10 @@ print('Hello, World') +print('Andrew') +product = 3607*34227 +factor1 = '3607' +factor2 = '34227' +print(product) +print(int(factor1)*int(factor2), 'Do they match?') ######################################################################## # This line is a COMMENT -- a note to human readers of this file. @@ -13,7 +19,7 @@ ######################################################################## # -# TODO: 1. +# DONE: 1. # (Yes, that means for YOU to DO things per these instructions:) # # Run this module by right clicking anywhere in this window and select @@ -26,7 +32,7 @@ ######################################################################## # -# TODO: 2. +# DONE: 2. # Notice the small horizontal BLUE bars on the scrollbar-like thing # on the right. Each blue bar indicates a TO DO in this module. # @@ -34,7 +40,7 @@ # by clicking on the blue bars. ** Try that now. ** # # b. When you have completed a TO DO, you should change the word -# TODO +# DONE # to # DONE. # Try it now on line 16 above, and note that its blue bar on @@ -51,7 +57,7 @@ ######################################################################## # -# TODO: 3. +# DONE: 3. # Add another print statement below. # It should print any string that you want (but keep it G-rated!) # Test your code by re-running this module using either the right click @@ -62,7 +68,7 @@ ######################################################################## # -# TODO: 4. +# DONE: 4. # Add yet another print statement. # This one should print the *product* of 3,607 and 34,227. # Let the computer do the arithmetic for you (no calculators!). From b690683d907adac7a462e7763fa3a5f1fc1a81d1 Mon Sep 17 00:00:00 2001 From: whiteaj2 Date: Wed, 30 Aug 2017 23:19:35 -0400 Subject: [PATCH 3/6] Committed as per directions of TODO #5 --- src/m2_hello_world.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/m2_hello_world.py b/src/m2_hello_world.py index 390a054..fc82459 100644 --- a/src/m2_hello_world.py +++ b/src/m2_hello_world.py @@ -3,6 +3,8 @@ product = 3607*34227 factor1 = '3607' factor2 = '34227' +print(3607*34227) +#Different ways to accomplish the same thing print(product) print(int(factor1)*int(factor2), 'Do they match?') @@ -82,7 +84,7 @@ ######################################################################## # -# TODO: 5. +# DONE: 5. # Look at the list of files in this project to the left. # Note that this file (m2_hello_world.py) is now displayed in a blue # font color (if the file is highlighted select a different file so yu can From bea8c51b2b5e4fae5ebba3d2bd7a7e96ff00a108 Mon Sep 17 00:00:00 2001 From: whiteaj2 Date: Wed, 30 Aug 2017 23:44:44 -0400 Subject: [PATCH 4/6] Added new turtle --- src/m3_turtles.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/m3_turtles.py b/src/m3_turtles.py index 2739c42..5c07c4d 100644 --- a/src/m3_turtles.py +++ b/src/m3_turtles.py @@ -14,7 +14,7 @@ """ ######################################################################## # -# TODO: 1. +# DONE: 1. # (Yes, that means for YOU to DO things per these instructions:) # # On Line 13 above, replace PUT_YOUR_OWN_NAME_HERE with your OWN name. @@ -29,7 +29,7 @@ ######################################################################## # -# TODO: 2. +# DONE: 2. # Allow this file to use the rosegraphics.py file by marking the src # directory as a "Sources Root". Do that by right clicking on the src folder, # then selector Mark Directory As --> Sources Root @@ -73,11 +73,17 @@ matt.backward(50) matt.left(90) matt.forward(50) +matt.right(45) +matt.pen_up() +matt.forward(50) +matt.pen_down() +matt.pen = rg.Pen('orange', 20) +matt.forward(150) ######################################################################## # -# TODO: 3. +# DONE: 3. # Add a few more line of your own code above to make one of the # existing Turtles move some more and/or have different # characteristics. @@ -91,7 +97,7 @@ ######################################################################## # -# TODO: 4. +# DONE: 4. # The code above CONSTRUCTS two SimpleTurtle objects and gives those objects NAMES: # dave matt # @@ -109,10 +115,12 @@ # As always, test by running the module. # ######################################################################## - +myTurtle = rg.SimpleTurtle() +myTurtle.pen = rg.Pen('green', 10) +myTurtle.forward(20) ######################################################################## # -# TODO: 5. +# DONE: 5. # Run one more time to be sure that all is still OK. # Ensure that no blue bars on the scrollbar-thing to the right remain. # From 4b5da688e25d9bca142aed0208634d71d4664508 Mon Sep 17 00:00:00 2001 From: whiteaj2 Date: Thu, 31 Aug 2017 00:40:01 -0400 Subject: [PATCH 5/6] Added original code for turtle rainbow as my example --- src/m5_your_turtles.py | 86 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/src/m5_your_turtles.py b/src/m5_your_turtles.py index d9de2a6..f91a473 100644 --- a/src/m5_your_turtles.py +++ b/src/m5_your_turtles.py @@ -2,15 +2,15 @@ Your chance to explore Loops and Turtles! Authors: David Mutchler, Dave Fisher, Valerie Galluzzi, Amanda Stouder, - their colleagues and PUT_YOUR_NAME_HERE. + their colleagues and Andrew White. """ ######################################################################## -# TODO: 1. +# DONE: 1. # On Line 5 above, replace PUT_YOUR_NAME_HERE with your own name. ######################################################################## ######################################################################## -# TODO: 2. +# DONE: 2. # # You should have RUN the PREVIOUS module and READ its code. # (Do so now if you have not already done so.) @@ -28,3 +28,83 @@ # # Don't forget to COMMIT your work by using VCS ~ Commit and Push. ######################################################################## + +#Objective is to create a rainbow using loops, and only rosegraphics functions learned in video and previous modules +#Can be accomplished with one turtle and one for loop( by using clones, I think(haven't tested) ) but not the objective + +import rosegraphics as rg +window = rg.TurtleWindow() +window.delay(0.25) + +#Define turtles for different colors +#Not efficient but simple +redTurtle = rg.SimpleTurtle() +redTurtle.pen = rg.Pen('red',10) + +orangeTurtle = rg.SimpleTurtle() +orangeTurtle.pen = rg.Pen('orange',10) + +yellowTurtle = rg.SimpleTurtle() +yellowTurtle.pen = rg.Pen('yellow',10) + +greenTurtle = rg.SimpleTurtle() +greenTurtle.pen = rg.Pen('green',10) + +blueTurtle = rg.SimpleTurtle() +blueTurtle.pen = rg.Pen('blue',10) + +purpleTurtle = rg.SimpleTurtle() +purpleTurtle.pen = rg.Pen('purple',10) + +#Change turtles orientation from right to up +redTurtle.left(90) +#Create a 180 degree arc +for i in range(180): + #Red turtle moves forward 2, the rest move forward by a 0.18 decrement + redTurtle.forward(2.0) + redTurtle.right(1) + +#Move turtle to starting position and rotate +orangeTurtle.pen_up() +orangeTurtle.forward(10) +orangeTurtle.pen_down() +orangeTurtle.left(90) +#Rest of code is copied from my previous code and repurposed +for i in range(180): + orangeTurtle.forward(1.82) + orangeTurtle.right(1) + +yellowTurtle.pen_up() +yellowTurtle.forward(20) +yellowTurtle.pen_down() +yellowTurtle.left(90) +for i in range(180): + yellowTurtle.forward(1.64) + yellowTurtle.right(1) + +greenTurtle.pen_up() +greenTurtle.forward(30) +greenTurtle.pen_down() +greenTurtle.left(90) +for i in range(180): + greenTurtle.forward(1.46) + greenTurtle.right(1) + +blueTurtle.pen_up() +blueTurtle.forward(40) +blueTurtle.pen_down() +blueTurtle.left(90) +for i in range(180): + blueTurtle.forward(1.28) + blueTurtle.right(1) + +purpleTurtle.pen_up() +purpleTurtle.forward(50) +purpleTurtle.pen_down() +purpleTurtle.left(90) +for i in range(180): + purpleTurtle.forward(1.10) + purpleTurtle.right(1) + +#close window on click +window.close_on_mouse_click() \ No newline at end of file From b47daf19768bded1cdf6560b84fa17af78c8a9f9 Mon Sep 17 00:00:00 2001 From: whiteaj2 Date: Thu, 31 Aug 2017 12:56:57 -0400 Subject: [PATCH 6/6] Added original code for turtle rainbow as my example --- src/m5_your_turtles.py | 100 ++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 66 deletions(-) diff --git a/src/m5_your_turtles.py b/src/m5_your_turtles.py index f91a473..fc86a8c 100644 --- a/src/m5_your_turtles.py +++ b/src/m5_your_turtles.py @@ -33,78 +33,46 @@ #Can be accomplished with one turtle and one for loop( by using clones, I think(haven't tested) ) but not the objective import rosegraphics as rg +import math window = rg.TurtleWindow() window.delay(0.25) -#Define turtles for different colors -#Not efficient but simple +#Define turtle for drawing redTurtle = rg.SimpleTurtle() redTurtle.pen = rg.Pen('red',10) -orangeTurtle = rg.SimpleTurtle() -orangeTurtle.pen = rg.Pen('orange',10) - -yellowTurtle = rg.SimpleTurtle() -yellowTurtle.pen = rg.Pen('yellow',10) - -greenTurtle = rg.SimpleTurtle() -greenTurtle.pen = rg.Pen('green',10) - -blueTurtle = rg.SimpleTurtle() -blueTurtle.pen = rg.Pen('blue',10) - -purpleTurtle = rg.SimpleTurtle() -purpleTurtle.pen = rg.Pen('purple',10) - -#Change turtles orientation from right to up -redTurtle.left(90) -#Create a 180 degree arc -for i in range(180): - #Red turtle moves forward 2, the rest move forward by a 0.18 decrement - redTurtle.forward(2.0) - redTurtle.right(1) - -#Move turtle to starting position and rotate -orangeTurtle.pen_up() -orangeTurtle.forward(10) -orangeTurtle.pen_down() -orangeTurtle.left(90) -#Rest of code is copied from my previous code and repurposed -for i in range(180): - orangeTurtle.forward(1.82) - orangeTurtle.right(1) - -yellowTurtle.pen_up() -yellowTurtle.forward(20) -yellowTurtle.pen_down() -yellowTurtle.left(90) -for i in range(180): - yellowTurtle.forward(1.64) - yellowTurtle.right(1) - -greenTurtle.pen_up() -greenTurtle.forward(30) -greenTurtle.pen_down() -greenTurtle.left(90) -for i in range(180): - greenTurtle.forward(1.46) - greenTurtle.right(1) - -blueTurtle.pen_up() -blueTurtle.forward(40) -blueTurtle.pen_down() -blueTurtle.left(90) -for i in range(180): - blueTurtle.forward(1.28) - blueTurtle.right(1) - -purpleTurtle.pen_up() -purpleTurtle.forward(50) -purpleTurtle.pen_down() -purpleTurtle.left(90) -for i in range(180): - purpleTurtle.forward(1.10) - purpleTurtle.right(1) +#define array of colors +colors = ['red','orange','yellow','green','blue','purple'] + +#cycle through every color in the array +for i in range(6): + #Set pen color to the color based on position in array, arranged for rainbow + redTurtle.pen = rg.Pen(colors[i],10) + #Move forward to starting position and face up + redTurtle.pen_up() + redTurtle.forward(10*i) + redTurtle.pen_down() + redTurtle.left(90) + #Make a 180 degree arc + for k in range(180): + #18 because 180, number has to relate to pi because it's a circular arc + redTurtle.forward(2-((math.pi / 18)*i)) + redTurtle.right(1) + #Return to initial position and orientation + redTurtle.pen_up() + redTurtle.go_to(rg.Point(0,0)) + redTurtle.pen_down() + redTurtle.left(90) + +#define second turtle +blackTurtle = rg.SimpleTurtle() +blackTurtle.pen = rg.Pen('black',10) +#move black turtle down 5 because that is the radius of the pen +blackTurtle.pen_up() +blackTurtle.go_to(rg.Point(0,-5)) +blackTurtle.pen_down() +#draw black underline +blackTurtle.forward(230) #close window on click window.close_on_mouse_click() \ No newline at end of file