+ 3
What is the value of h(6,8) for the function below?def h(m,n): ans = 1 while (n > 0): (ans,n) = (ans*m,n-2) return(ans)
2 Respostas
+ 6
n = 8, and for each iteration, n is deducted by 2, which means the loop would run 4 times, each for values of n = 8, 6, 4, 2.
m = 6. The variable ans is multiplied by m for each iteration, i.e.
1*6*6*6*6
= 1296.
+ 1
here we see that the loop will run until n>o ,i.e,8>0..this will happen if the loop runs for 4 times.hence for each iteration the value 6 which is obtained as (ans*m=6) will be multilplied making the answer as 6*6*6*6*1=1296