1.

What does g(31415927) return, for the following function definition? def g(x): (q,d) = (1,0) while q

Answer»

"ANSWER is 25

the while loop will run 25 times

as 31415927 / 2**24 =1.8...  which is > 1

so for last time it will GO

for 2**25 , d will be incremented 24+1=25

then it becomes less than 1

CONDITION becomes false... while loop terminates


-->the no. of times X is divided by 2 & remains >1

the d will be incremented by 1"



Discussion

No Comment Found