用python做一个判断多个数字是否为偶数或奇数的程序
用python做一个判断4个数字是否为偶数或奇数的程序,并且在最后说出1.奇数的数目比偶数多 2.偶数比奇数多 3.奇数和偶数一样多
人气:395 ℃ 时间:2019-11-07 07:05:57
解答
datas = [1,2,3,4]
s = d = 0
for i in datas:
if i%2 == 0:
d+=1
else:
s+=1
if s > d:
print '奇数多'
elif s < d:
print '偶数多'
else:
print '一样多'
推荐
猜你喜欢
- 一个长方体的饼干盒,长10cm,宽6cm,高12cm.如果围着它贴一圈商标纸(上下不贴),这张商标纸的面积至
- 中和5ml某h2so4溶液,用去0.5mol/l的naoh液25毫升,求该硫酸氢溶液
- 抛物线y=x2-4x-4的顶点坐标是_.
- 杜甫的诗歌大多反映现实生活,表现了忧国忧民的思想,因此被后人尊称为——
- 1、一种商品打六折,售价是600元,如果按原价卖出可以多赚多少钱
- R1,R2并联时电流比为1:2,电阻R1功率为P1,若R1,R2串联接到同一电源上,此时R2的功率为P2.则P1:P2=?
- 小麦的出粉率一定,小麦的重量和磨成的面粉的重量( )
- It was easy of him to make mistakes in grammer. 为什么是of him 不是for him ?