《笨办法学python》加分习题14——我的答案
2017-08-14 22:16
411 查看
这是我自己学习的答案,会尽力写的比较好。还望大家能够提出我的不足和错误,谢谢!
运行结果:
2、
运行结果:
3、代码:
运行结果:
4、嗯!
文中例题:
代码: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、嗯!
相关文章推荐
- 《笨办法学python》加分习题2——我的答案
- 《笨办法学python》加分习题16——我的答案
- 《笨办法学python》加分习题18——我的答案
- 《笨办法学python》加分习题25——我的答案
- 《笨办法学python》加分习题4——我的答案
- 《笨办法学python》加分习题31——我的答案
- 《笨办法学python》加分习题36——我的答案
- 《笨办法学python》加分习题5——我的答案
- 《笨办法学python》加分习题7——我的答案
- 《笨办法学python》加分习题8——我的答案
- 《笨办法学python》加分习题19——我的答案
- 《笨办法学python》加分习题9——我的答案
- 《笨办法学python》加分习题20——我的答案
- 《笨办法学python》加分习题30——我的答案
- 《笨办法学python》加分习题37——我的答案
- 《笨办法学python》加分习题11——我的答案
- 《笨办法学python》加分习题32——我的答案
- 《笨办法学python》加分习题35——我的答案
- 《笨办法学python》加分习题41——我的答案
- 《笨办法学python》加分习题10——我的答案