+ 2

What does f(31415927) return, for the following function definition?def f(x): d=0 while x > 1: (x,d) = (x/2,d+1) return(d)

ans thz question guys plz

6th Feb 2018, 2:17 AM
kamalesh vra
kamalesh vra - avatar
6 Respuestas
+ 25
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
6th Feb 2018, 3:10 AM
🌛DT🌜
🌛DT🌜 - avatar
0
1
2nd Feb 2019, 5:43 AM
Prabhakaran K
Prabhakaran K - avatar
0
What does h(3231) return for the following function definition? def h(x): (m,a) = (1,0) while m <= x: (m,a) = (m*2,a+1) return(a)
1st Aug 2019, 4:25 AM
Saurabh S Jadhav
Saurabh  S Jadhav - avatar
0
What does h(3231) return for the following function definition? def h(x): (m,a) = (1,0) while m <= x: (m,a) = (m*2,a+1) return(a)
27th Sep 2019, 2:46 PM
RAMLAL K
0
What does f(27182818) return, for the following function definition? def f(x): d=0 while x > 1: (x,d) = (x/2,d+1) return(d)
28th Jan 2024, 6:00 PM
AKSHAY KUMAR
AKSHAY KUMAR - avatar
- 1
def f(x): d=0 while x >= 1: (x,d) = (x/4,d+1) return(d)
30th Jan 2019, 2:49 PM
kothapally manudeep
kothapally manudeep - avatar