Computer Science, asked by leenapatil8334, 6 months ago

Find and write the output of the following code.
Def ChangeVal(M,N):
For i in range (N) :
If M[i]%5==0:
M[i] //=5
If M[i]%3==0
M[i] //=3
L=[25,8,75,13]
ChangeVal(L,4)
For i in L:
Print (i,end='#') ​

Answers

Answered by vishwajithjkumar1
56

Answer:

5#8#5#4#

Explanation:

First i=0

M[i]=25

Thus value of M[i] changes to integer value of 25/5 i.e 5

Similarly the loop goes through...

At 8 no change at 75, M[i] divisible by both 5 and 3. So after 1st if condition M[i] = 15

After 2nd if condition its divided again by 3 and integer value is taken thus its 5.

For 12 it changes M[i] changes to 4.

These changes are done directly to the list so after the modifications the list M = [5,8,5,4]

Thus after the function is called this is the value of M.

Then using for loop each value is printed with a hash after it.

Hope it helped

Answered by SaurabhJacob
5

The output is,

                         5#8#5#13#

  • Since the function is for changing the value.
  • In the first loop, the first condition is checking for the multiple of 5. So, the value at that place is changed to quotient b dividing it by 5.
  • Similarly in the second condition but the value is changed to 3.
  • In the second loop, there is printing of every element of the list is taking place by separating it with # by using the end statement.
Similar questions