1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | def setup(): name=["John","Henry","Michael"] id=[1,2,3] age=[17,16,19] weight=[45,90,65] height=[156,170,175] bmi=[] print("---------- DISPLAY ZONE ----------") i=0 while i<len(weight): print(" [id",id[i],"][ Name",name[i],"][ age",age[i],"][ weight",weight[i],"][ height",height[i],"]") i+=1 i=0 # ---------- bmi zone ---------- print("---------- BMI ZONE ----------------") count=0 # bmi > 25 bmi=BMI(weight,height) while i<len(bmi): # ---------- print bmi>25 if bmi[i]>25: count+=1 print("[ id",id[i],"][ Name",name[i],"][ age",age[i],"][ weight",weight[i],"][ height",height[i],"][ BMI","{:.2f}".format(bmi[i]),"]") i+=1 print("count BMI > 25 :",count) # number of student bmi>25 # ---------- average age zone ---------- print("---------- Age ZONE ----------------") print("Average age of students : ","{:.2f}".format(avg(age))) # ---------- count age < 30 ---------- c=0 # age<30 i=0 while i<len(age): if age[i]<30: c+=1 i+=1 print("count age < 30 : ",c) # ---------- minimum weight of student ---------- print("---------- Weight ZONE ----------------") print("minimum weight of students :",mini(weight)) c1=0 i=0 while i<len(weight): if weight[i]<50: c1+=1 print("[ id",id[i],"][ Name",name[i],"][ age",age[i],"][ weight",weight[i],"][ height",height[i],"]") i+=1 print("count number of students with weight < 50 : ",c1) def BMI(w,h): bmi=[] i=0 while i<len(w): m=h[i]/100 bmi.append(w[i]/(m*m)) i+=1 return bmi def avg(a): i=0 sum=0 while i<len(a): sum+=a[i] i+=1 sum=sum/len(a) return sum def mini(a): min=a[0] i=0 while i<len(a): if a[i]<min: min=a[i] i+=1 return min setup() |
วันอังคารที่ 20 ตุลาคม พ.ศ. 2558
Lab06 : Parallel array
สมัครสมาชิก:
ส่งความคิดเห็น (Atom)
commit เพิ่มเติม : เพื่ม userstory, bookmark
>> add userstory ทำการเพิ่ม userstory ใน functional tests >> add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...
-
1 2 3 4 5 6 7 8 9 def setup (): print (d2b( 8 )) def d2b (num): x = "" while num > 0 : x = str ( int (n...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 def test_layout_and_styling ( self ): # Edith goes to the home page self . brow...
-
การใช้ template inheritence คือการสืบทอดเทมเพลต เพื่อให้ไม่ต้องเขียนโค้ดหน้าเว็บๆซ้ำๆ เราจะมีหน้าหลักอันเดียว (base.html or parent) ภายในนั...
ไม่มีความคิดเห็น:
แสดงความคิดเห็น