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 September 26th, 2012, 06:47 AM
IrvinK IrvinK is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 2 IrvinK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 34 m 47 sec
Reputation Power: 0
Python programming - turtleworld

Hello.. im a beginner at python

I want to draw a sierpenski triangle with depth 5.

Can someone help me please? So far ive drawed a triangle..

I know i have to use recursive loops but i find this hard to understand .. my idea was to start with the little trinangle and go out to bigger triangles and so on.

so far ive have made:


from swampy.TurtleWorld import *

angle = 60
def triangle(t, length, n):
for i in range(3):
fd(t, length)
lt(t, 180/n)
lt(t, 180/n)

def depth(n):
if n == 0:
return
else:
triangle()
depth(n-1)


world = TurtleWorld()
bob = Turtle()
bob.delay = 0.1
triangle(bob, 10, 60)



wait_for_user()

Reply With Quote
  #2  
Old September 26th, 2012, 10:34 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,460 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 4 Days 6 h 56 m 42 sec
Reputation Power: 403
1) Use the turtle module supplied with python rather than some custom thing few people have.

2) I can find examples of Sierpinski triangle turtle programs in python (except that it doesn't matter since the logo calls to turtle should be easily similar) on the internet. So can you.

3) Recursive algorithms can be expressed without recursion. Your statement that you need recursion is false.

4) Your triangle function needs 3 arguments yet you try to call it without arguments in your function depth.

Good luck.
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Python programming - turtleworld

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