>>> 9/2
4.5
If n%3==0 and n%5==0
>>> 7**4
2401
F=(c+32)/9*5
inp = int(input("请输入消费金额:"))
if inp >= 50 and inp <=100:
print("你消费金额:%s,优惠:%s,需要支付:%s"%(inp,round(inp*0.1,2),inp-inp*0.1))
elif inp > 100:
print("你消费金额:%s,优惠:%s,需要支付:%s"%(inp,round(inp*0.2,2),inp-inp*0.2))
elif inp < 50:
print("您的消费不足")
a = 2
for i in range(1,100):
print("%s + %s = %s"%(i,a,i+a))
a+=1
a,b=1,2
a,b=b,a
For循环
x=0
for i in range(10):
inp = input("请输入性别(m/f):")
if inp == "f":
print("可以加入球队")
x+=1
elif inp == "m":
print("不满足要求")
print("满足要求的总人数:%s"%x)
While循环
x=0
i=0
while i < 10:
inp = input("请输入性别(m/f):")
if inp == "f":
print("可以加入球队")
x+=1
elif inp == "m":
print("不满足要求")
i+=1
print("满足要求的总人数:%s"%x)
import math
inp = int(input("目前油箱状态:"))
tank1 = 60
oc = 11
for tank in range(60,0,-1) :
print("油箱多大%s,油箱状态%s,还能行驶%s km"%(tank1,round(tank/60,2),round(tank*11,2)))
if tank <= 23:
print("请在下一站加油")
break
elif tank > 23:
print("本站不需要加油,请在后面第%s加油"%(math.ceil(tank*oc/200)))