tonybaldwin | blog

non compos mentis

assignments: python pizza py

leave a comment »

I’ve managed to gather some hacker tutors.
Real hackers (unlike myself, an aspirant and novice, by any real measure).

One gave the an assigment to make a program that generates 5 random numbers.
I did:

# Let’s make a pizza.
# escrito por anthony baldwin

from random import randint

print “I’m hungry!”
print “Let’s make a nice pizza, eh!”

ing = (“pepperoni”, “ham”, “onions”, “sausage”, “bacon”, “peppers”, “spiders”, “mozzarella”, “anchovies”, “chocolate chips”, “dog hairs”, “toe-nail clippings”, “fried clams”, “lollipops”, “paper clips”, “calamari”, “m&ms”, “broccoli”, “gum drops”, “green beans”)

print “Let’s make a pizza with”

for i in range(5):
p = randint(0,19)
print ing[p]

print ” ”
print “That’s a nice pizza, eh! ”
print “Mangeamos!”

Another told me to write a program with writes 5 lines
but not with 5 print statements, with a loop, so that it could be
extended to print up to 500 such lines by only changing the number.

I did:

# stars python
# escrito por anthony baldwin /

t = “*”
print “Twinkle, twinkle little stars.”

for i in range(5):
print t * (i+1)

print “Twinkle, twinkle…”


Written by tonybaldwin

February 27, 2008 at 12:34 pm

Posted in hacking

Tagged with , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: