




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A collection of python exercises designed for use with the codehs platform. The exercises focus on drawing various shapes and patterns using the python programming language. Each exercise includes code snippets and instructions, allowing users to practice fundamental programming concepts such as loops, functions, and turtle graphics. The exercises are suitable for beginners learning python and can be used to reinforce basic programming skills.
Typology: Exams
1 / 8
This page cannot be seen from the preview
Don't miss anything!





2.1.4: Stretched Slinky - circle(35) forward(40) circle(35) forward(40) circle(35) forward(40) circle(35) forward(40) circle(35) forward(40)
2.2.4: Shorter Dashed Line - penup() backward(200) pendown() forward(50) penup() forward(50) pendown() forward(50) penup() forward(50) forward(50) penup() forward(50) pendown() forward(50) penup() forward(50) pendown()
2.2.5: Caterpillar - penup() backward(200) pendown() circle(20) penup() forward(40) pendown() circle(20) penup() forward(40) pendown() circle(20) penup()
forward(40) pendown() circle(20) penup() forward(40) pendown() circle(20)
2.3.5: Rectangle - forward(50) left(90) forward(100) left(90) forward(50) left(90) forward(100) left(90)
2.3.6: 4 Columns - penup() left(90) pendown() forward(200) left(180) forward(400) left(90) penup() forward(100) pendown() left(90) forward(400) penup() left(90) forward(200) left(90) pendown() forward(400)
2.4.5: Row of Circles - penup() backward(190) for i in range (20): pendown() circle(10) penup() forward(20)
2.4.6: 4 Columns 2.0 - pendown() backward(190)
setposition(0,0) for i in range (1): pendown() circle(50) penup() forward(100)
2.6.4: Circle Pyramid with Comments - """In this code Tracey will build a pyrimid""" penup() setposition(-100,-200) for i in range (3): pendown() circle(50) penup() forward(100) setposition(-50,-100) #Now Tracey will draw a circle for i in range (2): pendown() circle(50) penup() forward(100) setposition(0,0) for i in range (1): pendown() circle(50) penup() forward(100) #Now Tracey will take a break
2.8.4: Beaded Bracelet - speed(0) """ there must be 36 beads, a radius of 10 pixles, and the braclet must have a diameter of 200. use a function and turn tracy 10 degrees after drawing and return to the middle of each bead. """ speed(0) def draw_beaded_braclet(): for i in range(36): penup() forward(100) pendown() circle(10) penup() backward(100) left(10)
draw_beaded_braclet()
2.8.5: Shape Stack - """This code will help Tracey put her toy blocks into a tall stack""" def draw_circle_stack(): for i in range(4): pendown() circle(25) forward(100) def draw_square_stack(): left(90) for i in range(4): pendown() left(90) circle(50, 360, 4) draw_square_stack() draw_circle_stack()
2.9.5: Four Colored Triangles - speed(0) pensize(5) color("red") backward(100) forward(200) backward(200) left(45) for i in range(4): color("green") forward(50) right(90) color("blue") forward(50)
2.9.6: Colorful Bracelet - speed(0) def draw_colored_braclet(): for i in range(12): penup() color("purple") forward(100) pendown() begin_fill() circle(10) end_fill() penup() backward(100) left(10) penup() color("blue")
for i in range(10): draw_circle_row() move_up_a_row()
2.10.5 sidewalk - speed(0) def line_of_squares(): for i in range(8): pendown() right(45) circle(35,360,4) left(45) forward(50) penup() setposition(-200,150) line_of_squares() penup() setposition(-200,-200) line_of_squares() penup() setposition(200,-200) left(90) line_of_squares() penup() setposition(-150,-200) line_of_squares()
2.11.4: Dartboard - penup() radius= for i in range(25,101,25): setposition(0,0) right(90) forward(i) left(90) pendown() circle(i) penup() def draw_something(): forward(20)
2.11.5: Line of Increasing Blocks - speed(3) size= def make_square(): for i in range(4): pendown() forward(size) left(90)
setposition(-150,0) for i in range(5): make_square() penup() forward(2*size) size=size+