python 运算/赋值/循环

python3 中只有一个Input
Python2 中的raw_input与python3中的input一模一样
python3中input输出字符串类型
int,float=数字类型
//地板除
% 取余数
**幂函数

交叉赋值
x=11
y=22
x,y=y,x
链式赋值
x=10
x=y=z=10

解压赋值
l=[1,2,3]
a,b,c=l

_纯粹下划线代表废弃变量

*_填充

逻辑运算符
and
or
not 将紧跟其后的条件结果取反
print(not 10<3 or 3<3) 括号里先算NOT
逻辑运算先算括号里的

比较运算符
!=不等于

循环
重复做某件事
while 条件:
代码1
代码2
代码3
# 终止本层循环

# print(10//3)
# print(14//3)
# print(20%3)
# print(15%3)
# print(10**5)
# # print(4**5)
# name1='小李子'
# name2='喜欢小顺子'
# # print(name1+name2)
# sentence='重要的事情说三遍'
# print(sentence*3)

# age = 18
# # # age+=1 # age=age+1
# # age*=3 # age=age*3
# # print(age)
# x=11
# y=22
# x,y=y,x
# print(x,y)
# x=y=z=11
# print(x,y,z)

# l=['wang','22','music','loving']
# # a,b,_,_,=l
# # a,b,*_=l
# # *_,a,b=l
# # a,*_,b=l
# print(a,b)

# dic={'sss':123,'www':333,'qqq':444}
# x,*_=dic
# print(x,_)
# res=(3>4 and 4>3) or ((1==3 and 'x' == 'x') or 3 >3)
# print(res)
#
# gender=input("请输入你的性别")
# age=int(input("请输入你的年龄"))
# height=int(input("请输入你的升高"))
# is_beautiful=int(input("请输入你的颜值"))
# if gender=='female' and age>18 and age<26 and height>165 and is_beautiful>7:
# weixin=input("请输入你的微信号:")
# else:
# print("谢谢")

# count='111'
# secret='123'
# of_count=input("请输入你的账号:")
# of_secret=input("请输入你的密码")
# if of_count == count and of_secret == secret:
# print("账户密码正确,欢迎使用")
# else:
# print("账号密码错误,请重新输入")
原文地址:https://www.cnblogs.com/longfeiwang/p/10196540.html