asked 137k views
0 votes
I cannot figure out how to limit the number that they can make the bars of the turtle go too. I need to find a way to make them not go any higher than 200.

import turtle

Jane = turtle.Turtle()


bar1 = int(input("What is the height of the first bar?" ))


bar2 = int(input("What is the height of the second bar?" ))


bar3 = int(input("What is the height of the third bar?" ))


bar4 = int(input("What is the height of the fourth bar? "))


Jane.left(90)


def bar(height):


Jane.forward(height)


Jane.left(90)


Jane.forward(20)


Jane.left(90)


Jane.forward(height)


Jane.right(180)



bar(bar4)


bar(bar3)


bar(bar2)


bar(bar1)

1 Answer

4 votes

Answer:

import turtle

Jane = turtle.Turtle()

bar1 = int(input("What is the height of the first bar?" ))

bar2 = int(input("What is the height of the second bar?" ))

bar3 = int(input("What is the height of the third bar?" ))

bar4 = int(input("What is the height of the fourth bar? "))

Jane.left(90)

def bar(height):

if height > 200:

height = 200

Jane.forward(height)

Jane.left(90)

Jane.forward(20)

Jane.left(90)

Jane.forward(height)

Jane.right(180)

bar(bar4)

bar(bar3)

bar(bar2)

bar(bar1)

answered
User G Clovs
by
7.9k points