Python Forum
turtle polygon as specified by user input
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
turtle polygon as specified by user input
#1
The following is an exercise question from tutorial course and my code.

Write a program that asks the user for the number of sides, the length of the side, the color, and the fill color of a regular polygon. The program should draw the polygon and then fill it in.

import turtle      
wn = turtle.Screen()  
alex = turtle.Turtle()

sides = input ("Number of sides in polygon?"  )
length = input ("Length of the sides in polygon?" )
colorname = input ("Color of polygon?" )
fcolor = input ("Fill color of polygon?")

alex.color = (colorname)
alex.fillcolor = (fcolor)

for i in range(sides):
   alex.forward (length)
   alex.left (360 / sides)
Input pop-ups work, but otherwise, no output.
Reply


Messages In This Thread
turtle polygon as specified by user input - by johneven - Feb-28-2019, 08:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Simulate an answer based on user input [Beginner needs guidance] Bombardini 1 1,367 Nov-12-2022, 03:47 AM
Last Post: deanhystad
  Print user input into triangle djtjhokie 1 2,484 Nov-07-2020, 07:01 PM
Last Post: buran
  Changing Directory based on user input paulmerton4pope 13 8,317 Aug-14-2020, 11:48 AM
Last Post: GOTO10
  how to add the user input from file into list wilson20 8 4,433 May-03-2020, 10:52 PM
Last Post: Larz60+
  Writing a function that changes its answer based on user input SirRavenclaw 2 2,913 Dec-21-2019, 09:46 PM
Last Post: Clunk_Head
  Print the longest str from user input edwdas 5 4,284 Nov-04-2019, 02:02 PM
Last Post: perfringo
  how to add user input to a dictionary to a graph KINGLEBRON 3 3,147 Jul-31-2019, 09:09 PM
Last Post: SheeppOSU
  Turtle Polygon drawing program tp_oz 3 3,265 Jul-23-2019, 01:01 PM
Last Post: ichabod801
  New to Python - tiny coding assistance on user input function and assign to variable Mountain_Duck 1 2,584 Mar-23-2019, 06:54 PM
Last Post: Yoriz
  Extracting list element with user input valve 1 2,641 Mar-11-2019, 07:37 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020