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

来源:互联网 发布:澳大利亚国立大学知乎 编辑:程序博客网 时间:2024/05/22 22:19

这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!

文中例题:

代码:

from sys import argvscript, user_name = argvprompt = '> '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_namelikes = raw_input(prompt)print "Where do you live %s?" % user_namelives = 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 argvscript, user_name, user_appearance = argvprompt = '--- '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、嗯!

阅读全文
0 0