import easygui as gui
age = 0
sex = gui.enterbox("tell me your sex:f or m")
if sex == 'f':
age = int(gui.enterbox("input your age:"))
if 10 <= age <= 12:
gui.msgbox("join us")
else:
gui.msgbox("i am so sorry")
else:
gui.msgbox("i am sorry,and we only need female")
7-3 加油站
import easygui as gui
tank = int(gui.enterbox("the tank container is :"))
percent = int(gui.enterbox("the percent of full is :"))
km = int(gui.enterbox("the km is :"))
distance = tank * percent / 100 * km
str2 = "size of tank :" + str(tank) + "\n" + "percent full" +str(percent) + "\n" + "km per liter" + str(km) + "\n"
if distance > 200:
gui.msgbox( str2+ " you can go another %s km" %(str(distance)) + "\n" + "the next station is 200km far away"
+ "\n" + " you can wait for the next station")
else:
gui.msgbox(str2 + "you must stop")
7-4 输入密码,you are in
import easygui as gui
code = 'mima123456'
tries = 0
test = gui.enterbox("请输入密码:",title="join us")
while test != code and tries < 5:
if not test:
break
tries += 1
test = gui.enterbox("please try again,you have %d times" %(5-tries))
if(test == code):
break
if (test == code):
gui.msgbox("ok,you are in")
else:
gui.msgbox("sorry")