#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Need a little help on these codes :s


    I need someone to check these codes. I already checked it myself and have done as much as i could but there are some errors but i don't know where to look at since i am fairly new to python . thanks

    Code:
    from turtle import *
    
    shape_height = input("Enter a height integer: ")
    shape_width = input("Enter a width integer: ")
    start_x = input("Enter an X coordinate: ")
    start_y = input("Enter a Y coordinate: ")
    pen_width = input("Enter a pen width: ")
    
    
    def draw_circle():
        # This function draws a circle
        color("red")
        width(pen_width + 3)
        penup()
        goto(start_x, start_y)
        pendown()
        circle(shape_height)
    
    def draw_quad():
        # This function draws a quad
        color("blue")
        width(pen_width)
        penup()
        goto(start_x - 140, start_y + 150)
        pendown()
        forwrd(shape_height)
        right(90)
        forward(shape_width)
        right(90)
        forward(shape_height)
        right(90)
        forward(shape_width)
        right(90)
    
    def draw_triangle():
        # This function draws a trianlge
        color("green")
        width(pen_width + 2)
        penup()
        goto(start_x + 100, start_y - 120)
        pendown()
        right(180)
        circle(shape_width, steps=3)
    
    draw_circle()
    draw_quad()
    draw_triangle()
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    Correct the spelling of forwrd in draw_quad
    run the program in python 2
    review the turtle graphics documents looking for a way to keep the window open to see the pretty picture.

    Otherwise please explain the problem you observe.
    Dave.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0
    already fixed the forward mispelling but still having these errors:

    Traceback (most recent call last):
    File "D:/Joko's folder/New Folder/Computer science/section_3/test.py", line 47, in <module>
    draw_circle()
    File "D:/Joko's folder/New Folder/Computer science/section_3/test.py", line 15, in draw_circle
    width(pen_width + 3)
    TypeError: Can't convert 'int' object to str implicitly

    ps. im running on python 3.2
    also, input these values to make sure you can see the whole image
    Height integer: 45
    Width integer: 60
    X coordinate: 20
    Y coordinate: 30
    Pen width: 4
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,997
    Rep Power
    481
    As I said, run your code in python2.

    In python3 use

    int(input('I return a string'))
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0
    Ah, thanks it finally worked! just had to put int(input
    THanks again =)

IMN logo majestic logo threadwatch logo seochat tools logo