Programming Fundamentals
วันพุธที่ 23 กันยายน พ.ศ. 2558
Lab 5 - Find sum of positive values in array
def pos_sum(a):
n = a
i = 0
suma = 0
while(i < len(n)):
if(n[i] > 0):
suma = suma + n[ i ]
i = i + 1
print("Summary of Positive number is =", suma)
pos_sum([-5, 4, 3, 2, 1, -6, -3])
ไม่มีความคิดเห็น:
แสดงความคิดเห็น
บทความใหม่กว่า
บทความที่เก่ากว่า
หน้าแรก
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
ไม่มีความคิดเห็น:
แสดงความคิดเห็น