1、系统生成一个随机数1到5,然后让用户的猜测,若猜对了,提示恭喜你,猜对了,否则提示,对不起,你猜错了
(提示,1到5的随机数为:secret = random.randint(1, 5)),此行代码之前需先引入随机数模块import random
2、将以下乘法口诀表代码改为while循环
for i in range(1, 9+1): text = "" for j in range(1, i+1): text += "{}*{}={:2} ".format(i,j,i*j) print(text)
看到Successfully installed easygui字样的,表示easygui安装成功
import easygui as g g.msgbox("hello world!")
import easygui as g rel = g.ynbox("你喜欢红色吗?", "title") if rel: g.msgbox("你选择是") else: g.msgbox("你选择否")
import easygui as g msg = "输入你喜欢的颜色" title = "游戏互动" choices = ["红色", "绿色", "蓝色", "青色"] choice = g.choicebox(msg, title, choices) g.msgbox("你喜欢的颜色是: " + choice)
import easygui as g msg = "输入你喜欢的颜色" title = "游戏互动" choices = ["红色", "绿色", "蓝色", "青色"] choice = g.buttonbox(msg, title, choices) g.msgbox("你喜欢的颜色是: " + choice)
import easygui as g text = g.enterbox("请输入一句话", "title") g.msgbox(text)
原文:https://www.cnblogs.com/luhouxiang/p/11664722.html