+ 2
Please solve & explain
What is the output of this code? d=lambda p: p*2 t=lambda p:p*3 X=2 X=d(x) X=t(x) X=d(x) Print(x) Ans 24
4 Respuestas
+ 4
X=2
d(2)=4
t(4)=12
d(12)=24
+ 4
Error. Python is case sensitive. You've declared a variable named 'X' then used 'x'. 'Print' is not a function. Its 'print'.
Now, real problem and solution :
d = lambda p:p*2
Means,
def d(p) :
return p*2
t = lambda p:p*3
Means ,
def t(p) :
return p*3
Then,
x = 2
x = d(x) # x = 2*2 = 4
x = t(x) # x = 4*3 = 12
x = d(x) # x = 12*2 = 24
So, `print (x)` will output 24 ✓
0
Aur yaha small x undefined hai, correct your code, variable names are case sensitive
- 3
Tune dm ne youtube link bheja tha, wo subscribe kar diya hai, waha message ka reply nhi jaa rha tha to idhar reply kiya gai, dekh kar delete kr dena