python 2019.10.16

Posted on 2019-10-15 17:53  明俊  阅读(123)  评论(0)    收藏  举报

学了if语句

if 条件:
    结果

if 条件:
    结果
elif 条件:
    结果
else:
    结果
while循环
while 循环条件:
    循环体

循环终止
1.改变循环条件终止
2.break 终止循环
3.continue 跳过本次循环继续下次循环

while 循环条件:
    循环体
else#循环结束后运行else

占位符 %$:表示字符串  $d表示数字
例:
name = input("请输入你的名字")
age = int(input("请输入你的年龄"))
height = int(input("请输入你的身高"))

info=(我叫%s年龄$d岁身高%dcm学习进度3%%) %(name, age,height)
print(info)

运算符 + — * / % == +=  —= *=  /=  != <>  > < 
逻辑运算符 not  and  or  优先级:()not and or
print(1 or 2) # 1
print(0 or 2) # 2
print(1 and 2)# 2
print(0 and 2)# 0

 

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3