Write a Python program that prompts a user to select a shape

Write a Python program that prompts a user to select a shape for you to draw. You should give the user at least three options. If the user selects a valid shape, draw the shape using a Turtle object, otherwise tell them that the shape is not valid. Hint: this program will require the use of an if-elif-else block. Sample:
What shape should I draw(circle/triangle/square)? hexagon.
Sorry, I don\'t know how to draw that!
What shape should I draw(circle/triangle/square)? circle

##python turtle graphic circle drawn

Solution

import turtle

print(\"What shape should I draw(circle/triangle/square)?\")
inp=raw_input()
tina = turtle.Turtle()
tina.shape(\'turtle\')
tina.color(\'lime\')
  
while(1):
   if inp == \'circle\':
       circle = tina.circle(50)
       print \'python turtle graphic circle drawn\';
   elif inp == \'square\':
       square = tina.forward(100),tina.right(90),tina.forward(100),tina.right(90)
       square = tina.forward(100),tina.right(90),tina.forward(100),tina.right(90)
       print \'python turtle graphic square drawn\';
   elif inp == \'triangle\':
       triangle = tina.forward(100),tina.right(120),tina.forward(100)
       triangle = tina.right(120),tina.forward(100)
       print \'python turtle graphic triangle drawn\';
   else:
       print(\'Sorry, I don\\\'t know how to draw that!\')
   print(\"What shape should I draw(circle/triangle/square)?\")
   inp=raw_input()
   tina.clear();

Write a Python program that prompts a user to select a shape for you to draw. You should give the user at least three options. If the user selects a valid shape

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site