Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #66981

Re: Functions help

Path csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=125eea375=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.065
X-Spam-Evidence '*H*': 0.87; '*S*': 0.00; 'turtle': 0.07; 'subject:help': 0.08; 'doing?': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'question.': 0.14; '23,': 0.16; 'angle': 0.16; 'inspiration': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'example': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'sorry,': 0.24; 'initial': 0.24; 'math': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'record': 0.27; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; 'forgot': 0.30; 'heading': 0.30; 'skip:g 30': 0.30; 'skip:( 20': 0.30; 'code': 0.31; 'about.': 0.31; "d'aprano": 0.31; 'long.': 0.31; 'steven': 0.31; '-----': 0.33; 'could': 0.34; 'add': 0.35; 'really': 0.36; 'thank': 0.38; 'anything': 0.39; 'does': 0.39; 'how': 0.40; 'you.': 0.62; 'back': 0.62; 'show': 0.63; 'information': 0.63; 'received:194': 0.64; 'talking': 0.65; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; '2014,': 0.84; 'it\xe2\x80\x99s': 0.84; 'i\xe2\x80\x99ll': 0.84; 'to:addr:cox.net': 0.84; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="4.97,535,1389740400"; d="scan'208";a="2490928"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Mon, 24 Feb 2014 16:01:38 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Scott W Dunning <swdunning@cox.net>
In-Reply-To <79B85A42-ABE1-4CC6-922B-A8AAAD26C80B@cox.net>
Subject Re: Functions help
MIME-Version 1.0
X-Mailer Zimbra 7.2.4_GA_2900 (ZimbraWebClient - GC7 (Linux)/7.2.4_GA_2900)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7309.1393254099.18130.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1393254099 news.xs4all.nl 2952 [2001:888:2000:d::a6]:51315
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66981

Show key headers only | View raw


----- Original Message ----- 

> On Feb 23, 2014, at 1:44 AM, Steven D'Aprano <
> steve+comp.lang.python@pearwood.info > wrote:
> > Sorry, I don't really understand your question. Could you show an
> > example
> 
> > of what you are doing?
> 

> > Do you mean "add 5" or "*5"? "Add *5 doesn't really mean anything
> > to
> > me.
> 
> Sorry I forgot to add the code that I had to give an example of what
> I was talking about. I’ll put it below, sorry that it’s so long. A

Here's an example of how your star() function could be rewritten.
Note that it does not exactly do what it does in your example regarding the start and end position of the turtle.
So use it for inspiration only ;)


from turtle import *
from math import sin, sqrt, radians

def star(width):
	R = (width)/(2*sin(radians(72)))
	A = (2*width)/(3+sqrt(5))
	# record the initial position
	position = getturtle().pos()
	heading =  getturtle().heading()
	penup()
	left(36) # initial angle
	forward(R)
	pendown()
	for arms in range(5):
		left(144)
		forward(A)
		right(72)
		forward(A)
	penup()
	# go back to the initial position
	getturtle().setpos(position)
	getturtle().setheading(heading)
   
showturtle()
clear()
star(50)


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Functions help Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-02-24 16:01 +0100

csiph-web