黑松山资源网 Design By www.paidiu.com
本文实例讲述了python实现的简单文本类游戏实现方法。分享给大家供大家参考。具体实现方法如下:
############################################################ # - My version on the game "Dragon Realm". # - taken from the book "invent with python" by Al Sweigart. # - thanks for a great book Mr Sweigart. # - this code takes advantage of python 3. ############################################################ #files.py import random import time print('\n\n[--system--] one file is bad the other is good ..guess the right one.\n') print('\n\nconnecting....') time.sleep(1) print('....') time.sleep(1) print('....') time.sleep(1) print('....') time.sleep(1) print('\nconnection established') def displayIntro(): print('------------') print('SYSTEM FILES') print('------------\n') print('1.) file.') print('2.) file.\n') def chooseOption(): option = '' while option != '1' and option != '2': print('which file to download"htmlcode">############################################################ # - My version of the game "guess the number". # - taken from the book "invent with python" by Al Sweigart. # - thanks for a great book Mr Sweigart. # - this code takes advantage of python 3. ############################################################ # -NOTE - this program will crash if a number is not typed. #digitcode.py import random import time guessesTaken = 0 print('\n\n\n\n\n[--system--] enter code in 15 trys to avoid lockout\n') print('\nconnecting....') time.sleep(1) print('....') time.sleep(1) print('....') time.sleep(1) print('....') time.sleep(1) print('connection established\n') print('---------------------') print(' MAINFRAME - LOGIN ') print('---------------------') print('\nenter 3 digit access code..') number = random.randint(000, 999) while guessesTaken < 15: print() guess = input('user:> ') guess = int(guess) guessesTaken = guessesTaken + 1 if guess < number: print('\nACCESS - DENIED -code to low') if guess > number: print('\nACCESS - DENIED -code to high') if guess == number: break if guess == number: guessesTaken = str(guessesTaken) print('\nverifying ....') time.sleep(1) print('\nauthenticating ....') time.sleep(1) print('....') time.sleep(1) print('....') time.sleep(1) print('\nACCESS - GRANTED') print('\nGAME OVER\n') exit(0) if guess != number: number = str(number) print('\n....') time.sleep(1) print('\n....') time.sleep(1) print('\nSYSTEM LOCKED -the code was ' + number) print() exit(0)希望本文所述对大家的Python程序设计有所帮助。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
更新日志
2024年10月09日
2024年10月09日
- 《原神》「星路拾忆」网页活动壁纸展示
- 群星.2024-祝你幸福!电影原声带【阿里巴巴】【FLAC分轨】
- 于台烟.2004-执着【乾坤唱片】【WAV+CUE】
- 黄品源.2004-感谢·情人(引进版)【滚石】【WAV+CUE】
- 《最终幻想16》评测:游、戏两难全的系列转折
- 《纸嫁衣》五部打包¥104,《鬼泣5》仅需¥44
- 《崩坏:星穹铁道》造物大赛卷出新高度
- 《王菲 菲常传奇 2CD》[WAV+CUE][950MB]
- 《王菲 空灵独味唱腔 非常传奇 紫水晶2CD》[WAV+CUE][860MB]
- 《车载专业测试王1号 极品音质》[WAV/分轨][980MB]
- 炉石传说的国服回归送什么奖励 炉石传说9.25回归最新消息介绍
- 云顶之弈最强阵容汇总2024 云顶之弈最强阵容搭配最新版本
- S14lol全球总决赛在哪观看 lol全球总决赛观赛直播地址汇总
- 黄思婷2011-感谢天[豪记唱片][WAV+CUE]
- 孙淑媚2013-太阳[台湾首版][WAV+CUE]