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("賬號密碼錯誤,請重新輸入")