I am having trouble trying to finish a python turtle program. When I attempt to input x and y coordinates as well as a radius value for the function like
t.drawSnowman(x = 25,y = 25,radius = 25) the program misbehaves when I input values.but if I leave out the parameters above and instead just use t.drawSnowman() the program works as intended but I am not able to create various instances of the snowman.
I would really like help trying to figure out how to input the parameters and still have the program function.
here's my code
import turtle
class MyTurtle(turtle.Turtle):
""""""
def __init__(self):
"""Turtle Constructor"""
turtle.Turtle.__init__(self, shape="turtle")
def drawNose(self, x=0, y=0, radius = 15, circle_color = "black"):
'''draw nose '''
self.pendown()
self.goto(-(radius) * (0.25),(radius * 6)+(radius * 4)+(radius))
self.goto(0,(radius * 6)+(radius * 4)+(radius)+(radius * (0.25)))
self.goto((radius) * (0.25),(radius * 6)+(radius * 4)+(radius))
self.goto(0,(radius * 6)+(radius * 4)+(radius))
self.penup()
def leftEye(self, x=0, y=0, radius = 15, circle_color = "black"):
'''draw left eye'''
self.pendown()
self.circle(radius*(.25))
self.penup()
def rightEye(self, x=0, y=0, radius = 15, circle_color = "black"):
'''draw right eye'''
self.pendown()
self.circle(radius*(.25))
self.penup()
def bottomOfHat(self, x=0, y=0, radius = 15, circle_color = "black"):
''' draw the long part of the hat at the bottom '''
self.goto(0,(radius * 6)+(radius * 4)+(radius * 2))
self.pendown()
self.goto(-(radius),(radius * 6)+(radius * 4)+(radius * 2))
self.goto(-(radius),(radius * 6)+(radius * 4)+(radius * 2)+(radius * (0.5)))
self.goto(radius,(radius * 6)+(radius * 4)+(radius * 2)+(radius * (0.5)))
self.goto(radius,(radius * 6)+(radius * 4)+(radius * 2))
self.goto(0,(radius * 6)+(radius * 4)+(radius * 2))
self.penup()
def topOfHat(self, x=0, y=0, radius = 15, circle_color = "black"):
'''draw the top bigger part of the hat'''
self.goto(radius*(.75),(radius * 6)+(radius * 4)+(radius * 2)+(radius * (0.5)))
self.pendown()
self.goto(radius*(.75),(radius * 6)+(radius * 4)+(radius * 2)+(radius * 2))
self.goto(-(radius)*(.75),(radius * 6)+(radius * 4)+(radius * 2)+(radius * 2))
self.goto(-(radius)*(.75),(radius * 6)+(radius * 4)+(radius * 2)+(radius * (0.5)))
def bottomCircle(self, x=0, y=0, radius = 15, circle_color = "black"):
'''draws the bottom circle'''
self.pendown()
self.circle(radius * 3)
self.penup()
def middleCircle(self, x=0, y=0, radius = 15, circle_color = "black"):
'''draw the middle circle'''
self.pendown()
self.circle(radius * 2)
self.penup()
def topCircle(self, x=0, y=0, radius = 15, circle_color = "black"):
'''draw the top circle'''
self.pendown()
self.circle(radius)
self.penup()
def drawSnowman(self, x=0, y=0, radius = 15, circle_color = "black"):
self.bottomCircle()
self.goto(0,radius * 6)
self.middleCircle()
self.goto(0,(radius * 6)+(radius * 4))
self.topCircle()
self.goto(-(radius) * (0.5),(radius * 6)+(radius * 4)+(radius))
self.leftEye()
self.goto((radius) * (0.5),(radius * 6)+(radius * 4)+(radius))
self.rightEye()
self.goto(0,(radius * 6)+(radius * 4)+(radius))
self.drawNose()
self.bottomOfHat()
self.topOfHat()
t = MyTurtle()
t.hideturtle()
radius = 15
t.drawSnowman(x = 25,y = 25,radius = 25)
this is a picture of the snowman when I use the parameters
t.drawsnowman(x = 25 y=25 radius = 25)
this is the snowman when I inuput no parameters t.drawsnowman()