feedback

(Solution document) The programmer was expecting the following program to print 200. What does it print instead? Why does it print what it does?


 The programmer was expecting the following program to print 200. What does it print instead? Why does it print what it does?


def proc(x):

x = 2*x*x

def main():

num = 10

proc(num)

print(num)

main() 


Need some help please. This is in python. I do not understand these two questions.


Is the following program legal since the variable x is used in two different places (proc and main)? Why or why not?


def proc(x):

return 2*x*x

def main():

x = 10

print(proc(x))

main()

 







About this question:

Pay using PayPal (No PayPal account Required) or your credit card. All your purchases are securely protected by .
SiteLock