Q. Consider the following code and write the flow of execution for this. Line numbers have been given for your reference.

def power (b, p):            # 1
    y = b ** p               # 2
    return y                 # 3
                             # 4
def calcSquare(x):           # 5
    a = power (x, 2)         # 6
    return a                 # 7
                             # 8
n = 5                        # 9
result = calcSquare(n)       # 10
print (result)               # 11

Answer :-

1->5->9->10->5->6->1->2->3->6->7->10->11

Output :-

25
>>> 

16 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. You have made big error, by not noticing the function call of power function in line 6.
    Correct answer is:
    1-5-9-10-5-6-1-2-3-6-7-10-11

    ReplyDelete
  2. You missed a 6 before 7(third last place) as compiler will read it again to assign the value in "a" present in 6th line.

    ReplyDelete
  3. Where is the output??Please tell

    ReplyDelete
  4. Output will be 52

    ReplyDelete
    Replies
    1. You are worng, Please run the program in your IDLE Python.

      Delete
  5. will it not directly execuse from __main__ why is def included?? its not in flow of execution

    ReplyDelete
    Replies
    1. i mean execute

      Delete
    2. I did not understant what you want to say, Please tell me again.

      Delete
  6. But, even blank line will be executed right?

    ReplyDelete
  7. I didn't get it's solution please give a brief explanation...

    ReplyDelete
  8. you fool of an ass

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post