python3.7 初学整理,,if判断句使用the
python3.7 初学整理,,if判断句使用the
if判断句使用
the_world_is_flat=Falseif the_world_is_flat: print ("Be careful not to fall off!")else: print ("No!")
运行结果:
运算
print(2+2)print(8/5)print(8/2) # //忽略小数部分
运行结果:
除法永远返回浮点数
print(5**2) #乘方 5的2次方
运行结果:25
赋值
width=10height=20area=width*heightprint(area)
运行结果:200
转义
print(‘C:\some\name‘)print(r‘C:\some\name‘)
运行结果:
连接字符串
str="pyt"print(str+"hon")
运行结果:
嵌套判断
num=float(input("请输入一个数字"))if num>=0: if num==0: print ("零") else: print ("正数")else: print ("负数")
运行结果:
python3.7 初学整理
评论关闭