'''lecture_09_distance_template.py Illustrates how return statements work Oliver W. Layton CS 151: Computational Thinking: Visual Media Fall 2020 TODO: 1. Add return statement 2. Demo None: show what happens with assignment without return value 3. Simultaneous assignment: show returning absolute and Eucludean distance 4. Try adding int and tuple ''' import math # def distance(x, y): # '''Computes the Euclidean distance between x and y''' # dist = math.sqrt(x**2 + y**2) # return dist # # return math.sqrt(x**2 + y**2) # # math.sqrt(x**2 + y**2) # # main code # dist = 0 # x = 3 # y = 4 # dist123 = distance(x, y) # print(dist123) # if dist123 is None: # print('The value is None') # else: # print('The value is', dist123) def distance(x, y): '''Computes the Euclidean distance between x and y''' dist = math.sqrt(x**2 + y**2) absDiff = abs(x - y) return absDiff, dist # main code dist = 0 x = 3 y = 4 d1, d2 = distance(x, y) # z = distance(x, y) # print(z) # print('keep going...') # print(z + 1) # print('d1', d1) # print('d2', d2) # print(absDiff)