⑴sum=0 for i in range(10): sum+=i i=i+1 print (sum) 輸出結(jié)果: | ⑵c=0 for i in range(1,21): if i%3==0 or i%5==0: c+=1 print(c) 輸出結(jié)果: |
⑶s="中國China" if len(s)<=5: t=s else: t=s[0:4] print(t) 輸出結(jié)果: | ⑷s=0 for i in range(1, 10) : if i%3==0: s=s+1 else: s=s+2 print(s) 輸出結(jié)果: |