首页 > 代码库 > 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)