Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> x =42 >>> id(x) 140715097643328 >>> y =42 >>> id(y) 140715097643328 >>> x =5 >>> id(x) 140715097642144 >>> y 42 >>> id(y) 140715097643328 >>> a = [2, 4, 6] >>> type(a) >>> id(a) 2541285801416 >>> a[1] =7 >>> a [2, 7, 6] >>> for k in a: print(id(k)) 140715097642048 140715097642208 140715097642176 >>> a[1] =0 >>> id(a[1]) 140715097641984 >>> x 5 >>> y 42 >>> a [2, 0, 6] >>> a [2, 0, 6] >>> x 5 >>> y 42 >>> a [2, 0, 6] >>> def my_function(c): print(a) d= 2 print(d) print(c) >>> my_function(4) [2, 0, 6] 2 4 >>> a [2, 0, 6] >>> c Traceback (most recent call last): File "", line 1, in c NameError: name 'c' is not defined >>> d Traceback (most recent call last): File "", line 1, in d NameError: name 'd' is not defined >>> d = 20 >>> x 5 >>> y 42 >>> a [2, 0, 6] >>> d 20 >>> my_function(y) [2, 0, 6] 2 42 >>> d 20 >>> d 20 >>> def fn(w): print(w) print(d) d = 4 print(d) >>> fn(y) 42 Traceback (most recent call last): File "", line 1, in fn(y) File "", line 3, in fn print(d) UnboundLocalError: local variable 'd' referenced before assignment >>> def fn2(w): print(w) print(d) >>> fn2(y) 42 20 >>> def square(x) SyntaxError: invalid syntax >>> def square(x): return(x**2) >>> square(42) 1764 >>> def cube(x): return(x**3) >>> cube(10) 1000 >>> from math import sqrt >>> sqrt(101) 10.04987562112089 >>> from graphics import * >>> p1 = Point(5, 10) >>> p2 = Point(7, 20) >>> p1.getX() 5.0 >>> p1.getY() 10.0 >>> distance(p1, p2) Traceback (most recent call last): File "", line 1, in distance(p1, p2) NameError: name 'distance' is not defined >>> q = Point(0, 6) >>> distance(p1, q) Traceback (most recent call last): File "", line 1, in distance(p1, q) NameError: name 'distance' is not defined >>> a, b = 5, 7 >>> a 5 >>> b 7 >>> def sumdiff(x, y): return x + y, x - y >>> a 5 >>> b 7 >>> sumdiff(a, b) (12, -2) >>> w = sumdiff(a, b) >>> w (12, -2) >>> r, s = sumdiff(a, b) >>> r 12 >>> s -2 >>> r, s, t = sumdiff(a, b) Traceback (most recent call last): File "", line 1, in r, s, t = sumdiff(a, b) ValueError: not enough values to unpack (expected 3, got 2) >>> t = sumdiff(a, b) >>> t (12, -2) >>> t[0] 12 >>> t[1] -2 >>> def changeme(c): c = c+2 print(c) >>> s -2 >>> changeme(s) 0 >>> s -2 >>> def change2(x): #x is a list for k in range(len(x)): x[k] = k+2 >>> w = [7, 6, 5, 2] >>> change2(w) >>> w [2, 3, 4, 5] >>>