Question: question 8 : Write a function called figure _ row ( x , y , n ) that draws a horizontal line of n stick

question 8: Write a function called figure_row(x, y, n) that draws a horizontal line of n stick figures. Draw the first stick figure at (x, y), and the others to the right of it at equally-spaced intervals. Don't let the figures overlap or go off the screen.
(x, y) should be either the bottom-left or bottom-right corner of the row of stick figures.
Note that there is no size parameter passed to figure_row. Draw stick figures of size s a row of 10 stick figures: using the a2 file def figure_row(x, y, n). so far this is what u have fix it so it draws 10 stick figures in a row next to each other using my a2 file
for i in range(n):
size =10
radius =4
a2.jumpto(x + i *50, y)
a2.eye(radius)
turtle.fillcolor('white')
turtle.begin_fill()
turtle.circle(radius)
turtle.end_fill()
turtle.fillcolor('black')
turtle.begin_fill()
turtle.circle(radius /2)
turtle.end_fill()
a2.draw_happy(size)
a2.jumpto(x, y)
turtle.pendown()
turtle.setheading(-60)
turtle.circle(size,120)
turtle.penup()
a2.draw_sad(size)
turtle.pendown()
turtle.setheading(240)
turtle.circle(size,120)
turtle.penup()
a2.draw_surprised(size)
turtle.pendown()
turtle.setheading(0)
turtle.circle(size)
turtle.penup()
a2.draw_neutral(size)
turtle.pendown()
turtle.goto(-size /2,0)
turtle.forward(size)
turtle.penup()
a2.draw_eyes(size)
turtle.penup()
turtle.goto(-size /4, size /4)
turtle.pendown()
a2.eye(size /5)
turtle.penup()
turtle.goto(size /4, size /4)
turtle.pendown()
a2.eye(size /5)
turtle.penup()
a2.nose(size)
turtle.pensize(size //30)
turtle.penup()
turtle.goto(0, size /5)
turtle.pendown()
turtle.setheading(-120)
turtle.forward(size *0.25)
turtle.left(120)
turtle.forward(size *0.125)
turtle.penup()
return turtle.position()
a2.head(size)
head_color = random.choice(['red', 'blue', 'green', 'yellow', 'purple', 'orange'])
turtle.fillcolor(head_color)
# Draw the head (circle)
turtle.penup()
turtle.goto(0,-size)
turtle.pendown()
turtle.begin_fill()
turtle.circle(size)
turtle.end_fill()
turtle.penup()
# Draw eyes
draw_eyes(size)
# Draw nose
nose_pos = nose(size)
# Draw mouth
turtle.goto(nose_pos[0], nose_pos[1]- size /2)
turtle.setheading(180)
mouth_styles =['happy', 'sad', 'surprised', 'neutral']
selected_mouth = random.choice(mouth_styles)
if selected_mouth == 'happy':
draw_happy(size /4)
elif selected_mouth == 'sad':
draw_sad(size /4)
elif selected_mouth == 'surprised':
draw_surprised(size /4)
else:
draw_neutral(size /4)
a2.body(size)
# Draw the body
turtle.penup()
turtle.goto(0,-size)
turtle.pendown()
turtle.goto(0,-size *2)
turtle.penup()
a2.armsarm(size)
# Draw the arms
turtle.goto(0,-size *1.5)
turtle.pendown()
turtle.goto(-size, -size *1.5)
turtle.penup()
turtle.goto(0,-size *1.5)
turtle.pendown()
turtle.goto(size,-size *1.5)
turtle.penup()
a2.legs(size)
# Draw the legs
turtle.goto(0,-size *2)
turtle.pendown()
turtle.goto(-size /2,-size *3)
turtle.penup()
turtle.goto(0,-size *2)
turtle.pendown()
turtle.goto(size /2,-size *3)
turtle.penup()
a2.stick_figure(size)
head(size)
body(size)
arms(size)
legs(size)
def draw_multiple_rows(start_x, start_y, rows, figures_per_row):
vertical_spacing =70
for i in range(rows):
y_position = start_y - i * vertical_spacing
figure_row(start_x, y_position, figures_per_row)
a2.pyturtle.penup()
a2.turtle.goto(x, Y)
turtle.setheading(0)
turtle.pendown()
a2.stick_figure(a2.size)
turtle.speed(0)
turtle.hideturtle()
turtle.done(). and do question 9 : Write a function called figure_grid(x, y, r, c) that draws a rectangular array consisting of r rows each containing c stick figures (drawn using figure_row). Draw each row at regularly spaced intervals, and don't let figures overlap or go off the screen.
Draw the figures at a size that allows for at least 5 rows and 10 figures per row to fit on the screen.
For example, here's a 10 by 10 grid of stick figures:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!