Ask Question

Val = 25

def example ():

global val

val = 15

print (val)

print (val)

example ()

print (val)

what is the output?

+2
Answers (1)
  1. 19 May, 19:48
    0
    25 15

    15

    Explanation:

    The first, print (val) will be printed, and here the value of val is 25 as set outside the function. Then the print (val) inside the example () will be printed, and here we have declared val as global and set its value to 15, And with last print as well, since the val is now global and with value 15, and hence the output will be 15. And hence the output is as above.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Val = 25 def example (): global val val = 15 print (val) print (val) example () print (val) what is the output? ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers