Hi,all

Last week we all go through Virtual environment and Testing.Hence in this blog, I'm going to explain how to test a program.

Here am testing the program "biggest two in a list". Here we have under stand how to get two biggest number in a list.

``````def big(n):
x=n
y=n
if (x<y):
y=n
x=n
for i in range(2,len(n)):
if (x<n[i]):
y=x
x=n[i]
elif(y<n[i]):
y=n[i]

return (x,y)

``````

Here once we got the list we just assign first two element into x and y.Then we check x and y by using if loop.And assign biggest to x and second biggest to y.then we compare x and y with other element in list by using for loop and if  loop.once it starts the for loop and if check element in x is < n[i], if true it will assign x equal to that element and change element in the x to y. If the if loop condition is false then element in x will not change and it goes to else condition.In else loop it check element in y is less then n[i],then it will assign to it ,this FOR loop continue until the it reach the last element in list.And here we return x and y.

Then write testing program test.

import big
def test():
actual=big.big([10,12,5,15,9,16])
expect=16,15
assert actual == expect

Here we import the program file,then we create function .Here in variable actual we give the list by call the function and assign the expected return to the variable expect,at last we check whether return value from program and expect value is equal.if its equal then show it is passed else its show error.

That's for this week.....

thank you...