import random
secret = random.randint(1,10)
print('-------------------gclome-------------------')
temp = input("不妨輸入我現在心裏想的那個數字:")
guess= int(temp)
while guess != secret:
temp = input("哎呀,猜錯了,請重新輸入吧:")
guess= int(temp)
if guess==secret:
print("你是我的蛔蟲嗎哈哈哈哈")
print("哼,猜中了也沒有獎勵")
else:
if guess > secret:
print("大了大了")
else:
print("小了小了!")
print("遊戲結束,不玩啦!")
Python的條件分支語言
1、if else語句
If
Else
2、While循環
While 條件:
條件爲真(true)執行的操作
random模塊裏面有個函數叫做 randint(),會返回一個隨機的整數