马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
今日学习python的循环语句while和for P15,P16,P17,P18,P19love = 'yes'
while love == 'yes':
love = input("今天你还爱我吗?")
i=1
sum = 0
while i <=1000000:
sum=sum+i
i=i+1
print('和为',sum)
while True:
answer = input("可以退出吗?")
if answer == '可以':
break
print('不行')
i=0
while i < 10:
i=i+1
if i %2 ==0:
continue
print(i)
i=1
while i<5:
print("循环外",i)
i=i+1
else:
print("循环内",i)
day =1
while day <=7:
answer = input("今天有好好学习吗?")
if answer != '有':
break
day = day+1
else:
print("非常棒已经7天学习")
i=1
while i <=9:
j=1
while j <=i:
print(j,"*",i,"=",j*i,end=" ")
j=j+1
print()
i=i+1
day =1
hour =1
while day <=7:
while hour <=8:
print("今天学习八个小时")
hour = hour +1
if hour >1:
break
day =day+1
break
sum =0
for i in range(1,1000001):
sum=sum+i
print(sum)
for n in range(2,10):
for x in range(2,n):
if n%x ==0 :
print(n,'=',x,'*',n // x)
break
else:
print(n,'是一个素数')
|