โดย jirawoot » 20/06/2019 3:49 pm
โค้ด: เลือกทั้งหมด
def myfun_var(arg1,*vertuple):
"this function is show you how variable"
print("argument is", arg1)
for a in vertuple:
print("vartuple is:", a)
myfun_var("mindphp.com")
print('----------------------')
myfun_var('mindphp.com', 'training', 'python')
ผลลัพธ์
- Selection_019.png (9.71 KiB) Viewed 440 times
โค้ด: เลือกทั้งหมด
def summary(*a):
total=0
for n in range(len(a)):
total += a[n]
print('argument =',n ,":",a[n])
print(total)
summary(1,2,3,4,5,6,7)
summary(2.02,7.36)
ผลลัพธ์
- Selection_020.png (11.32 KiB) Viewed 440 times
[code]
def myfun_var(arg1,*vertuple):
"this function is show you how variable"
print("argument is", arg1)
for a in vertuple:
print("vartuple is:", a)
myfun_var("mindphp.com")
print('----------------------')
myfun_var('mindphp.com', 'training', 'python')
[/code]
ผลลัพธ์
[attachment=1]Selection_019.png[/attachment]
[code]
def summary(*a):
total=0
for n in range(len(a)):
total += a[n]
print('argument =',n ,":",a[n])
print(total)
summary(1,2,3,4,5,6,7)
summary(2.02,7.36)
[/code]
ผลลัพธ์
[attachment=0]Selection_020.png[/attachment]