Python Frequently Asked Questions, Release 3.9.5 13 2.2. Core Language However, there is one class of operations where the same operation sometimes has different behaviors with different types: the augmented assignment operators. For example,$_{+=}$ mutates lists but not tuples or ints ($_{a_list +=}$ Some operations (for example$_{y.append(10)}$ and$_{y.sort()}$ ) mutate the object, whereas superficially similar operations (for example$_{y = y + [10]}$ and$_{sorted(y)}$ ) create a new object. In general in Python (and in all cases in the standard library) a method that mutates an object will return$_{None}$ to help avoid getting the two types of operations confused. So if you mistakenly write$_{y.sort()}$ thinking it will give you a sorted copy of$_{y}$, you’ll instead end up with$_{None}$ , which will likely cause your program to generate an easily diagnosed error. we can see that in this case$_{x}$ and$_{y}$ are not equal anymore. This is because integers are immutable , and when we do x = x + 1 we are not mutating the int$_{5}$by incrementing its value; instead, we are creating a new object (the int 6 ) and assigning it to$_{x}$ (that is, changing which object$_{x}$ refers to). After this assignment we have two objects (the ints$_{6}$and$_{5}$ ) and two variables that refer to them ($_{x}$ now refers to$_{6}$but$_{y}$ still refers to$_{5}$ ). >>> x =5 # ints are immutable >>> y =x >>> x =x +1 # 5 can't be mutated, we are creating a new object here >>> x 6 >>> y 5 If we instead assign an immutable object to$_{x}$: After the call to$_{append()}$ , the content of the mutable object has changed from$_{[]}$ to$_{[10]}$ . Since both the variables refer to the same object, using either name accesses the modified value$_{[10]}$ . There are two factors that produce this result: you might be wondering why appending an element to$_{y}$ changed$_{x}$ too. 2) Lists are mutable , which means that you can change their content. 1) Variables are simply names that refer to objects. Doing$_{y = x}$doesn’t create a copy of the list – it creates a new variable$_{y}$ that refers to the same object$_{x}$refers to. This means that there is only one object (the list), and both$_{x}$ and$_{y}$ refer to it. >>> x =[] >>> y =x >>> y.append( 10 ) >>> y [10] >>> x [10] 2.2.9 Why did changing list ‘y’ also change list ‘x’? 2.2.8 What is the difference between arguments and parameters? Parameters are defined by the names that appear in a function definition, whereas arguments are the values actually passed to a function when calling it. Parameters define what types of arguments a function can accept. For example, given the function definition: foo , bar and kwargs are parameters of$_{func}$ . However, when calling$_{func}$ , for example: def func(foo, bar = None ,**kwargs): pass func( 42 , bar=314 , extra=somevar) the values$_{42}$ ,$_{314}$ , and$_{somevar}$are arguments. If you wrote code like: