Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m trying to understand this example code I\'m working on in Python (I\'m usin

ID: 3830289 • Letter: I

Question

I'm trying to understand this example code I'm working on in Python (I'm using version 3.6.1) to break down the code itself, and the relationship between its arguments & parameters. There are a few questions I had after looking over & working on it, and I'd really appreciate any help.

Exactly which parts of this code are the arguments, and which are the parameters?

For clarification... how are arguments & parameters matched?

I tried changing the value of 'a' using the calculate function, but after I ran the program, it doesn't look like the value changed. Why would this be?

def calculate(x, y):
a = y/x
a = a-x/y

b = 2
c = 3
a = 0

print (a)
calculate (b, c)
print (a)

Explanation / Answer

def calculate(x, y):
a = y/x
a = a-x/y

b = 2
c = 3
a = 0

print (a)
calculate (b, c)
print (a) #Here are printing the "a" value which is the outside of the method so it doesnot change.

##If You Change code like this it will work.

def calculate(x, y):
a = y/x
a = a-x/y
print (a) # Printing here is correct to get value in a method
b = 2
c = 3
a = 0
print (a)
calculate (b, c)

#Output:

sh-4.3$ python main.py                                                                                                                                                          

0                                                                                                                                                                               

1