draw polygon based on user input - turtle python

0 votes
I'm trying to write a turtle code to ask the user how many sides polygon they would like. How do I do that?
Jul 6, 2019 in Python by Yamini
9,400 views

1 answer to this question.

0 votes

Try something like this:

import turtle
# create a screem
window = turtle.Screen()
#Set the background color
window.bgcolor("lightgreen")
#create turtle
turtle = turtle.Turtle()
# set turtle color
turtle.color("blue")
turtle.pensize(3)
# take input
sides = int(input("How many sides do you want? Use digits: "))
polygon(sides, length)
def polygon(sides,length):
    for x in range(sides):
        shape.forward(length)
        shape.left(360/sides)
answered Jul 6, 2019 by Umer

I have same issue in submitting these work , its very difficult phase.

Hi, @K Jaiswal,

Could you please elaborate on your query so that we can resolve your query sooner as possible?

Related Questions In Python

0 votes
1 answer

Unable to take input from user in Python

num = input("enter number") print(num) READ MORE

answered May 1, 2018 in Python by aayushi
• 750 points
795 views
0 votes
1 answer

Draw a square using the turtle module - Python

Hey @Baily, use something like this: import turtle sq ...READ MORE

answered Jun 22, 2019 in Python by Himanshu
1,586 views
0 votes
1 answer

How do I draw a hexagon using the turtle module of python?

Hey @Jinu, try this: import turtle polygon = ...READ MORE

answered Jun 23, 2019 in Python by Haseeb
7,402 views
0 votes
0 answers

how to merge two data frames based on particular column in pandas python?

I want to  merge two data frames: df1 company,standard tata,A1 cts,A2 dell,A3 df2 company,return tata,71 dell,78 cts,27 hcl,23 I ...READ MORE

May 26, 2022 in Python by Kichu
• 19,040 points
508 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,464 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,125 views
0 votes
1 answer

Snake head placed on the center - Python using turtle

You can use turtle's goto() function. This ...READ MORE

answered Jun 21, 2019 in Python by Greg
837 views
0 votes
1 answer

How do I draw a semi-circle only using turtle - Python

Try this: import turtle turtle = turtle.Pen() turtle.left(90) for x in ...READ MORE

answered Jul 6, 2019 in Python by Bheem
10,282 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP