def setup():
a = [8,8,3,5,8,2,7,-5,2]
display_list(a)
maxval_position(a)
def maxval(a):
max=a[0]
i=0
while i<len(a):
if a[i]>max:
max=a[i]
i+=1
return max
def maxval_position(a):
max=maxval(a)
i=0
keep=[]
while i < len(a):
if a[i]==max:
keep.append(i)
i+=1
if len(keep)==1:
print("First & Last:",keep[0])
else :
print("First:",keep[0])
print("Last:",keep[len(keep)-1])
def display_list(a):
i=0
while i<len(a):
print(i,":",a[i])
i+=1
setup() # keep=[] -> list # keep.append("what to append")
======================================================================
def setup():
a = [8,8,3,5,8,2,7,-5,2]
display_list(a)
m=maxval(a)
print(max_first_position(a,m))
print(max_last_position(a,m))
def maxval(a):
max=a[0]
i=0
while i<len(a):
if a[i]>max:
max=a[i]
i+=1
return max
def max_first_position(a,max):
i=0
while i < len(a):
if a[i]==max:
return i
break
i+=1
def max_last_position(a,max):
i=len(a)-1
while i > 0:
if a[i]==max:
return i
break
i-=1
def display_list(a):
i=0
while i<len(a):
print(i,":",a[i])
i+=1
setup()
สมัครสมาชิก:
ส่งความคิดเห็น (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) ภายในนั...
ไม่มีความคิดเห็น:
แสดงความคิดเห็น