嗨嘿嗨,我又回来啦同志们!!!!!!!!!!!!!!!!!!!!

今天我们又要回到Python的世界里啦!

我隆重的退出新的Python游戏——《节日大问答!!!》

好了我们废话不多说,上代码!!!

import random
festival = ["元旦","腊八节","元宵节","妇女节",
            "植树节","愚人节","清明节","劳动节",
            "母亲节","儿童节","端午节","父亲节",
            "建党节","建军节","七夕节","教师节",
            "中秋节","国庆节","重阳节","感恩节",
            "冬至","圣诞节"]
month = [1,1,2,3,3,4,4,5,5,6,6,6,7,8,8,9,9,10,10,11,12,12]
day = [1,20,26,8,12,1,4,1,9,1,14,20,1,1,14,10,21,1,14,25,21,25]
score = 50
print('''
-------节日知识问答-----

       初始得分50分
     
       答对一题+10分
     
       答错一题-10分
     
      如果不答也算错误
     
     得100分则闯关成功!
     
--------准备开始啦-------
''')
while True:
    f = random.choice(festival)
    print("节日:",f)
    ans = print("请问今年该节日的日期是几月几日?")
    i = festival.index(f)
    m = int(input("请输入月份:"))
    d = int(input("请输入日期:"))
    if m == month[i] and d == day[i]:
        print("答对啦!")
        score += 10
        print("您的分数为:",score)
        print()
    else:
        print("答错啦!")
        score -= 10
        print("您的分数为:",score)
        print()
    
    if score == 100:
        print("恭喜闯关成功获得100分!")
        break
    if score < 0:
        print("很遗憾您闯关失败!再接再励!")
        break

嗯现在我们这次的游戏就分享到这里,拜拜!!!
(顺便题一句这次的代码比较短,因为我时间不够)

本站作者已申明原创,禁止转载!

文章内容属作者个人观点,不代表本站立场,如有侵权立删。

   口袋儿题库-青少儿编程自测题库