What is the value of f(4000) for the function below?
def f(x):
d=0
while x ;= 1:
(x,d) = (x/5,d+1)
return(d)
Answers
Answered by
0
Return value of the function:
Output:
none
Explanation:
In the given method definition there is some error so, the correct method definition to this question can be describes as follows:
Method definition:
def f(x): #defining a method
d=0 #defining a variable d and initializes a value that is 0
while x == 1: #defining loop to calculate value
(x,d) = (x/5,d+1) #holding value in x and d variable
return(d) #return value
val=f(4000) #calling the method
print(val) #print value
Explanation to this question can be defines as follows:
- In the above code, a method a variable "d" is defined, which initializes a value, that is 0.
- In the next step, a while loop is declared, that holds calculated value in x and d variable and return d variable value, and method is called, that accept a value, that is "4000", are print is the return value.
- In this method loop value is equal to 1, which is wrong that's why it will print "none".
Learn more:
- Return type: https://brainly.in/question/9967610
Similar questions