# Name: # Section: # hw3.py ##### Template for Homework 3, exercises 3.1 - ###### # ********** Exercise 3.1 ********** # Define your function here ##### YOUR CODE HERE ##### # Test Cases for Exercise 3.1 ##### YOUR CODE HERE ##### # ********** Exercise 3.2 ********** # Define your function here def ball_collide(ball1, ball2): ##### YOUR CODE HERE ##### return "Not Yet Implemented" # Test Cases for Exercise 3.2 # print ball_collide((0, 0, 1), (3, 3, 1)) # Should be False # print ball_collide((5, 5, 2), (2, 8, 3)) # Should be True # print ball_collide((7, 8, 2), (4, 4, 3)) # Should be True # ********** Exercise 3.3 ********** # Define your dictionary here - populate with classes from last term my_classes = {} def add_class(class_num, desc): ##### YOUR CODE HERE ##### return "Not Yet Implemented" # Here, use add_class to add the classes you're taking next term add_class('6.189', 'Introduction to Python') def print_classes(course): ##### YOUR CODE HERE ##### return "Not Yet Implemented" # Test Cases for Exercise 3.3 ##### YOUR CODE HERE ##### # ********** Exercise 3.4 ********** NAMES = ['Alice', 'Bob', 'Cathy', 'Dan', 'Ed', 'Frank', 'Gary', 'Helen', 'Irene', 'Jack', 'Kelly', 'Larry'] AGES = [20, 21, 18, 18, 19, 20, 20, 19, 19, 19, 22, 19] # Define your functions here def combine_lists(l1, l2): comb_dict = {} ##### YOUR CODE HERE ##### return comb_dict # combined_dict = combine_lists(??, ??) # Finish this line... def people(age): # Use combined_dict within this function... return "Not Yet Implemented" # Test Cases for Exercise 3.4 (all should be True) #print 'Dan' in people(18) and 'Cathy' in people(18) #print 'Ed' in people(19) and 'Helen' in people(19) and\ # 'Irene' in people(19) and 'Jack' in people(19) and 'Larry'in people(19) #print 'Alice' in people(20) and 'Frank' in people(20) and 'Gary' in people(20) #print people(21) == ['Bob'] #print people(22) == ['Kelly'] #print people(23) == [] # ********** Exercise 3.5 ********** def zellers(month, day, year): ##### YOUR CODE HERE ##### return "Not Yet Implemented" # Test Cases for Exercise 3.5 print zellers("March", 10, 1940) == "Sunday" # This should be True ##### YOUR CODE HERE #####