求100之和
#!/usr/bin/env python # _*_ coding:utf-8 _*_ i = 0 sum = 0 while i < 100: i = i + 1 sum = sum + i print(sum)
打印1-100跳过7
#!/usr/bin/env python # _*_ coding:utf-8 _*_ i = 0 while i < 10: i = i + 1 if i == 7: pass else: print(i)
#!/usr/bin/env python # _*_ coding:utf-8 _*_ i = 1 while i < 10: i = i + 1 if i == 7: continue print(i)
打印奇偶数
#!/usr/bin/env python # _*_ coding:utf-8 _*_ i = 0 while i < 100: i = i + 1 if i%2 == 0: print("偶数", i) else: print("奇数", i)