加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Guess_the_number_game.py 801 Bytes
一键复制 编辑 原始数据 按行查看 历史
# using codeSkulpter
import random
import simplegui
def new_game():
global num
print("new game starts")
def range_of_100():
global num
num = random.randrange(0, 100)
print("your range is 0-100")
def range_of_1000():
global num
num = random.randrange(0, 1000)
print("Your range is 0-1000")
def input_guess(guess):
global num
print("Your Guess is ", guess)
num1 = int(guess)
if num1 == num:
print("Correct")
elif num1 >= num:
print("Greater")
elif num1 <= num:
print("Lower")
frame = simplegui.create_frame("Guess The Number", 200, 200)
frame.add_button("range[0-1000)", range_of_1000)
frame.add_button("range[0-100)", range_of_100)
frame.add_input("enter your guess", input_guess, 200)
frame.start()
new_game()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化