The programmer was expecting the following program to print


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()

Solution Preview :

Prepared by a verified Expert
Business Management: The programmer was expecting the following program to print
Reference No:- TGS02675849

Now Priced at $10 (50% Discount)

Recommended (97%)

Rated (4.9/5)