欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python實(shí)現(xiàn)的簡(jiǎn)單文本類游戲?qū)嵗?/h1>
 更新時(shí)間:2015年04月28日 15:01:48   作者:feiwen  
這篇文章主要介紹了python實(shí)現(xiàn)的簡(jiǎn)單文本類游戲,以兩個(gè)實(shí)例形式分析了python操作文本與字符串的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了python實(shí)現(xiàn)的簡(jiǎn)單文本類游戲?qū)崿F(xiàn)方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

############################################################
# - 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? 1 or 2')
    option = input('user:> ')
  return option
def checkOption(chosenOption):
  print('\nintialising download....')
  time.sleep(1)
  print('accessing file....')
  time.sleep(1)
  print('downloading....')
  time.sleep(1)
  print('....')
  time.sleep(1)
  print('....')
  time.sleep(1)
  goodfile = random.randint(1, 2)
  if chosenOption == str(goodfile):
    print('\ndownload complete.')
    print('\nGAME OVER')
  else:
    print('\nfile corrupt')
    print('system infected.')
    print('\nGAME OVER')
playAgain = 'yes'
while playAgain == 'yes':
  displayIntro()
  optionNumber = chooseOption()
  checkOption(optionNumber)
  print('\ndownload again? .... (yes or no)')
  playAgain = input('user:> ')
############################################################
# - 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)

希望本文所述對(duì)大家的Python程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • Python練習(xí)之ORM框架

    Python練習(xí)之ORM框架

    這篇文章主要介紹了Python練習(xí)之ORM框架,通過使用SQLObject框架操作MySQL數(shù)據(jù)庫(kù)展開文章主題詳細(xì)內(nèi)容,具有一定的參考價(jià)值,需要的朋友可以參考一下
    2022-06-06
  • python中協(xié)程實(shí)現(xiàn)TCP連接的實(shí)例分析

    python中協(xié)程實(shí)現(xiàn)TCP連接的實(shí)例分析

    在本篇文章中我們給大家分享了python中協(xié)程實(shí)現(xiàn)TCP連接的代碼示例內(nèi)容,有需要的朋友們可以跟著學(xué)習(xí)下。
    2018-10-10
  • python實(shí)現(xiàn)坦克大戰(zhàn)

    python實(shí)現(xiàn)坦克大戰(zhàn)

    這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)坦克大戰(zhàn),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-04-04
  • Pycharm Plugins加載失敗問題解決方案

    Pycharm Plugins加載失敗問題解決方案

    這篇文章主要介紹了Pycharm Plugins加載失敗問題解決方案,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-11-11
  • 使用Python腳本來控制Windows Azure的簡(jiǎn)單教程

    使用Python腳本來控制Windows Azure的簡(jiǎn)單教程

    這篇文章主要介紹了使用Python腳本來控制Windows Azure的簡(jiǎn)單教程,由于微軟官方提供了Python SDK,使得用戶自己用Python控制Azure成為了可能,需要的朋友可以參考下
    2015-04-04
  • Python標(biāo)準(zhǔn)庫(kù)內(nèi)置函數(shù)complex介紹

    Python標(biāo)準(zhǔn)庫(kù)內(nèi)置函數(shù)complex介紹

    這篇文章主要介紹了Python標(biāo)準(zhǔn)庫(kù)內(nèi)置函數(shù)complex介紹,本文先是講解了complex的作用和使用注意,然后給出了使用示例,需要的朋友可以參考下
    2014-11-11
  • Python如何使用turtle庫(kù)繪制圖形

    Python如何使用turtle庫(kù)繪制圖形

    這篇文章主要介紹了Python如何使用turtle庫(kù)繪制圖形,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-02-02
  • YOLOv5中SPP/SPPF結(jié)構(gòu)源碼詳析(內(nèi)含注釋分析)

    YOLOv5中SPP/SPPF結(jié)構(gòu)源碼詳析(內(nèi)含注釋分析)

    其實(shí)關(guān)于YOLOv5的網(wǎng)絡(luò)結(jié)構(gòu)其實(shí)網(wǎng)上相關(guān)的講解已經(jīng)有很多了,但是覺著還是有必要再給大家介紹下,下面這篇文章主要給大家介紹了關(guān)于YOLOv5中SPP/SPPF結(jié)構(gòu)源碼的相關(guān)資料,需要的朋友可以參考下
    2022-05-05
  • Python編程技巧連接列表的八種操作方法

    Python編程技巧連接列表的八種操作方法

    這篇文章主要為大家介紹了Python編程技巧之連接列表的八種操作方法,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步
    2021-10-10
  • python求加權(quán)平均值的實(shí)例(附純python寫法)

    python求加權(quán)平均值的實(shí)例(附純python寫法)

    今天小編就為大家分享一篇python求加權(quán)平均值的實(shí)例(附純python寫法),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-08-08

最新評(píng)論