Monday, June 17, 2013

Learning Python - The Hard Way

I am learning Python once a week at LA Makerspace. I am finally understanding how to code by using learnpythonthehardway.com. Here is my program for tonight:

 
from sys import argv

script, user_name = argv
prompt = '> '

print "Hi %s, I'm the %s script." % (user_name, script)
print "I'd like to ask you a few questions."
print "Do you love me %s?" % user_name
likes = raw_input(prompt)

print "Do you like that I'm learning Python, %s?" % user_name
python = raw_input(prompt)

print "What kind of computer do you have?"
computer = raw_input(prompt)

print """Alright, so you said %r about loving me. That's good because I love you too :)You said %r to liking that I learn Python. I like learning with you.And you have a %r computer. Nice. Can I play with it?""" % (likes, python, computer)

and this is Lucas' interaction with the program:
Hi Lucas, I'm the ex14.py script.
I'd like to ask you a few questions.
Do you love me Lucas?
> biensur
Do you like that I'm learning Python, Lucas?
> oui, beaucoup
What kind of computer do you have?
> big slow one that my baby makes fun of

Alright, so you said 'biensur' about loving me. That's good because I love you too :)
You said 'oui, beaucoup' to liking that I learn Python. I like learning with you.
And you have a 'big slow one that my baby makes fun of' computer. Nice. Can I play with it?