自己写的第一本Linux教程,也小小的班门弄斧一下

        对于web开发人员来说,最熟悉的操作系统可能就是Linux了,虽然经常使用windows操作系统来做开发,但是对Linux的热爱与欣赏则是发自内心的一股力量,当然,我也是Linux的一个狂热爱好者。

        其实早在2015年的年初就开始写这本教程了,但是一直由于各种原因被耽搁,导致迟迟没有发布出来,直到今天偶然看到了它,才决定发布出来。


       下面是下载地址:

       首先是在百度网盘的下载地址:百度网盘超链接

        然后是在新浪微盘的下载地址: 点击去新浪微盘 

   最后就是在csdn上的下载地址:点击在csdn下载

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
本游戏设定为随机抽取一个成语,并在其中随机一个字加下划线,要求玩家填入正确的成语,如果填正确则加分,否则扣分。游戏共设有3个难度级别:简单、中等和困难,分别对应加分和扣分的不同数值。游戏结束后,如果分数排名前5名,则可将玩家分数添加到游戏榜单中。 以下是游戏代码: ```python import random # 成语列表,可自行添加更多成语 idioms = ['画蛇添足', '井底之蛙', '守株待兔', '杀鸡焉用牛刀', '班门弄斧', '对牛弹琴', '半途而废', '海底捞针', '卧薪尝胆', '画龙点睛'] # 定义游戏难度级别 difficulty_levels = { 'easy': {'score_increment': 1, 'score_decrement': 1, 'num_questions': 5}, 'medium': {'score_increment': 2, 'score_decrement': 2, 'num_questions': 10}, 'hard': {'score_increment': 3, 'score_decrement': 3, 'num_questions': 15} } # 游戏榜单,最多存储5个玩家分数 high_scores = [] # 随机抽取一个成语,并在其中随机一个字加下划线 def generate_question(): idiom = random.choice(idioms) index = random.randint(0, len(idiom)-1) question = idiom[:index] + '_' + idiom[index+1:] answer = idiom return question, answer # 在控制台中显示游戏界面 def show_game_interface(question, score): print('当前得分:', score) print('请填下面的成语:') print(question) # 计算并显示游戏结果 def show_game_result(score): print('游戏结束!你的分数是:', score) if score < 0: print('挑战失败!') else: print('恭喜你获得了胜利!') if len(high_scores) < 5 or score > high_scores[-1]['score']: name = input('请输入你的名字:') high_scores.append({'name': name, 'score': score}) high_scores.sort(key=lambda x: x['score'], reverse=True) if len(high_scores) > 5: high_scores.pop() # 开始游戏 def start_game(difficulty): score_increment = difficulty_levels[difficulty]['score_increment'] score_decrement = difficulty_levels[difficulty]['score_decrement'] num_questions = difficulty_levels[difficulty]['num_questions'] score = 0 for i in range(num_questions): question, answer = generate_question() show_game_interface(question, score) user_answer = input('请输入你的答案:') if user_answer == answer: score += score_increment print('回答正确,得分+', score_increment) else: score -= score_decrement print('回答错误,扣分-', score_decrement, ',正确答案是', answer) show_game_result(score) # 显示游戏榜单 def show_high_scores(): if len(high_scores) == 0: print('暂无排行榜!') else: print('游戏排行榜:') for i, high_score in enumerate(high_scores): print(i+1, '.', high_score['name'], '-', high_score['score'], '分') # 选择游戏难度 def select_difficulty(): print('请选择游戏难度:') print('1. 简单') print('2. 中等') print('3. 困难') choice = input('请输入你的选择(1-3):') if choice == '1': start_game('easy') elif choice == '2': start_game('medium') elif choice == '3': start_game('hard') else: print('无效的选择!') # 显示游戏主菜单 def show_main_menu(): print('欢迎来到成语游戏!') print('1. 开始游戏') print('2. 显示排行榜') print('3. 退出游戏') choice = input('请输入你的选择(1-3):') if choice == '1': select_difficulty() elif choice == '2': show_high_scores() elif choice == '3': exit() else: print('无效的选择!') # 循环显示游戏主菜单 while True: show_main_menu() ``` 在游戏中,玩家可以通过输入数字来选择游戏难度。在游戏过程中,玩家需要填下划线后面的成语,并根据填的成语是否正确来获得或扣除分数。游戏结束后,玩家的分数将被添加到游戏榜单中,并根据分数排名进行排序。玩家可以选择在游戏主菜单中查看游戏榜单或退出游戏。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值