1、打印0-9 十个数字
for i in range(10): print(i)
2、打印偶数:
for i in range(0,10,2): print(i)
3、if判断中猜游戏,升级(只能猜三次,超过三次没猜对,提示退出)
_age = 18for i in range(3): guess_age = int(input("guess_age:")) if guess_age == _age: print("GoodLuck!") break elif guess_age > _age: print("cai da le ") else: print("cai xiao le ")else: print("chao guo san ci qing tui chu!!!")
作业:
编写登陆接口
1.输入用户名密码;
2.认证成功后显示欢迎信息
3.输错三次,提示退出稍候在试
#!/usr/bin/env python_user = "lijinzhu"_pass = "123456"for i in range(3): user = input("Please input your username: ") passwd = input("input your passwd: ") if _user == user and _pass == passwd: print("WELCOME",user,"login this system") break else: print("username or passwd is wrong...")else: print("cuowu chaoguo 3ci,qing shaohou zai shi ......")