1 #! /usr/bin/env python3 2 # -*- coding:utf-8 -*- 3 4 # 输出1-100内所有的奇数 5 6 count = 1 7 8 while count < 101: 9 tmp = count % 2 10 if tmp == 0: 11 pass 12 else: 13 print(count) 14 count += 1
1 #! /usr/bin/env python3 2 # -*- coding:utf-8 -*- 3 4 # 输出1-100内所有的奇数 5 6 count = 1 7 8 while count < 101: 9 tmp = count % 2 10 if tmp == 0: 11 pass 12 else: 13 print(count) 14 count += 1
Python从0到100(七):Python列表介绍及运用
一、Python语法#求出1-100的奇数和、偶数和sum_1 = 0sum_2 = 0for i in range(1,101): if i%2 ==0: sum_2 += i else: sum_1 += iprint("奇数和:",sum_1)print("偶数和:",sum_2)奇数和: 2500偶数和: 2550二、Java
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M