Computer Science, asked by anshusainibala2801, 6 months ago

Determine the output of the following: def printit(list1): m=n=list1[0] for a in list1: if am: m=a print("Biggest", m, "smallest", n) list1=[2,13,11,15,6] printit(list1)

Answers

Answered by ItzMrAlcohol
1

Answer:

printit

Explanation:

Answered by dreamrob
0

Given program :

def printit(list1):

   m=n=list1[0]

   for a in list1:

       if a>m:

           m=a

   print("Biggest", m, "smallest", n)

list1=[2,13,11,15,6]

printit(list1)

Dry Run :

m = n = list[0] = 2

1) When a = 2

a>m ⇒ 2>2 (False)

2) When a = 13

a>m ⇒ 13>2 (True)

So, m = 13

3) When a = 11

a>m ⇒ 11>13 (False)

4) When a = 15

a>m ⇒ 15>13 (True)

So, m = 15

5) When a = 6

a>m ⇒ 6>15 (False)

So, final value of m = 15 and n = 2

So, the output is :

Biggest 15 smallest 2

Program to find biggest and smallest :

def Big_Small(L):

   m=n=L[0]

   for a in L:

       if a>m:

           m=a

       if a<n:

           n=a

   print("Biggest", m, "Smallest", n)

L=[12,13,11,15,6,34,1,23,3]                                

Big_Small(L)

Similar questions