Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 9th, 2012, 04:33 PM
Krilltuska Krilltuska is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 3 Krilltuska User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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)

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()

Reply With Quote
  #2  
Old December 10th, 2012, 07:04 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,383 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 44 m 42 sec
Reputation Power: 383
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!

Reply With Quote
  #3  
Old December 10th, 2012, 09:24 AM
Krilltuska Krilltuska is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 3 Krilltuska User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #4  
Old December 10th, 2012, 09:32 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,383 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 13 h 44 m 42 sec
Reputation Power: 383
As I said, run your code in python2.

In python3 use

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

Reply With Quote
  #5  
Old December 10th, 2012, 11:05 AM
Krilltuska Krilltuska is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 3 Krilltuska User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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 =)

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Need a little help on these codes :s

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap