Day 2 条件语句 循环语句
条件语句
-
if
-
if-else
-
if-elif-else
-
assert
当这个关键词后边的条件为 False 时,程序自动崩溃并抛出AssertionError的异常。
循环语句
- while
- while-else
- for
- for-else
- range
- enumerate
枚举 给元素一个索引值 - break
- continue
- pass
空操作 不执行语句
练习1
i=1500
while i<=2700:
if i%7==0 and i%5==0:
print(i)
i=i+1
练习2
v1,v2,t,s,l = map(int,input().split())
k=0
time=0
s1=0
s2=0
while k<l:
s2=s2+v2
s1 = s1 + v1
time=time+1
k = max(s1, s2)
if k>=l:
break
if s1-s2>=t:
s1=s1-v1*s
if k==s1:
if k==s2:
print("D")
else:
print("R")
elif k==s2:
print("T")
print(time)