+ 1

Can someone please explain this program? #Python

def f(x): return g(x)+3%2 def g(x): return x**2+2 print(f(g(1))) Correct answer is 12.. but I don't know how.. Please explain... How I think it is done. First g(1) is solved.. so g(1)= 1**2+2 = 3 Now it becomes f(3) From definition of f we have g(x) + 1 which means 3+1= 4 So according to me the answer is 4 but idk how it comes to be 12.. even tried running this program. Thanks

21st Jul 2019, 6:33 PM
Rohit Panchal
Rohit Panchal - avatar
4 ответов
+ 3
f(3) returns g(3) + 3 % 2. g(3) returns 11 (3**2 + 2) 11 + 3 % 2 = 12.
21st Jul 2019, 6:45 PM
Paul
Paul - avatar
+ 2
~ swim ~ thanks once again.
21st Jul 2019, 6:50 PM
Rohit Panchal
Rohit Panchal - avatar