Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
December 9th, 2012, 05:33 PM
 Krilltuska
Registered User

Join Date: Dec 2012
Posts: 3
Time spent in forums: 1 h 33 m 38 sec
Reputation 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)

# 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_triangle()```

#2
December 10th, 2012, 08:04 AM
 b49P23TIvg
Contributing User

Join Date: Aug 2011
Posts: 4,163
Time spent in forums: 1 Month 3 Weeks 2 Days 9 h 27 m 53 sec
Reputation Power: 455
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!

#3
December 10th, 2012, 10:24 AM
 Krilltuska
Registered User

Join Date: Dec 2012
Posts: 3
Time spent in forums: 1 h 33 m 38 sec
Reputation 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

#4
December 10th, 2012, 10:32 AM
 b49P23TIvg
Contributing User

Join Date: Aug 2011
Posts: 4,163
Time spent in forums: 1 Month 3 Weeks 2 Days 9 h 27 m 53 sec
Reputation Power: 455
As I said, run your code in python2.

In python3 use

int(input('I return a string'))

#5
December 10th, 2012, 12:05 PM
 Krilltuska
Registered User

Join Date: Dec 2012
Posts: 3
Time spent in forums: 1 h 33 m 38 sec
Reputation Power: 0
Ah, thanks it finally worked! just had to put int(input
THanks again =)

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Need a little help on these codes :s