[python-advocacy] How programming language webpages should be designed

Ray Allen rayallen153 at googlemail.com
Thu Nov 12 15:39:59 CET 2009


 I'd like

> > to see it possible to execute the code too.
>
> http://codepad.org/eRDY42Lj
>

***Hopefully, we'd be able to allow interactive execution thereby allowing
the user to guess ouptut first and witness the shuffle function in action.
I lvery much like the interactive shell used for the tutorial on the ruby
site.

A dict would be nice too,  but I don't want so much in one snippit
> that it becomes hard to follow.
>
> I like that your code has some marketing embedded in it.
>

***Thanks. The code as it stands is simple to follow, but it includes quite
a few concepts: the use of a standard library funciton; list creation; list
method; iteration; strings; integer; print output.    In hindsight, I guess
it would remain simple and readable if we added a bit more flow control
(such as an if statement) but I'm not sure about dictionaires or classes.
These are soon discovered in the tutorial/documentation and are probably
best avoided if this is just intended to give a taster.

"""Example Python Program"""

import random

# Create and add to a list
python = []
python.append("Easy to read")
python.append("Fast to code")
python.append("Quick to learn")
python.append("Modular and object oriented")
python.append("Open source and cross platform")

# Shuffle list
random.shuffle(python)

# Loop through list
count = 1
print "Python is ... "
for each in python:
    print count,each
    count += 1

print "Discover more at http://www.python.org"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/advocacy/attachments/20091112/57392e08/attachment.htm>


More information about the Advocacy mailing list