您的位置:首页 > 编程语言 > Python开发

《笨办法学python》加分习题14——我的答案

2017-08-14 22:16 411 查看
这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!

文中例题:

代码:

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 like me %s?" % user_name
likes = raw_input(prompt)

print "Where do you live %s?" % user_name
lives = raw_input(prompt)

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

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)


运行结果:



加分习题:

1、查到Zork是一款文字类的游戏,而Adventure我没有查到,有机会会玩一下的。

2、
prompt = '--- '


运行结果:



3、代码:

from sys import argv

script, user_name, user_appearance = argv
prompt = '--- '

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

print "Where do you live %s %s?" % (user_appearance, user_name)
lives = raw_input(prompt)

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

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)


运行结果:



4、嗯!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: