首页 > 代码库 > day01学习总结(20170213)
day01学习总结(20170213)
#1测试判断用户与密码是否正确:
import getpass
username = "llz"
password = "123455"
_username = input("请输入用户名:")
#assword = getpass.getpass("请输入密码:")
_password = input("请输入密码:")
if _username == username and _password == password:
print("wlelcome user {name} longin ...".format(name = username))
else:
print("Invalid user or name!")
#2猜年龄的游戏1:
age_of_oldboy = 70
guess_age = int(input("guess oldboy_age:"))
if guess_age == age_of_oldboy :
print("yes,you got it!")
elif guess_age > age_of_oldboy:
print ("guess smaller...")
else:
print("guess it bigger...")
#3猜年龄的游戏.循环方法01:
age_of_oldboy = 56
count = 0
while count < 3:
guess_age = int(input("guess oldboy_age:"))
if guess_age == age_of_oldboy:
print ("yes,you got it!")
break
elif guess_age > age_of_oldboy:
print ("guess smaller...")
else:
print("guess it bigger...")
count +=1
else:
print ("your tried more than 3 times...")
#4猜年龄的游戏.循环方法02:
age_of_oldboy = 56
count = 0
for count in range(3):
guess_age = int(input("guess oldboy_age:"))
if guess_age == age_of_oldboy:
print ("yes,you got it!")
break
elif guess_age > age_of_oldboy:
print ("guess smaller...")
else:
print("guess it bigger...")
else:
print ("your tried more than 3 times...")
#5:打印循环数字:
for i in range(9):
print("______",i)
for j in range(9):
print(j)
if i > 5:
print("end!")
break
#6测试模块打印目录:
import os
cmd_res = os.popen("dir").read()
print("-->",cmd_res)
os.mkdir("new_dir")
day01学习总结(20170213)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。