Python--day 2

 1 # -*- coding:utf-8 -*-
 2 # Author:Monarch-T
 3 import getpass
 4 #密文  模块在pycharm中不好使
 5 '''
 6 username = input("username:")
 7 userpasswd = getpass.getpass("passwd:")
 8 print(username, userpasswd)
 9 '''
10 #if-else流程语句
11 #python 强制缩进
12 #GTT不加引号是变量 单引号和双引号是一样的在python中
13 '''
14 _name = 'GTT'
15 _passwd = '1234'
16 username = input("username:")
17 userpasswd = input("passwd:")
18 
19 if username == _name and _passwd == userpasswd:
20     print("Welcome user {name} login...".format(name=username))
21 else:
22     print("Invaild username or userpasswd!")
23 '''
24 
25 guess = int(input("guess age:"))
26 age = 56
27 if age == guess:
28     print("you got it!")
29 elif guess > age:
30     print("think smaller!")
31 else:
32     print("think bigger!")
33 
34 #while循环
35 '''
36 count = 0
37 while True:
38     print("count:",count)
39     count = count + 1
40 '''
41 count = 3
42 while count>0:
43     guess = int(input("guess age:"))
44     age = 56
45     if age == guess:
46         print("you got it!")
47         break
48     elif guess > age:
49         print("think smaller!")
50     else:
51         print("think bigger!")
52     count -= 1
53 else:
54  print("you have tried too many times!....fuck off")
本文出自T-大帅的博客,转载必须注明出处。 https://www.cnblogs.com/Monarch-T/
原文地址:https://www.cnblogs.com/Monarch-T/p/10245706.html