วันอาทิตย์ที่ 4 ตุลาคม พ.ศ. 2558

+num array

def setup():
   n = [ 9,-5,18,-2,0,7]
   i=0
   summ=0
   count=0
   while(i<len(n)):
      if(n[i]>=0):
         summ=summ+n[i]
         count=count+1
      i=i+1
   print("count positive number of array = ",count)  
   print("sum of positive in array =",summ)
 
setup()

ไม่มีความคิดเห็น:

แสดงความคิดเห็น