示例#1
0
def koch(niveau=3, iter=0, taille=100, delta=0):
    """
    Tracé du flocon de Koch de niveau 'niveau', de taille 'taille'
    (px).

    Cette fonction récursive permet d'initialiser le flocon (iter=0,
    par défaut), de tracer les branches fractales (0<iter<=niveau) ou
    bien juste de tracer un segment (iter>niveau).
    """

    if iter == 0:                         # Dessine le triangle de niveau 0
        T.title("Flocon de Koch - niveau {}".format(niveau))
        koch(iter=1, niveau=niveau, taille=taille, delta=delta)
        T.right(120)
        koch(iter=1, niveau=niveau, taille=taille, delta=delta)
        T.right(120)
        koch(iter=1, niveau=niveau, taille=taille, delta=delta)
    elif iter <= niveau:                  # Trace une section _/\_ du flocon
        koch(iter=iter + 1, niveau=niveau, taille=taille, delta=delta)
        T.left(60 + delta)
        koch(iter=iter + 1, niveau=niveau, taille=taille, delta=delta)
        T.right(120 + 2 * delta)
        koch(iter=iter + 1, niveau=niveau, taille=taille, delta=delta)
        T.left(60 + delta)
        koch(iter=iter + 1, niveau=niveau, taille=taille, delta=delta)
    else:                               # Trace le segment de dernier niveau
        T.forward(taille / 3 ** (niveau + 1))
示例#2
0
    def __init__(self):
        turtle.title('Phogo - CRM UAM')
        turtle.mode('logo')
        turtle.penup()

        #turtle.setx(turtle.screensize()[0] // 8)
        turtle.screensize(4000, 4000)
    def __init__(self, model):
        """Initialize the view at the starting of the application."""
        self.model = model

        self.cellWidth = self.CELL_WIDTH
        self.model = model
        self.gridSize = model.GRID_SIZE
        self.player = self.model.player1
        self.screen = turtle.Screen()
        self.gridWidth = self.CELL_WIDTH * self.gridSize
        self.playerGrid = self.player.getGrid(self.player.PLAYER_GRID)
        self.enemyGrid = self.player.getGrid(self.player.OPPONENT_GRID)
        self.iconsToDraw = []

        turtle.title('BATTLESHIP : {} vs {}'.format(
            self.model.player1.playerName, self.model.player2.playerName))
        self.__setScreen()
        self.__setColor()
        turtle.tracer(0, 0)

        gridWidth = self.gridWidth
        gridAnchorPoints = []
        gridAnchorPoints.append((
            -self.width/2 + self.GRID_MARGINLEFT,
            self.height/2 - self.GRID_MARGINTOP - gridWidth))
        gridAnchorPoints.append((
            self.width/2 - gridWidth - self.GRID_MARGINRIGHT,
            self.height/2 - self.GRID_MARGINTOP - gridWidth ))

        self.__drawGrid(gridAnchorPoints[0], gridWidth)
        self.__drawGrid(gridAnchorPoints[1], gridWidth)

        self.gridAnchorPoints = gridAnchorPoints
示例#4
0
def main():
    turtle.title('数据驱动的动态路径绘制')
    turtle.setup(800,600,0,0)
    #设置画笔
    pen = turtle.Turtle()
    pen.color("red")
    pen.width(5)
    pen.shape("turtle")
    pen.speed(5)
    #读取文件
    result = []
    file = open("C:\Users\30908\Desktop\wode.txt","r")
    for line in file:
        result.append(list(map(float,line.split(","))))
    print result
    #动态绘制
    for i in range(len(result)):
        pen.color((result[i][3],result[i][4],result[i][5]))
        pen.fd(result[i][0])
        if result[i][1]:
            pen.rt(result[i][2])
        else:
            pen.lt(result[i][2])
    pen.goto(0,0)
    file.close()
示例#5
0
def main():
    #用户输入一个文件名
    filename = input("enter a filename: ").strip()
    infile = open(filename, 'r')

    #建立用于计算词频的空字典
    wordCounts = {}
    for line in infile:
        processLine(line.lower(), wordCounts)

    #从字典中获取数据对
    pairs = list(wordCounts.items())

    #列表中的数据对交换位置,数据对排序
    items = [[x,y] for (y,x) in pairs]
    items.sort()

    #输出count个数词频结果
    for i in range(len(items)-1, len(items)-count-1, -1):
        print(items[i][1]+'\t'+str(items[i][0]))
        data.append(items[i][0])
        words.append(items[i][1])
    infile.close()

    #根据词频结果绘制柱状图
    turtle.title('词频结果柱状图')
    turtle.setup(900, 750, 0, 0)
    t = turtle.Turtle()
    t.hideturtle()
    t.width(3)
    drawGraph(t)
示例#6
0
    def display( self, text ):
        """Display the finished graphic until the window is closed.

        Might be better to display until key click or mouse click.
        """
        turtle.title( text )
        turtle.ht()
示例#7
0
def main():
  ap = ArgumentParser()
  ap.add_argument('--speed', type=int, default=10,
                  help='Number 1-10 for drawing speed, or 0 for no added delay')
  ap.add_argument('program')
  args = ap.parse_args()

  for kind, number, path in parse_images(args.program):
    title = '%s #%d, path length %d' % (kind, number, path.shape[0])
    print(title)
    if not path.size:
      continue
    pen_up = (path==0).all(axis=1)
    # convert from path (0 to 65536) to turtle coords (0 to 655.36)
    path = path / 100.
    turtle.title(title)
    turtle.speed(args.speed)
    turtle.setworldcoordinates(0, 655.36, 655.36, 0)
    turtle.pen(shown=False, pendown=False, pensize=10)
    for i,pos in enumerate(path):
      if pen_up[i]:
        turtle.penup()
      else:
        turtle.setpos(pos)
        turtle.pendown()
        turtle.dot(size=10)
    _input('Press enter to continue')
    turtle.clear()
  turtle.bye()
示例#8
0
def main():
    bob = turtle.Turtle()
    turtle.title('Sun Figure')
    turtle.setup(800, 800, 0, 0)
    bob.speed(0)
    bobMakesASun(bob, 1, 'purple')
    turtle.done()
示例#9
0
def main():
    # set up the name of the window
    turtle.title("Polygonville")
    # setup the screen size through (1000, 650)
    # setup the initial location through (0,0)
    turtle.setup(1000,650,0,0)
    print("Welcome to Polygonville!")
    totalSides = input("Input number of sides in the polygon: ")
    while totalSides != 0:
        if totalSides < 3:
            print("Sorry, " + str(totalSides) + " is not "
            + "valid, try again or press 0 to exit")
        elif totalSides == 3:
            totalAngles = 180 * (totalSides - 2)
            sideLength = input("Put polygon sidelength: ")
            angle = totalAngles/totalSides
            func1(totalSides, sideLength, angle, totalAngles)
        else:
            totalAngles = 180 * (totalSides - 2)
            sideLength = input("Put polygon side length: ")
            angle = totalAngles/totalSides
            func2(totalSides, sideLength, angle, totalAngles)
        if totalSides > 3:
            print("Polygon Summary: \n" + 
                "Sides: " + str(totalSides) + "| Anterior Angle: " + 
                str(angle) + "| Sum of Angles: " + str(totalAngles))
        totalSides = input("\nInput number of sides in the polygon: ")
    if totalSides == 0:
        print("Thank you for using Polygonville!")
示例#10
0
def main():
    fileName = input('input a file name:').strip()
    infile = open(fileName, 'r')
    
    wordCounts = {}
    for line in infile:
        processline(line.lower(), wordCounts)
    
    pairs = list(wordCounts.items())
    items = [[x, y] for (y, x) in pairs]
    items.sort()
    for i in range(len(items)):
        if items[i][1] == ' ':
            items.pop(i)
    for i in range(len(items)-1, len(items)-count-1, -1):
        print(items[i][1]+'\t'+str(items[i][0]))
        data.append(items[i][0])
        words.append(items[i][1])
    infile.close()
    
    turtle.title('wordCounts chart')
    turtle.setup(900, 750, 0, 0)
    t = turtle.Turtle()
    t.hideturtle()
    t.width(3)
    
    drawGraph(t)
def startGame():
    '''Draws the grid ready to play the game
       Clears the grid to make sure it is empty before starting a new game
       Displays the rules/how to play to the user
       Asks the user which game mode to play by calling gameModeSelection()'''       
    
    turtle.setup(650,600)
    turtle.title("Noughts and Crosses by Genaro Bedenko")
    drawGrid()

    # Reset the gridSquares to be empty
    # This is needed for when a game has already been played and the player chose 
    # to play again, they need to play from a new grid
    for i in range(1,10):
        gridSquares[i] = 0

    displayRules()

    playSavedGame = messagebox.askquestion(title="Play Previous Game?", message="Do you want to play a previously saved game?")

    if(playSavedGame=="yes"):
        try:
            loadGame(gridSquares)

        # If the user clicks yes to play a saved game but their isn't one saved in the directory. Display a message to tell them
        # this and move on to starting a new game
        except FileNotFoundError:
            messagebox.showinfo(title="No Saved Game Available", message="There isn't a currently saved game available to play")
            gameModeSelection()
    else:
        gameModeSelection()
示例#12
0
def init():
    t.setworldcoordinates(0,0,
        WINDOW_WIDTH, WINDOW_HEIGHT)
    t.up()
    t.setheading(90)
    t.forward(75)
    t.title('Typography:Name')
示例#13
0
def drawSetup(title,xlimits,xscale,ylimits,yscale,axisThickness=None):
	turtle.title(title)
	xmin, xmax = xlimits
	ymin, ymax = ylimits
	#turtle.setup(xmax-xmin,ymax-ymin,0,0) #window-size
	globals()['xmin'] = xmin
	globals()['xmax'] = xmax
	globals()['ymin'] = ymin
	globals()['ymax'] = ymax
	globals()['xscale'] = xscale
	globals()['yscale'] = yscale

	turtle.setworldcoordinates(xmin,ymin,xmax,ymax)
	#turtle.speed(0) #turtle.speed() does nothing w/ turtle.tracer(0,0)
	turtle.tracer(0,0)

	drawGrid()
	#drawGridBorder()
	
	turtle.pensize(axisThickness)

	drawXaxis()
	drawXtickers()
	numberXtickers()
	
	drawYaxis()
	drawYtickers()
	numberYtickers()

	turtle.pensize(1)
示例#14
0
    def __init__(self):
        # Janela sobre
        self.janSobre = None


        # Cor de fundo
        self.corFundo = "gray"


        turtle.screensize(1000, 700, self.corFundo)
        turtle.setup(width=1000, height=700)
        turtle.title("cidadeBela - Janela de desenho")


        turtle.speed(0)
        turtle.tracer(4)

        # Definindo variáveis globais
        self._tamPadrao = ""

        # Listas de prédios
        self.predios = ['Casa', 'Hotel']
        self.prediosProc = [ 'hotel', 'hotelInv', 'casa', 'casaInv' ]


        # Sorteando elementos
        self.sorteioPredios    = [["casa", 1], ["hotel", 1]]
        self.sorteioPrediosInv = [["casaInv", 1], ["hotelInv", 1]]


        #  Cores dos prédios
        self.coresHotel = ["076080190", "255255255", "167064057", "153204255", "000090245",
                           "201232098", "255058123", "010056150", "130255255", "255255000",
                           "255000000", "255127042", "000255000", "255170255", "000255170",
                           "212000255", "170255127", "127212255", "255127127", "255212085",
                           "212212255", "255255127", "222202144" ]
        self.coresCasa  = ['209187103', '115155225', '130047006', '255137111', '203229057',
                           '017130100', '025195159', '204057065', '194082255', '092221159',
                           '167045055', '238243030', '069241248', '000156228', '159094040',
                           '048033253', '040209239', '138164253', '190042177', '000122159',
                           '255255255', '253208201', '245228133']
        self.coresLoja  = ['255255255', '253208201', '245228133' ]

        #  Janelas dos prédios
        self.janelasHotel = janelas.janelasHotel
        self.janelasCasa  = janelas.janelasCasa
        self.janelasLoja  = janelas.janelasLoja
        self.janelasTodas = janelas.janelasTodas

        #  Tetos dos prédios
        self.tetosHotel = tetos.tetosHotel
        self.tetosCasa  = tetos.tetosCasa
        self.tetosLoja  = tetos.tetosLoja
        self.tetosTodas = tetos.tetosTodas

        #  Portas dos prédios
        self.portasHotel = portas.portasHotel
        self.portasCasa  = portas.portasCasa
        self.portasLoja  = portas.portasLoja
        self.portasTodas = portas.portasTodas
def regression():
    filename = input("Please provide the name of the file including the extention: ")
    while not (os.path.exists(filename)):
        filename = input("Please provide a valid name for the file including the extention: ")
    ds = []
    file = open(filename)

    for line in file:
        coordinates = line.split()
        x = float(coordinates[0])
        y = float(coordinates[1])
        point = (x, y)
        ds.append(point)
    my_turtle = turtle.Turtle()
    turtle.title("Least Squares Regression Line")

    turtle.clearscreen()
    xmin = min(getXcoords(ds))
    xmax = max(getXcoords(ds))
    ymin = min(getYcoords(ds))
    ymax = max(getYcoords(ds))
    xborder = 0.2 * (xmax - xmin)
    yborder = 0.2 * (ymax - ymin)
    turtle.setworldcoordinates(xmin - xborder, ymin - yborder, xmax + xborder, ymax + yborder)
    plotPoints(my_turtle, ds)
    m, b = leastSquares(ds)
    print("The equation of the line is y=%fx+%f" % (m, b))
    plotLine(my_turtle, m, b, xmin, xmax)
    plotErrorBars(my_turtle, ds, m, b)
    print("Goodbye")
示例#16
0
def turtleProgram():
    import turtle
    import random
    global length
    turtle.title("CPSC 1301 Assignment 4 MBowen") #Makes the title of the graphic box
    turtle.speed(0) #Makes the turtle go rather fast
    for x in range(1,(numHex+1)): #For loop for creating the hexagons, and filling them up
        turtle.color(random.random(),random.random(),random.random()) #Defines a random color
        turtle.begin_fill()
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.forward(length)
        turtle.left(60)
        turtle.end_fill()
        turtle.left(2160/(numHex))
        length = length - (length/numHex) #Shrinks the hexagons by a small ratio in order to create a more impressive shape
    turtle.penup()   
    turtle.goto(5*length1/2, 0) #Sends turtle to a blank spot
    turtle.color("Black")
    turtle.hideturtle()
    turtle.write("You have drawn %d hexagons in this pattern." %numHex) #Captions the turtle graphic
    turtle.mainloop()
示例#17
0
def main():
    #设置窗口信息
    turtle.title('数据驱动的动态路径绘制')
    turtle.setup(800, 600, 0, 0)
    #设置画笔
    pen = turtle.Turtle()
    pen.color("red")
    pen.width(5)
    pen.shape("turtle")
    pen.speed(5)
    #读取文件
    result=[]
    file = open("data.txt","r")
    for line in file:
        result.append(list(map(float, line.split(','))))
    print(result)
    #动态绘制
    for i in range(len(result)):
        pen.color((result[i][3],result[i][4],result[i][5]))
        pen.forward(result[i][0])
        if result[i][1]:
            pen.rt(result[i][2])
        else:
            pen.lt(result[i][2])
    pen.goto(0,0)
示例#18
0
def init():
    """
    sets the window size and the title of the program
    """
    t.setworldcoordinates(0, 0, WINDOW_LENGTH, WINDOW_HEIGHT)
    t.title('Forest')
    t.up()
    t.forward(100)
示例#19
0
def draw_background():
    t.setup(300, 500)
    t.title('Hangman')
    t.pu()
    t.setpos(-100, -200)
    t.seth(0)
    t.pd()
    t.fd(200)
示例#20
0
 def __init__(self, title="Game of Life", dimension=(1200,800), speed='slow', dotsize=10):
     """  initialze the turtle object  """
     self.dotsize = dotsize
     w, h = dimension
     turtle.setup(w, h, 0,0)
     turtle.title(title)
     turtle.speed(speed)
     turtle.shape('blank')
     turtle.Turtle.__init__(self)
示例#21
0
文件: spiro.py 项目: diopib/pp
def main():
    # use sys.argv if needed
    print('generating spirograph...')
    # create parser
    descStr = """This program draws spirographs using the Turtle module. 
    When run with no arguments, this program draws random spirographs.
    
    Terminology:

    R: radius of outer circle.
    r: radius of inner circle.
    l: ratio of hole distance to r.
    """
    parser = argparse.ArgumentParser(description=descStr)
  
    # add expected arguments
    parser.add_argument('--sparams', nargs=3, dest='sparams', required=False, 
                        help="The three arguments in sparams: R, r, l.")
                        

    # parse args
    args = parser.parse_args()

    # set to 80% screen width
    turtle.setup(width=0.8)

    # set cursor shape
    turtle.shape('turtle')

    # set title
    turtle.title("Spirographs!")
    # add key handler for saving images
    turtle.onkey(saveDrawing, "s")
    # start listening 
    turtle.listen()

    # hide main turtle cursor
    turtle.hideturtle()

    # checks args and draw
    if args.sparams:
        params = [float(x) for x in args.sparams]
        # draw spirograph with given parameters
        # black by default
        col = (0.0, 0.0, 0.0)
        spiro = Spiro(0, 0, col, *params)
        spiro.draw()
    else:
        # create animator object
        spiroAnim = SpiroAnimator(4)
        # add key handler to toggle turtle cursor
        turtle.onkey(spiroAnim.toggleTurtles, "t")
        # add key handler to restart animation
        turtle.onkey(spiroAnim.restart, "space")

    # start turtle main loop
    turtle.mainloop()
示例#22
0
def init():
    turtle.setworldcoordinates(-WINDOW_WIDTH / 2, -WINDOW_WIDTH / 2,
                               WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2)
    turtle.up()
    turtle.setheading(0)
    turtle.hideturtle()
    turtle.title('Snakes')
    turtle.showturtle()
    turtle.setx(-225)
    turtle.speed(0)
示例#23
0
def init():
    """
    Initialize the canvas
    :pre: relative (0,0), heading east, up
    :post: relative (0,0), heading east, up
    :return: None
    """
    t.setworldcoordinates(-BOUNDARY/2, -BOUNDARY/2, BOUNDARY, BOUNDARY)
    t.title("SQUARES")
    t.speed(0)
示例#24
0
文件: mv.py 项目: islarrab/raplog
def main():
    if (len(sys.argv) <= 1):
        print "No se encuentra archivo."
        exit(1)
    else:
        turtle.title("Raplog - "+sys.argv[1])
        cargarArchivo(sys.argv[1])
        if permiteEjecutar():
            ejecutaCuadruplos()
            if a:
                turtle.done()
示例#25
0
 def __init__(self,actions,drawColour="black"):
     self.actions = actions
     self.stack = []
     t.setup()
     # Try to make the animation of drawing reasonably fast.
     t.tracer(100,0) # Only draw every 50th update, set delay to zero.
     t.title ("Jose Javier's L System demo")
     t.reset()
     t.degrees()
     t.color(drawColour)
     t.hideturtle() # don't draw the turtle; increase drawing speed.
def init(x , y):
    """	
    :input: x and y corrdinate for setting intial/starting corrdinates
    :pre:(relative) pos (0,0), heading (east), up
    :post:(relative) pos (x,y), heading (east), up
    :return: None
    """
    t.up()
    t.title('forest')
    t.setx(x)
    t.sety(y)
示例#27
0
def initialisePostLoad(path):
    """See: initialise method: same process without screen resolution process

    Adds extra 'title' functionality, displaying the name of the loaded file as
    the title.
    """
    turtle.title(path)
    turtle.shape("turtle")
    turtle.color("black")
    turtle.speed(7)
    turtle.pendown()
示例#28
0
文件: tgp.py 项目: Splint/Python-PPA
def drawShape(shape, red, blue, green):
    tu.title("Turtle Graphics with Python")
    tu.fillcolor(red, blue, green)
    tu.pencolor(red, blue, green)

    tu.up()
    tu.begin_fill()

    if shape.lower() == 'square':
        tu.goto(100, 100)
        tu.down()
        tu.goto(100, -100)
        tu.goto(-100, -100)
        tu.goto(-100, 100)
        tu.goto(100, 100)
        tu.end_fill()

    elif shape.lower() == "circle":
        tu.down()
        tu.circle(100)
        tu.end_fill()

    elif shape.lower() == "triangle":
        tu.goto(-100, -100)
        tu.down()
        tu.goto(100, -100)
        tu.goto(0, 100)
        tu.goto(-100, -100)
        tu.end_fill()
    
    elif shape.lower() == "rectangle":
        tu.goto(200, 50)
        tu.down()
        tu.goto(200, -50)
        tu.goto(-200, -50)
        tu.goto(-200, 50)
        tu.goto(200, 50)
        tu.end_fill()

    elif shape.lower() == "pentagon":
        tu.goto(0, 100)
        tu.down()
        tu.goto(-100, 0)
        tu.goto(-50, -100)
        tu.goto(50, -100)
        tu.goto(100, 0)
        tu.goto(0, 100)
        tu.end_fill()

    else:
        print "An error occurred. Exiting."
        sys.exit()
    
    tu.done()
示例#29
0
def init():
    """
    Initialize for drawing, (-500, -250) is in the lower left and
    (500, 500) is in the upper right
    :pre: pos (0,0), heading (east), up
    :pos: pos (0,0), heading (north), up
    :return: None
    """
    t.setworldcoordinates(-WINDOW_WIDTH, -WINDOW_HEIGHT/2, WINDOW_WIDTH, WINDOW_HEIGHT)
    t.left(90)
    t.title('Enhanced Tree')
    t.speed(0)
示例#30
0
def turtleProgram():
    import turtle
    import random
    turtle.title("CPSC 1301 Assignment 4 MBowen")
    turtle.speed(0)
    for x in range(1,(numShapes+1)):
        if 2 <= side <= 5:
            turtle.color(random.random(),random.random(),random.random())
            turtle.begin_fill()
            turtle.forward(length)
            turtle.left(90)
            turtle.forward(length)
            turtle.left(90)
            turtle.forward(length)
            turtle.left(90)
            turtle.forward(length)
            turtle.left(90)
            turtle.left(360/numShapes)
            turtle.end_fill()
        if side == 6:
            turtle.color(random.random(),random.random(),random.random())
            turtle.begin_fill()
            turtle.forward(length)
            turtle.left(360/side)
            turtle.forward(length)
            turtle.left(360/side)
            turtle.forward(length)
            turtle.left(360/side)
            turtle.forward(length)
            turtle.left(360/side)
            turtle.forward(length)
            turtle.left(360/side)
            turtle.left(360/numShapes)
            turtle.end_fill()
        if side == 7:
            turtle.color(random.random(),random.random(),random.random())
            turtle.begin_fill()
            turtle.forward(length)
            turtle.left(360/side)
            turtle.forward(length)
            turtle.left(360/side)
            turtle.forward(length)
            turtle.left(360/side)
            turtle.forward(length)
            turtle.left(360/side)
            turtle.forward(length)
            turtle.left(360/side)
            turtle.forward(length)
            turtle.left(360/side)
            turtle.left(360/numShapes)
            turtle.end_fill()
    turtle.mainloop()
示例#31
0
import turtle
import threading
from math import *


def call1(x, y):
    print(x, y)


turtle.title('거북이')
colors = ['red', 'green', 'blue']

# my = turtle.Turtle('turtle')
#
# my.pensize(10)
# my.pencolor('black')
# turtle.onscreenclick(call1, 1)
#
# my.penup()
# my.goto(-200,0)
# my.pendown()
# for i in range(-200,201):
#     my.goto(i, (200**2 - i**2)**0.5)
#     if i%20 == 0:
#         my.pencolor(colors[(i//20)%len(colors)])
# for i in range(200,-201,-1):
#     my.goto(i, -((200**2 - i**2)**0.5))
#     if i%20 == 0:
#         my.pencolor(colors[(i//20)%len(colors)])
# my.penup()
# my.goto(0,0)
示例#32
0
    else:
        draw_hex_star(pointer, length)
        pointer.right(30)
        pointer.color(colours[depth % 2])
        pointer.begin_fill()
        draw_circle(pointer, length / math.sqrt(3))
        pointer.end_fill()
        pointer.left(30)
        if colours[depth % 2] == 'green':
            area1 = math.pi * ((length / math.sqrt(3))**2)
            draw_bulls_eye_rec(pointer, depth - 1, length / math.sqrt(3),
                               area + area1)
        elif colours[depth % 2] == 'blue' and area > 0:
            area1 = math.pi * ((length / math.sqrt(3))**2)
            draw_bulls_eye_rec(pointer, depth - 1, length / math.sqrt(3),
                               area - area1)
        else:
            area1 = math.pi * ((length / math.sqrt(3))**2)
            draw_bulls_eye_rec(pointer, depth - 1, length / math.sqrt(3), area)


if __name__ == "__main__":
    turtle.setworldcoordinates(-WINDOW_HEIGHT / 2, -WINDOW_WIDTH / 2,
                               WINDOW_HEIGHT / 2, WINDOW_WIDTH / 2)
    turtle.title("Bullseye")
    turtle_obj = turtle.Turtle()
    turtle_obj._tracer(0, 0)
    turtle_obj.setheading(0)
    draw_bulls_eye_rec(turtle_obj, 6, 100)
    turtle_obj._update()
    turtle.done()
    for k in range(5):
        tu.forward(side)
        tu.right(144)
        tu.forward(side)
    tu.end_fill()


def random_length():
    return rn.randrange(5, 25)


def random_xy_coord():
    return rn.randrange(-290, 290), rn.randrange(-270, 270)


tu.title('a star filled sky')
tu.bgcolor('black')
# optional ('normal' is default) ...
# values for speed are 'fastest' (no delay), 'fast', (delay 5ms),
# 'normal' (delay 10ms), 'slow' (delay 15ms), 'slowest' (delay 20ms)
tu.speed('fastest')
colors = ['red', 'orange', 'magenta', 'green', 'blue', 'yellow', 'white']
# number of stars you want to show
stars = 50
for k in range(stars):
    color = rn.choice(colors)
    side = random_length()  # length of side
    x, y = random_xy_coord()
    draw_star(x, y, color, side)
# keep showing until window corner x is clicked
tu.done()
示例#34
0
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 19 15:55:35 2017

@author: 陈鑫一
"""

import turtle
turtle.title('数据驱动的动态路径绘制')
turtle.setup(800,600,0,0)
pen=turtle.Turtle()
pen.color("red")
pen.width(5)
pen.shape("turtle")
pen.speed(5)
result=[]
file=open("D:\data.txt","r")
for line in file:
    result.append( list( map(float,line.split(',')  ) )  )
print(result)
for i in range (len(result)):
    pen.color((result[i][3],result[i][4],result[i][5]))
    pen.forward(result[i][0])
    if result[i][1]:
        pen.rt(result[i][2])
    else:
        pen.lt(result[i][2])
pen.goto(0,0)
示例#35
0
def initPen():
    turtle.title('轨迹绘制')
    turtle.setup(800, 600, 0, 0)
    turtle.pencolor('red')
    turtle.pensize(5)
示例#36
0
#AutoTraceDraw.py
import turtle as t
t.title("自动轨迹绘制")
t.setup(800,600,0,0)
t.pencolor("red")
t.pensize(5)
#数据读取
datals = []
f = open('data.txt')
for line in f:
    line = line.replace('\n','')
    datals.append(list(map(eval, line.split(','))))
f.close()
#自动绘制
for i in range(len(datals)):
    t.pencolor(datals[i][3], datals[i][4], datals[i][5])
    t.fd(datals[i][0])
    if datals[i][1]:
        t.right(datals[i][2])
    else:
        t.left(datals[i][2])
import turtle as t
import time
from tkinter import Tk, simpledialog, messagebox, Canvas
import webbrowser

wt = t.Turtle()
t.title('BELL Multiple Windows Manager 20')
wt.ht()
wt.write("MADE BY BELL", align='center', font=('Arial', 40, 'bold'))
time.sleep(1)
wt.clear()
time.sleep(1)
wt.write("Bell MWM 20-multiple windows without bugs.",
         align='center',
         font=('Arial', 20, 'bold'))
time.sleep(2)
wt.clear()
time.sleep(1)
answer = simpledialog.askstring('Password', 'Welcome,enter sd2 to the box.')
if answer == 'sd2':
    wt.write("Enjoy MWM!!!", align='center', font=('Arial', 20, 'bold'))
    time.sleep(1)
    wt.clear()
    wt.write("Press i for Instagram",
             align='center',
             font=('Arial', 20, 'bold'))
    time.sleep(1)
    wt.clear()
    wt.write("Press y for Youtube", align='center', font=('Arial', 20, 'bold'))
    time.sleep(1)
    wt.clear()
def draw_forces(alpha, f1, f2, speed=1):
    # hier kann das ganze gedoens aufgezeichnet werden
    # mit dem turle modul
    breite = 1200
    hoehe = 800
    import turtle
    t = turtle.Turtle()
    s = turtle.getscreen()
    s.setup(breite, hoehe)
    # berechnung der Skalierung
    if f1 > f2:
        f1_scale = 350
        f2_scale = (f2 * 350) / f1
    else:
        f2_scale = 350
        f1_scale = (f1 * 350) / f2
    # nun sind die sklaierten Kraefte festgelegt
    # moege das Zeichen beginnen!
    t.shape("turtle")
    t.reset()
    t.penup()
    turtle.title("Copyright Niklas Abraham")
    t.fillcolor("red")
    t.speed(speed)
    t.goto(-300, 0)
    t.clear()
    t.clearstamps()
    t.pendown()
    t.pensize(5)
    t.pencolor('red')
    t.pendown()
    t.right(alpha / 2)
    t.forward(f1_scale)
    t.shape("arrow")
    t.stamp()
    t.shape("turtle")
    pos_1 = t.pos()
    t.penup()
    t.goto(-300, 0)
    t.left(alpha)
    t.pendown()
    t.pencolor('blue')
    t.fillcolor("blue")
    t.forward(f2_scale)
    t.shape("arrow")
    t.stamp()
    t.shape("turtle")
    t.pencolor('red')
    t.fillcolor("red")
    t.right(alpha)
    t.forward(f1_scale)
    t.shape("arrow")
    t.stamp()
    t.shape("turtle")
    t.penup()
    t.goto(pos_1[0], pos_1[1])
    t.shape("arrow")
    t.stamp()
    t.shape("turtle")
    t.pencolor('blue')
    t.fillcolor("blue")
    t.pendown()
    t.left(alpha)
    t.forward(f2_scale)
    t.shape("arrow")
    t.stamp()
    t.shape("turtle")
    t.penup()
    pos_2 = t.pos()
    t.goto(-300, 0)
    t.pencolor('green')
    t.fillcolor("green")
    t.right(alpha)
    t.pendown()
    t.goto(pos_2[0], pos_2[1])
    print('Die resultierende Kraft ist:', cal_res_Kraft(alpha, f1, f2))
示例#39
0
def PuntoMedio(x1,x2):
    return (x1+x2)/2

salir = False
while not salir:
    print("digite el numero del fractal que desee ver");
    print("1.Sierspinsky sieve(Regla 90)");
    print("2.Box Fractal");
    print("3.FractalH");
    print("4.Salir");
    respuesta= int(input('Ingrese la respuesta: '));
    if respuesta==1:
        n= int(input('Digite n '));
        turtle.clearscreen()
        t.hideturtle()
        turtle.title("Sierspinsky sieve(Regla 90)")
        sierspinskySieve(-298,-171,0,343,297,-171,n,t)
        PorcentajeT(n)
       
    else:
        if respuesta==2:
            n= int(input('Digite n '))
            turtle.clearscreen()
            t.hideturtle()
            turtle.title("Box Fractal")
            boxFractal(-343,343,343,343,343,-343,-343,-343,n,t)
            PorcentajeB(n)
        else:
            if respuesta==3:
                n= int(input('Digite n '))
                turtle.clearscreen()
示例#40
0
from __future__ import division
from __future__ import print_function

import turtle
from random import randint

LONGEUR = 800
LARGEUR = 800
turtle.setup(LONGEUR, LARGEUR)
turtle.title("Sah")
turtle.bgcolor("white")
turtle.showturtle()


def somme_carres_classique(n):
    somme = 0
    for i in range(n + 1):
        somme += i**2
    return somme


# somme_carres_classique(50)


def somme_carre_recur(n):
    if n == 1:
        somme = 1
    else:
        somme = somme_carre_recur(n - 1) + n**2
    return somme
示例#41
0
import turtle
import math
turtle.title("Moving star pattern - pattern #2")
bob = turtle.Turtle()
bob.color("#39a275", "#82caaf")
bob.speed(75)
bob.pensize(1.125)
bob.begin_fill()
for i in range(300):
    bob.forward(math.sqrt(i) * 10)
    bob.left(168)
bob.end_fill()
turtle.done()
示例#42
0
###################################################################
#FILE: HelloTurtle.py                                             #
#WRITER: Ran Shaham,ransha,203781000                              #
#EXERCISE: intro2cs ex1 2014-2015                                 #
#DESCRIPTION:                                                     #
#A program that draws some simple geometric shapes on the screen  #
#and prints "Hello Turtle!", using Turtle graphics.               #
###################################################################
import turtle

#title for the display window
turtle.title("Fun with Tutrtle Graphics and Python")
turtle.up()  #lift the pen up, no drawing.
turtle.goto(-100, -100)  #move turtle to the absolute position (-100,-100)
turtle.down()  #pen is down, drawing now.
# I will now draw a red square.
turtle.color("red")
turtle.goto(100, -100)  #moves the pen 200 points ONLY to the right,
#thus creating the lower end of the square.
turtle.goto(
    100, 100
)  #the right end of the square (200 points ONLY on the y axis) and so on...
turtle.goto(-100, 100)
turtle.goto(-100, -100)  #returned to the initial point.
#Now for an orange circle. since the circle's center in Turtle is drawn 'r'
#points to the LEFT of the turtle's position, and the turtle is heading
#to the east, I will start drawing from the point (0,-100) because the
#circle radius is 100 (and this point is 100 points to the RIGHT of turtle,
#so the center will be at (0,0))
turtle.up()
turtle.goto(0, -100)
示例#43
0
#IRON MAN DRAWING
import turtle
piece1=[[(-40, 120), (-70, 260), (-130, 230), (-170, 200), (-170, 100), (-160, 40), (-170, 10), (-150, -10), (-140, 10), (-40, -20), (0, -20)],[(0, -20), (40, -20), (140, 10), (150, -10), (170, 10), (160, 40), (170, 100), (170, 200), (130, 230), (70, 260), (40, 120), (0, 120)]]
piece2=[[(-40, -30), (-50, -40), (-100, -46), (-130, -40), (-176, 0), (-186, -30), (-186, -40), (-120, -170), (-110, -210), (-80, -230), (-64, -210), (0, -210)],[(0, -210), (64, -210), (80, -230), (110, -210), (120, -170), (186, -40), (186, -30), (176, 0), (130, -40), (100, -46), (50, -40), (40, -30), (0, -30)]]
piece3=[[(-60, -220), (-80, -240), (-110, -220), (-120, -250),(-90, -280), (-60, -260), (-30, -260), (-20, -250), (0, -250)],[(0, -250), (20, -250), (30, -260), (60, -260), (90, -280), (120, -250),(110, -220), (80, -240), (60, -220), (0, -220)]]
turtle.bgcolor('#ba161e')
turtle.setup(500,600)
turtle.title("I AM IRONMAN")
piece1Goto=(0,120)
piece2Goto=(0,-30)
piece3Goto=(0,-220)
turtle.speed(2)
def draw_piece(piece,pieceGoto):
    turtle.penup()
    turtle.goto(pieceGoto)
    turtle.pendown()
    turtle.color('#fab104') #Light Yellow
    turtle.begin_fill()
    for i in range(len(piece[0])):
        x,y=piece[0][i]
        turtle.goto(x,y)
    
    for i in range(len(piece[1])):
        x,y=piece[1][i]
        turtle.goto(x,y)
    turtle.end_fill()
    
draw_piece(piece1,piece1Goto)
draw_piece(piece2,piece2Goto)
draw_piece(piece3,piece3Goto)
turtle.hideturtle()
        






def message(m1, m2):
    t.clear()
    t.goto(0, 100)
    t.write(m1, False, "center",("", 20))
    t.goto(0, -100)
    t.write(m2, False, "center",("", 20))
    t.home()

t.title("Turtle Run")
t.setup(500, 500)
t.shape("turtle")
t.bgcolor("skyblue")
t.speed(0)
t.up()
t.color("gold")



t.onkeypress(turn_right, "Right")
t.onkeypress(turn_up, "Up")
t.onkeypress(turn_left, "Left")
t.onkeypress(turn_down, "Down")
t.onkeypress(start , "space")
t.listen()
示例#45
0
文件: shapes.py 项目: Jcvita/CS1
def init():
    """Initialize turtle"""
    turtle.up()
    turtle.title("Shapes")
    turtle.pensize(4)
示例#46
0
import turtle as tl
screen=tl.getscreen()
tl.title("Draw Japan Flag")
#all color between 0 to 1
turtle_speed=200
tl.speed(turtle_speed)
starting_point=tl.position()
bg_color=(.4,.6,.2)
tl.bgcolor((bg_color))
#height and width of flag 10:6
flag_width=300
flag_height=flag_width*.6
#radius of flag
radius=flag_width/5


def stop_draw(circle_center):
    x,y=circle_center
    global tl
    tl.penup()
    tl.goto(x,y)
    tl.pendown()


##draw the box of flag
box_color=(1,1,1)
tl.pen(pencolor=box_color,fillcolor=box_color)
tl.begin_fill()
tl.forward(flag_width)
tl.left(90)
tl.forward(flag_height)
示例#47
0
def colorin(nucleoti):
    if nucleoti == a:
        return 'red'
    if nucleoti == g:
        return 'blue'
    if nucleoti == t:
        return 'green'
    if nucleoti == c:
        return 'yellow'


inicio = 10
inicio2 = 10

turtle.title('ADN')
turtle.setup(1530, 1000, 0, 0)
turtle.screensize(20, 8000)
turtle.hideturtle()
turtle.penup()
turtle.goto(-10, -40)
turtle.write("Arreglo 5'", False, "left", ("arial", 20, "bold italic"))
turtle.goto(-200, -40)
turtle.write("Errores", False, "left", ("arial", 20, "bold italic"))
turtle.goto(-500, 300)
turtle.pencolor('red')
turtle.write("Adenina", False, "left", ("arial", 18, "bold italic"))
turtle.goto(-500, 250)
turtle.pencolor('blue')
turtle.write("Guanina", False, "left", ("arial", 18, "bold italic"))
turtle.goto(-500, 200)
示例#48
0
        T.goto(T.xcor(), 0)
    elif WhatNum <= 16:
        T.goto(T.xcor(), -250)

    if WhatNum % 4 == 1:
        T.goto(-900, T.ycor())
    elif WhatNum % 4 == 2:
        T.goto(-450, T.ycor())
    elif WhatNum % 4 == 3:
        T.goto(0, T.ycor())
    elif WhatNum % 4 == 0:
        T.goto(450, T.ycor())


music = pygame.mixer.music
t.title("거북왕을 찾아라")
t.shape("turtle")
t.setup(width=1920, height=1070, startx=0, starty=0)
T = t.clone()
T.speed(0)
while 1:
    t.reset()
    T.clear()
    T.ht()  # 타이머만 출력할거니까 은신
    T.up()  # 타이머만 출력할거니까 거북이놈 꼬리 들쳐버리기
    T.color("red")  # 글자 색깔 빨강
    T.goto(0, 495)  # 글자를 출력할 위치로 보냄
    pygame.init()
    music.load("Darara_5sec.mp3")
    t.fillcolor("#FACC2E")
示例#49
0
import turtle
turtle.title("My turtle drawing!!!")
turtle.setup(width=900, height=700, startx=0, starty=0)

turtle.pencolor('red')
turtle.speed(1)
#turtle.hideturtle()


def draw_square(size):
    turtle.forward(size)
    turtle.right(90)
    turtle.forward(size)
    turtle.right(90)
    turtle.forward(size)
    turtle.right(90)
    turtle.forward(size)


def draw_octagon(size):
    turtle.forward(size)
    turtle.right(45)
    turtle.forward(size)
    turtle.right(45)
    turtle.forward(size)
    turtle.right(45)
    turtle.forward(size)
    turtle.right(45)
    turtle.forward(size)
    turtle.right(45)
    turtle.forward(size)
示例#50
0
import turtle
screen = turtle.getscreen()
turtle.title("triangle")
turtle = turtle.Turtle()  # створюємо об'єкт
turtle.shape("classic")  # можемо міняти форму , міняємо на черепашку
turtle.color("black")  # міняємо колір об'єкта

turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.right(120)
示例#51
0
def main():
    # put label on top of page
    turtle.title('Colorful Shapes')

    # setup screen size
    turtle.setup(800, 800, 0, 0)

    # draw a triangle
    turtle.pensize(3)
    turtle.penup()
    turtle.goto(-200, -50)
    turtle.pendown()
    turtle.begin_fill()
    turtle.color('red')
    turtle.circle(40, steps=3)
    turtle.end_fill()

    # draw a square
    turtle.penup()
    turtle.goto(-100, -50)
    turtle.pendown()
    turtle.begin_fill()
    turtle.color('navy')
    turtle.circle(40, steps=4)
    turtle.end_fill()

    # draw a pentagon
    turtle.penup()
    turtle.goto(0, -50)
    turtle.pendown()
    turtle.begin_fill()
    turtle.color('green')
    turtle.circle(40, steps=5)
    turtle.end_fill()

    # draw a hexagon
    turtle.penup()
    turtle.goto(100, -50)
    turtle.pendown()
    turtle.begin_fill()
    turtle.color('yellow')
    turtle.circle(40, steps=6)
    turtle.end_fill()

    # draw a circle
    turtle.penup()
    turtle.goto(200, -50)
    turtle.pendown()
    turtle.begin_fill()
    turtle.color('purple')
    turtle.circle(40)
    turtle.end_fill()

    # write header
    turtle.penup()
    turtle.goto(-100, 50)
    turtle.write('Cool Colorful Shapes', font=('Times', 18, 'bold'))

    # hide turtle
    turtle.hideturtle()

    # persist drawing
    turtle.done()
示例#52
0
import turtle

## 전역 변수 선언 부분 ##
num = 0 
swidth, sheight = 1000, 300
curX, curY = 0, 0

## 메인 코드 부분 ##
if __name__ == "__main__" :
    turtle.title('거북이로 2진수 표현하기')
    turtle.shape('turtle')
    turtle.setup(width = swidth + 50, height = sheight + 50)
    turtle.screensize(swidth, sheight)
    turtle.penup()
    turtle.left(90)

    num=int(input("숫자를 입력하세요 : "))    
    binary = bin(num)
    curX = swidth / 2
    curY = 0
    for  i  in  range(len(binary) - 2) :
        turtle.goto( curX, curY )
        if num & 1 :
            turtle.color('red')
            turtle.turtlesize(2)
        else :
            turtle.color('blue')
            turtle.turtlesize(1)
        turtle.stamp()
        curX -= 50
        num >>= 1
示例#53
0
文件: sudoku.py 项目: uc01001/sudoku
import turtle
import random


turtle.title('Python Turtle Sudoku')
# --------------- Made this function to set our coordinates and environment whenever we play ------------- #
def setWorld():
    turtle.setworldcoordinates(-200, -200, 200, 200)
    turtle.hideturtle()
    turtle.pensize(5)
    turtle.speed(0)
    turtle.pu()
    turtle.goto(-180, -180)


# ------------ A function to draw the outer large square ------------- #
def drawGrid():
    for i in range(2):
        turtle.fd(360)
        turtle.lt(90)
        turtle.fd(360)
        turtle.lt(90)


# ------------ A function to draw squares within the grid ---------#
def drawSquare():
    for i in range(2):
        turtle.fd(40)
        turtle.lt(90)
        turtle.fd(40)
        turtle.lt(90)
示例#54
0
def _tscheme_prep():
    global _turtle_screen_on
    if not _turtle_screen_on:
        _turtle_screen_on = True
        turtle.title("Scheme Turtles")
        turtle.mode('logo')
示例#55
0
def do_simulation(x, y, num, INUM, sdrate): # 시뮬레이션 시작
    global cnt
    global case_code
    global distance
    global S
    global I
    global R
    global x_input
    global t_input
    global beta
    global pos

    if cnt == 0:
        distance = [0]*num
        pos = [0]*num
        case_code = [0]*num
        S = 0
        I = 0
        R = 0
        x_input = [0]*3
    
    S, I, R = countSIR(num, case_code)

    x_input[0] = S
    x_input[1] = I
    x_input[2] = R
    t_input = cnt
    plot_(x_input, t_input, beta, 1/14, num, sdrate)

    t.title(f'확산된지 {cnt}일 후 | 전체 = {num} | S = {S} | I = {I} | R = {R} | 사회적 거리두기 비율 = {sdrate}')
    
    if (I == 0 and S !=0 and R !=0) or R == num: # 시뮬레이션 종료
        t.exitonclick()
        print(f'감염병이 종식되기까지 총 {cnt}일이 소요되었습니다.')
        return
    
    t.setup(width = 800, height = 800)
    t.ht()
    t.penup()
    t.speed(0)

    for i in range(num):
        if i+1 == INUM:
            if case_code[INUM-1] != 2:
                case_code[INUM-1] = 1
            else:
                case_code[INUM-1] = 2
        t.goto(x[f'cx{i+1}'], y[f'cy{i+1}']) # 최초 감염자 외의 위치

        if case_code[i] == 0:
            t.dot(20,'blue')
            pos[i] = t.position()
        elif case_code[i] == 1:
            t.dot(20,'red')
            pos[i] = t.position()
        elif case_code[i] == 2:
            t.dot(20, 'green')
            pos[i] = t.position()

    if cnt >= 1:
        case_code, beta = activation_infect(x, y, num, distance, pos, case_code)
        case_code = activation_recover(x, y, num, case_code)

    t.clear()
    cnt = cnt + 1
    moving(x, y, num, INUM, sdrate)
示例#56
0
# Here we intend to create a simple different star which have two colors.

# It should use the turtle module
import turtle

# Let's give it a name.
star = turtle.Turtle()

# We'll use this to exitonclick().
window = turtle.Screen()

# A random  name.
turtle.title("A pointless star")

# Set a dark color for the background.
turtle.bgcolor("#2c3e50")

# Define the number of iterations
n = 100

# Define how much turtle walks forward
size = 90

# Set the fastest speed
star.speed(0)


# The main function
def drawStar(n, size):

    for i in range(n):
    height = random.randrange(50, 300)

    # 그리기 시작 위치 계산
    sx1 = rand_x - width / 2
    sy1 = rand_y - height / 2

    # 자리 초기화
    myTurtle.penup()  # 펜 떼고 이동만
    myTurtle.goto(sx1, sy1)

    # 좌변
    sy2 = sy1 + height
    myTurtle.pendown()  # 그리면서 이동
    myTurtle.goto(sx1, sy2)

    # 상변
    sx2 = sx1 + width
    myTurtle.goto(sx2, sy2)

    # 우변
    myTurtle.goto(sx2, sy1)

    # 하변
    myTurtle.goto(sx1, sy1)


myTurtle = turtle.Turtle('turtle')
turtle.title('거북이로 그림을 그려요.')
turtle.onscreenclick(leftClick, 1)
turtle.done()
示例#58
0
import turtle, random, time

turtle.title('The Turtle Experiment')
turtle.shape('turtle')
turtle.color('white')
turtle.fillcolor('white')
turtle.bgcolor('skyblue')
turtle.pensize(2)
turtle.speed(100)
turtle.penup()


def cloud(cloudX, cloudY):
    turtle.goto(cloudX, cloudY)
    for i in range(0, 45):
        x = random.randint(cloudX - 100, cloudX + 100)
        y = random.randint(cloudY - 30, cloudY + 30)
        size = random.randint(20, 90)
        turtle.goto(x, y)
        turtle.dot(size)


def populateClouds(number):
    for i in range(0, number):
        x = random.randint(-700, 700)
        y = random.randint(-200, 600)
        cloud(x, y)


populateClouds(20)
    value = input("Please provide an angle: ")
    while not value.isnumeric():
        print("The input must be integer...")
        value = input("Please provide an angle: ")
    return int(value)


def generate_random_color():
    r = randint(0, 255)
    g = randint(0, 255)
    b = randint(0, 255)
    return r, g, b


print("Setup Screen")
turtle.title("Colorful patterns")
turtle.setup(640, 600)
turtle.hideturtle()
turtle.bgcolor('black')
turtle.colormode(255)
turtle.speed(10)

angle = get_input_angle()

print("Start the drawing")

for i in range(0, 200):
    turtle.color(generate_random_color())
    turtle.forward(i)
    turtle.right(angle)
示例#60
0
'''
Using turtle to draw regular polygons
prompt user for the number of sides and the color components (r, g, b).
'''
import turtle

# Get the turtle ready in position
turtle.hideturtle()
turtle.up()
turtle.goto(-50, 5)
turtle.shape('turtle')
turtle.title('Labe 02 -- 2017')

# Ask the user for the number of poly's sides
sides = int(turtle.textinput("Lab 02", "The number of sides: "))

# User will input RGB values [0.0 - 1.0]
r = float(turtle.textinput("Lab 02", "Value of red [0.0 - 1.0]"))
g = float(turtle.textinput("Lab 02", "Value of green [0.0 - 1.0]"))
b = float(turtle.textinput("Lab 02", "Value of blue [0.0 - 1.0]"))

turtle.color(r, g, b)  # Assign the user specified color to turtle

deg = 360 / sides  # Calculate the turn
length = 400 / sides
turtle.showturtle()
turtle.down()
for i in range(sides):
    turtle.forward(length)  # By using loop, turn and
    turtle.left(deg)  # Move the turtle forward
turtle.up()