python_day1

01

age_of_oldboy = 56
for i in range(3):
    guess_age = int(input("guess age:") )
    if guess_age == age_of_oldboy :
        print("yes, you got it. ")
        break
    elif guess_age > age_of_oldboy:
        print("think smaller...")
    else:
        print("think bigger!")
else:
    print("you have tried too many times..fuck off")

 02

age_of_oldboy = 56

count = 0
while count <3:
    guess_age = int(input("guess age:") )
    if guess_age == age_of_oldboy :
        print("yes, you got it. ")
        break
    elif guess_age > age_of_oldboy:
        print("think smaller...")
    else:
        print("think bigger!")
    count +=1
else:
    print("you have tried too many times..fuck off")

 03

 1 age_of_oldboy = 56
 2 
 3 count = 0
 4 while count <3:
 5     guess_age = int(input("guess age:") )
 6     if guess_age == age_of_oldboy :
 7         print("yes, you got it. ")
 8         break
 9     elif guess_age > age_of_oldboy:
10         print("think smaller...")
11     else:
12         print("think bigger!")
13     count +=1
14     if count == 3:
15         countine_confirm = input("do you want to keep guessing..?")
16         if countine_confirm != 'n':
17             count =0

04

 1 import getpass
 2 
 3 _username = 'alex'
 4 _password = 'abc123'
 5 username = input("username:")
 6 #password = getpass.getpass("password:")
 7 password = input("password:")
 8 if _username == username and _password == password:
 9     print("Welcome user {name} login...".format(name=username))
10 else:
11     print("Invalid username or password!")

05

 1 count = 0
 2 while True:
 3     print("count:",count)
 4     count = count +1  #count +=1
 5     if count == 1000:
 6         break
 7 
 8 
 9 for i in range(0,10):
10     if i <3:
11         print("loop ",i)
12     else :
13         continue
14     print("hehe...")
15 
16 
17 for i in range(10):
18     print('----------',i)
19     for j in range(10):
20         print(j)
21         if j >5:
22             break

 

posted @ 2019-10-04 23:17  谢义xieyi521149  阅读(134)  评论(0编辑  收藏  举报