Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## extra credit
- ##Change the prompt variable to something else entirely.
- ## Add another argument and use it in your script.
- from sys import argv
- script, user_name, no_questions = argv
- prompt = '> '
- print "Hi %s, I'm the %s script." % (user_name, script)
- print "I'd like to ask you a few questions."
- i=['like', 'live', 'comp']
- def ask(x):
- if x=='like':
- print "Do you like me %s?" % user_name
- likes = raw_input(prompt)
- elif x=='live':
- print "Where do you live %s ?" % user_name
- lives=raw_input(prompt)
- elif x=='comp':
- print "What kind of computer do you have?"
- computer = raw_input(prompt)
- b=int(no_questions)
- for j in range(0,b):
- x=i[j]
- ask(x)
- print "That's all, folks!"
- # print """
- # Alright, so you said %r about liking me.
- # You live in %r. Not sure where that is.
- # And you have a %r computer. Nice.
- # """ % (likes, lives, computer)
- #win python shell
- # >>> import sys
- # >>> sys.argv=['','Ha','2']
- # >>> execfile('ex14.py')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement