import codestudio artist = codestudio.load('s1level41') for count in range(10): artist.pen.color = 'random' for count in range(4): artist.move_forward(20) artist.turn_right(90) artist.move_forward(20) artist.check()
import sys sys.path.append('../..') import codestudio z = codestudio.load('s1level63') z.speed = 'fast' def draw_square(length): for count in range(4): z.move_forward(length) z.turn_right(90) draw_square(50) draw_square(60) draw_square(70) draw_square(80) draw_square(90) z.check()
"""Stage 7: Puzzle 3 of 11 Ok, here's the code you wrote to draw a single triangle. Can you add a repeat (for) loop and turn function call to make a pretty flower? """ import sys sys.path.append('..') import codestudio artist = codestudio.load('s1level37') a = artist artist.color = artist.color_random() for count in range(4): for count in range(3): artist.move_forward(100) artist.turn_right(120) a.rt() artist.check()
import sys sys.path.append('../..') import codestudio z = codestudio.load('s1level66') def draw_snowman(length): z.left() distances = [length * 0.5, length * 0.3, length * 0.2] for counter in range(6): distance = distances[counter if counter < 3 else 5 - counter] / 57.5 for degree in range(90): z.move(distance) z.right(2) if counter != 2: z.left(180) z.left() z.speed = 'fastest' draw_snowman(250) draw_snowman(100) z.check()
"""Stage 5: Puzzle 7 of 10 Ok, let's make it a bit harder - see if you can draw these green glasses. The squares are 100 pixels on each side, and they're 50 pixels apart. Don't forget to draw in green! """ import sys sys.path.append('..') import codestudio artist = codestudio.load('s1level30') a = artist artist.color = 'green' artist.right(90) # ??? artist.check()
import codestudio bird = codestudio.load('s1level02') bird.move_forward() bird.move_forward() bird.check()
import sys sys.path.append('..') import codestudio artist = codestudio.load('enchcode4') artist.color = 'random' #TODO Redo the top to finish it #It was supposed to draw a house artist.turn_right(30) for count2 in range(3): artist.move_forward(100) artist.turn_right(120) artist.check()
import sys sys.path.append('..') import codestudio artist = codestudio.load('enchcode2') artist.color= 'random' artist.speed= 'fastest' for counter in range(4): #TODO Draw a square with sides of 100 pass artist.check()
import sys sys.path.append('..') import codestudio artist = codestudio.load('dima-spiral') artist.speed = 'fastest' artist.width = 5 artist.color = 'random' for counter in range(1, 501, 5): artist.move_forward(counter) artist.turn_right(91) artist.wait()
import sys sys.path.append('..') import codestudio artist = codestudio.load('sample') artist.color = 'random' for counter in range(4): # TODO draw one side and turn pass artist.check()
"""Stage 15: Puzzle 9 of 10 Can you re-create the `draw house(length)` function without help? Try it, and then draw a row of houses. Hint: replace 'pass' with your code. """ import sys sys.path.append('..') import codestudio z = codestudio.load('s1level90') def draw_square(length): for count in range(4): z.move_forward(length) z.turn_right(90) def draw_triangle(length): for count in range(3): z.move_forward(length) z.turn_right(120) def draw_house(length): pass # ???
import sys sys.path.append('../..') import codestudio z = codestudio.load('s1level59') for count in range(4): z.move(100) z.right() z.check()
import codestudio artist = codestudio.load('s1level64') # better, suitable for putting into a function library like `mymod` def draw_square(artist,size): for count in range(4): artist.move_forward(size) artist.turn_right(90) for counter in range(50,90,10): draw_square(artist,counter) artist.check()
import sys sys.path.append('..') import codestudio artist = codestudio.load('sample') artist.color= 'random' for counter in range(4): # TODO draw one side and turn pass artist.check()
import codestudio artist = codestudio.load('s1level25') artist.pen.color= 'red' artist.move_forward(100) # TODO complete the square artist.check()
import codestudio farmer = codestudio.load('s1level47') farmer.move_forward() farmer.move_forward() farmer.move_forward() farmer.dig() farmer.check()
The second number (51) is the maximum plus 1. We add a 1 so that 50 will be included. The third (5) is how much to count by (5,10,15,...50). Even though we have to add 1 to count the way we want, note how much cleaner Python loops are than the ones used in JavaScript (from 'Show Code') and other languages. """ import sys sys.path.append('..') import codestudio zombie = codestudio.load('s1level64') def draw_square(length): for count in range(4): zombie.move_forward(length) zombie.turn_right(90) zombie.speed = 'fast' smallest = 10 # ??? longest = 60 # ??? by = 20 # ??? for counter in range(smallest, longest + 1, by): draw_square(counter)
import sys sys.path.append('../..') import codestudio a = codestudio.load('s1level43') a.speed = 'fastest' for count3 in range(4): for count2 in range(10): a.color = a.color_random() for count in range(4): a.move_forward(20) a.turn_right(90) a.move_forward(20) a.turn_right(80) a.check()
"""Stage 19: Puzzle 2 of 6 Try running this program, and make changes to see what happens. Can you figure out how it works? (Or delete it and replace it with something totally different) """ import sys sys.path.append('..') import codestudio z = codestudio.load('s1level104') z.speed = 'faster' for counter in range(1,300,1): z.color = z.random_color() z.move_forward(counter) z.turn_right(121) z.wait()
"""Stage 15: Puzzle 1 of 10 This puzzle shows you how the `draw_square()` and `draw_circle()` functions are defined. Defining a function doesn't run its blocks. You have to call `draw_square()` function to actually draw a square. Note: in this Python version of code.org you have seen these functions all along in the Stage 11 puzzle code but we focus on them now to explain how to define them. """ import sys sys.path.append('..') import codestudio zombie = codestudio.load('s1level82') z = zombie def draw_square(): for count in range(4): zombie.move_forward(100) zombie.turn_right(90) def draw_circle(): saved_speed = zombie.speed zombie.speed = 'fastest' for count in range(360): zombie.move_forward(1) zombie.turn_right(1) zombie.speed = saved_speed
"""Stage 15: Puzzle 1 of 10 This puzzle shows you how the `draw_square()` and `draw_circle()` functions are defined. Defining a function doesn't run its blocks. You have to call `draw_square()` function to actually draw a square. Note: in this Python version of code.org you have seen these functions all along in the Stage 11 puzzle code but we focus on them now to explain how to define them. """ import sys sys.path.append('..') import codestudio zombie = codestudio.load('s1level82') z = zombie def draw_square(): for count in range(4): zombie.move_forward(100) zombie.turn_right(90) def draw_circle(): saved_speed = zombie.speed zombie.speed = 'fastest' for count in range(360): zombie.move_forward(1) zombie.turn_right(1) zombie.speed = saved_speed draw_square()
import sys sys.path.append('..') import codestudio artist = codestudio.load('rees1') # TODO find and fix the bug for count in range(4): for count in range(4): artist.color = 'random' artist.move_forward(20) artist.turn_right(90) artist.turn_left(90) artist.move_forward(20) artist.check()
"""Stage 11: Puzzle 2 of 11 Welcome to using functions, which let you define blocks of code! Try the new `draw_square()` function to draw a small 50x50 green square. """ import sys sys.path.append('..') import codestudio zombie = codestudio.load('s1level60') z = zombie def draw_square(length): for count in range(4): zombie.move_forward(length) zombie.turn_right(90) draw_square(50) zombie.check()
import sys sys.path.append('..') import codestudio artist = codestudio.load('mustache') artist.width = 4 artist.speed = 'fastest' # TODO make less Vegas for counter in range(1,720): artist.color= 'random' artist.move(10) artist.right(10) # hummmmm artist.check()
"""Stage 11: Puzzle 1 of 11 Hello. Me zombie artist. Me love drawing! Help me draw a square in a special color. Important note: you have all the same actions just with a zombie artist now. """ import sys sys.path.append('..') import codestudio zombie = codestudio.load('s1level59') z = zombie for count in range(4): z.forward(100) z.right() zombie.check()
import sys sys.path.append('../..') import codestudio a = codestudio.load('s1level41') a.color = a.random_colour() for count in range(10): for count in range(4): a.move_forward(20) a.turn_right(90) a.move(20) a.check()
"""Stage 5: Puzzle 2 of 10 Now, draw a square. NOTE: tell the artist to use your favorite color pen by assigning a color to the `artist.color` variable. """ import sys sys.path.append('..') import codestudio artist = codestudio.load('s1level25') a = artist artist.color = 'red' # ??? artist.check()
import sys sys.path.append('../..') import codestudio a = codestudio.load('s1level26') for count in range(4): a.move(100) a.right() a.check()
"""Stage 15: Puzzle 5 of 10 Now create a new `draw_house()` function and use it to house two cats. Hint: copy one of the existing functions to make your own from the code you created in the last puzzle by replacing `pass`. """ import sys sys.path.append('..') import codestudio z = codestudio.load('s1level86') def draw_square(): for count in range(4): z.move_forward(100) z.turn_right(90) def draw_triangle(): for count in range(3): z.move_forward(100) z.turn_right(120) def draw_house(): draw_square() z.move(100) z.right() z.move(100) z.left(120) z.move(100) z.left(120)
import sys sys.path.append('../..') import codestudio a = codestudio.load('s1level29') for count in range(3): a.move(100) a.turn(120) a.turn(180) for count in range(4): a.move(100) a.right() a.check()
"""Stage 15: Puzzle 2 of 10 Using the `draw_square()` function as an example, create a `draw_triangle()` function and use it. Hint: replace the `pass` with your steps to draw a triangle. """ import sys sys.path.append('..') import codestudio z = codestudio.load('s1level83') def draw_square(): for count in range(4): z.move_forward(100) z.turn_right(90) def draw_triangle(): pass # ??? z.check()
import sys sys.path.append('../..') import codestudio z = codestudio.load('s1level107') def draw_circle(step): saved_speed = z.speed z.speed = 'fastest' for count in range(60): z.move_forward(step) z.turn_right(6) z.speed = saved_speed for counter in range(4,9,4): for count in range(10): z.color = z.random_color() draw_circle(counter) z.turn_right(36) z.wait()
"""Stage 15: Puzzle 9 of 10 Can you re-create the `draw house(length)` function without help? Try it, and then draw a row of houses. Hint: replace 'pass' with your code. """ import sys sys.path.append('..') import codestudio z = codestudio.load('s1level90') def draw_square(length): for count in range(4): z.move_forward(length) z.turn_right(90) def draw_triangle(length): for count in range(3): z.move_forward(length) z.turn_right(120) def draw_house(length): pass # ??? z.check()
"""Stage 7: Puzzle 9 of 11 Here's the solution to the previous puzzle. How many degrees should you turn to complete the drawing? (You probably need to guess a few times.) """ import sys sys.path.append('..') import codestudio artist = codestudio.load('s1level43') artist.speed = 'fastest' a = artist for count3 in range(4): for count2 in range(10): artist.color = artist.color_random() for count in range(4): artist.move_forward(20) artist.turn_right(90) artist.move_forward(20) artist.turn_right(80) # ??? artist.check()
import sys sys.path.append('../..') import codestudio a = codestudio.load('s1level32') a.speed = 'fastest' for count in range(360): a.move_backward(1) a.left(1) a.check()
import sys sys.path.append('..') import codestudio artist = codestudio.load('lucas1') artist.color = 'random' artist.width = 2 artist.speed = 'faster' # TODO make it, if you can, lol # ok, one hint, the loop draws 250 lines # but has a maximum counter value of 500 #for counter in range(??,500,??) artist.check()