Question: Consider the following fragment of a Python program: def main() answer = 4 result = cube (3) print(answer, result) def cube(x): answer = x
Consider the following fragment of a Python program: def main() answer = 4 result = cube (3) print(answer, result) def cube(x): answer = x * X *X return answer Explain why the output is 4 27, and not 27 27 (since cube() sets answer to 27).
Step by Step Solution
3.43 Rating (143 Votes )
There are 3 Steps involved in it
The output is 4 27 because there are two separate variables named answer in the program T... View full answer
Get step-by-step solutions from verified subject matter experts
