Friday, 15 April 2011

function - Python turtle user input -


I am trying to write some code, when the user overlaps the tortoise, this is what I just But it only pulls a pentagon all the time.

  Import Turtle Turtle Size ('tortoise') DRF triangle (): I in range (3): For turtles. (50) Turtle right (360/3) def class (): For the range I (4): For turtles. (50) Turtle Wright (360/4) def Pentagon (): In Category (5) I: For Turtles. If answer == ('triangle'): triangle () aliff answer == ('square'): 50) Turtle. Wright (360/5) Answer = Input ('Select a shape. Triangle, Square or Pentagon'): Square () Alif Answer == ('Pentagon'): Pentagon () Other: Print ('Incorrect input') < / Code> 

You can try the code below:

 < Code> import turtle deaf triangle (): For the range i (3): For turtles. (50) Turtle Wright (360/3) Def Square (): For the category I (4): For Turtles. (50) Turtle Wright (360/4) def Pentagon (): For the category I (5): For turtles. (50) Turtle (Answer) if answer == ('triangle'): triangle () elif answer = () '' triangular '' ('tortoise') Answer = raw_input ('choose a shape ... triangle, class or pentagon:') = ('Square'): class () alif answer == ('Pentagon'): Pentagon () Other: Print ('wrong input')  

No comments:

Post a Comment