python操作符与流程控制

操作符:

算术运算: +   -   *  /  %  //   **

逻辑运算:and or  not  

身份运算: is     not is

不可变数据类型:数字  字符串  字典key

可变数据类型:列表  字典value

优先级:幂运算>正负号>算术运算>比较运算>逻辑运算

流程控制:

if else

guess = input("猜猜老男孩的年龄:")
a = int(guess)
age = 56

if a == age :
print ("you get it")
elif a < age:
print("too small")
else:
print("too big")

while   break  cuntinue else 

count = 3
while count:

username = input("请输入用户名:")
password = input("请输入密码:")
if username == "oldboy" and password == "123":
print("登陆成功!")
break
else:
count -= 1
print("错误!还有",count,"次机会!")
if count == 0:
print("机会用光了,程序退出")

原文地址:https://www.cnblogs.com/pythonclass/p/7200614.html