笔记26 笨办法习题36 设计与调试

笔记26 笨办法习题36 设计与调试

因为写校园回忆,把python学习给停了一段时间,今天回归,开练练习36。计划先用文字勾勒一个设想,然后给出一个路线图,在此基础上再做代码。
没有想到自己来设计一个游戏还真有难度,不依照ex35的方式来做一个代码,在atom上折腾了几天依然是遇到很多难解决的难题,完全做不出来。从ex36一直做到ex36.6还没有一个是成功的。最后做到没有错误指出的时候,在ps上依然执行不了,给出的只是无可执行的文件名,虽然什么错误也没有。好在这个过程中学会了识别几种错误,例如语法错误,例如,缩进的错误,但是改正了这些错误的结果,却依然没有弄成一个可执行的代码。
看来只有模仿ex35了,现在正在做的就是对于ex35的模仿。也许会成功吧,模仿总比原创要容易得多,有样本可以参考。弄了一整天,终于搞出个ex36.7.py,感到不太满意,但竟然可以运行,但运行到后面的无计可施地步的时候,不知道如何回到ps了。先把这个习作记录下来,继续前行吧。
总的思路是一次考试,成绩很好就可进入大学,成绩很糟,因为犯有大错,进监狱。进监狱后想逃跑,如果逃脱就有了点自由,如果逃不脱就只有升天了。但设计过程找不到好的图形表达,只有依据ex35的思路来做这个代码了。竟然可以运行,这是没有预料到的。因为还只是在python很低层的认知状态。
练习ex36.7.py

在这里插入代码片from sys import exit  #model ex35,
testcent = ["very good", "good", "bad", "too bad"]

def university():
    print("There are many talents in the university who is into it with high cent,you are:")

    testcent = input("> ")
    if "very good" in testcent or "too bad" in testcent:
        figures = (testcent)
    else:
        dead("Man, you are kick out!")

    if "very good" in testcent:
        print("you maybe have a good luck!")
        exit(0)
    else:
        dead("Man. your luck is too bad!")

def prison():
    print("That is a terrible place!")
    print("You will live a place of no free, how poorly!")
    print("you must make a great mistake.")
    print("How are you  going to escape from the prison?")
    no_guard = False

    while True:
        testcent = input("> ")

        if testcent == "escape" :
            dead("The guarder will shot you, but it is fail.")
        elif testcent == "arrested" and not no_guard:
            print("You did't escape.")
            print("You was sent back to the prison. ")
            no_guard = True
        elif testcent == "arressted" or no_guard:
            dead("You become a prison, badly!")
        else:
            print("no way to do anything!")

def start():
    print("You want to go into an university.")
    print("This needs you have 600 cents in test.")
    print("How many cents do you have?")

    testcent = input("> ")

    if testcent == "very good":
        university()
    elif testcent == "too bad":
        prison()
    else:
        dead("you will die.")

start()

这个练习的ps运行结果在这里插入代码片PS C:\Users\lenovo\1pythonw> python ex36.7.py
You want to go into an university.
This needs you have 600 cents in test.
How many cents do you have?

too bad
That is a terrible place!
You will live a place of no free, how poorly!
are you going to escape?
How are you going to escape from the prison?
very good
no way to do anything!

no way to do anything!

现在的水平只能做到这样了,继续学习,提高水平。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值