Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
27
9
116
7.6K
Himanshu Kumar
Himanshu Kumar@codewithimanshu·
@PythonPr Arre wah, Python! Python code looks deceptively simple, but the 'why' is where the real fun begins, right?
English
0
0
0
91
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr Answer: B). 9 Why!? The function add(x, y) is defined as return x - y. (add(a,b)=add(3,2)=3-2=1) The function cube(x) is defined as return x * 3. The argument passed is the result from the previous step, which is 1. (cube(1)=1*3=3)
English
2
0
6
408
R. Stephen Ruiz
R. Stephen Ruiz@rslruiz·
@PythonPr Ans. b. 9 a = 3 b = 2 print(square(cube(add(a, b)))) # add(a, b) -> 1 # cube(1) -> 3 # square(3) -> 9
English
0
0
2
137
Ana
Ana@Anaf9y·
@PythonPr Answer is b) 9 add(3, 2) \ 3 - 2 = **1** cube(1) \ 1 * 3 = **3** The result of cube(...) (which is 3) is passed to square(x). The square(x) function is defined as return x * x square(3) \ 3 * 3 = **9** 😄
English
0
0
0
135
developer_ar
developer_ar@developer_ar198·
@PythonPr Add : x-y Cube: x*3 🤪🤪😂 Makes me remember my code!! 😂🤣😂
English
0
0
0
34
Paylaş