猜年齡遊戲
1、給定年齡,使用者可以猜三次年齡
2、年齡猜對,讓使用者**兩次
3、使用者**兩次獎勵後可以退出
age = 20
count = 0
s_count = 3 # 定義最大迴圈次數
prize_list = ['布娃娃','鋼鐵俠','金箍棒','python趣味課']
while count < s_count :
age_inp = input('請輸入你猜測的年齡:')
if not age_inp.isdigit():
print('請輸入純數字')
continue
if age_inp == age :
print('猜對了,恭喜你獲得兩次**機會')
ans1 = input("放棄請輸入『n』或『n』。**請選擇0、1、2、3其中乙個數字輸入:")
if ans1 == 'n' or ans1 == 'n':
print('您已放棄,謝謝參與')
break
if ans1 in ['0','1','2','3']:
prize = prize_list[int(ans1)]
print(f'恭喜你獲得獎品:')
ans2 = input("還有一次**機會,放棄請輸入『n』或『n』。**請選擇0、1、2、3其中乙個數字輸入:")
if ans2 == 'n' or ans2 == 'n':
print('您已放棄,謝謝參與')
elif ans2 in ['0', '1', '2', '3']:
prize2 = prize_list[int(ans2)]
print(f'恭喜你獲得獎品: \n 遊戲結束,謝謝參與')
break
elif age_inp > age :
print('猜大了')
elif age_inp < age :
print('猜小了')
count += 1
if count < s_count :
choice = input("繼續玩兒嗎?繼續請輸入'y'或'y',不繼續請按任意鍵退出:")
if choice == 'y'or choice == 'y':
print('再來一次')
elif choice != 'y'or choice != 'y':
print('謝謝參與')
break
if count == s_count :
print('三次機會已經用完,謝謝參與')
break
python基礎 小遊戲簡單實現
給定年齡,使用者可以猜三次年齡 年齡猜對,讓使用者選擇兩次獎勵 使用者選擇兩次獎勵後可以退出 age 20 age count 0 while age count 3 age inp input 請輸入你猜測的年齡 if not age inp.isdigit print 請輸入你猜測的年齡的數字 ...
簡單掃雷小遊戲
game.h ifndef game h define game h include include include include define row 9 define col 9 define rows row 2 define cols col 2 define easy count 10 ...
Python製作簡單的滑雪小遊戲
python版本 3.6.4 pygame模組 以及一些python自帶的模組。安裝python並新增到環境變數,pip安裝需要的相關模組即可。遊戲規則 玩家通過 ad 鍵或者 操控前進中的滑雪者,努力避開路上的樹,盡量撿到路上的小旗。如果碰到樹,則得分減50,如果撿到小旗子,則得分加10。逐步實現...