Suppose you want to print a list of student currently enrolled in a school for a class. In this we have to pass a list of student in this function.
def PrintStudentNames(SchoolName,classname,*b): print(SchoolName) print(classname) print("Student Names are as: ") for name in b: print(name)
So when we want to call N number of student from the function we may call it using:
PrintStudentNames(‘Army School’,’12 th class’,’Mohit’,’Raj’,’Shobhit’,’Ranjan’,’Mitra’,’Rajni’)
Output:
Now try to write a programme that will help inĀ testing N number of test cases of addition..
so first write a addition programme.
def Add(a,b): return a+b def Testing(*b): for i in b: print(i) varsum=Add(i[0],i[1]) print("Summation is ",varsum) #Now Test a programme: Testing([1,2],[3,4],[7,8])
Now write a testing programme:
Output:
[1, 2] Summation is 3 [3, 4] Summation is 7 [7, 8] Summation is 15