# --------------------------------------------------------- # CSCI 246, Python Assignment # Your name # Last Modified: March ??, 2022 # --------------------------------------------------------- # Place the missing functions here. # --------------------------------------------------------- # print_set # --------------------------------------------------------- # original_set: a string that represents a set, e.g. "{1, 2}" # power_set, a list of strings that represents the power set of # the original set in any order, e.g. ["", "1", "12", "2"] # --------------------------------------------------------- # Print out a numbered list of each subset. Match the # format of the sample output transcript exactly. # --------------------------------------------------------- def print_set(original_set, power_set): print("The power set of", original_set, "consists of") counter = 1 for subset in power_set: print(str(counter) + ". {" + subset + "}") counter += 1 print("----------------") # --------------------------------------------------------- # relation_properties # --------------------------------------------------------- # max_label: The label of the highest point, e.g. 3 # Assume that points 0, 1, ... max_label exist # points: A list of lists that shows all ordered pairs in the relation, # e.g. [[0,1], [2,3]] is a relation consisting of 2 points # --------------------------------------------------------- # Determine whether a relation is (1) reflexive, (2) symmetric # and/or (3) transitive. These three concepts are introduced # in section 8.2. Match the format of the sample output transcript. # --------------------------------------------------------- def relation_properties(max_label, points): print("Data Set:", points) print("Reflexive:", reflexive(max_label, points)) print("Symmetric:", symmetric(max_label, points)) print("Transitive:", transitive(max_label, points)) print("----------------") # --------------------------------------------------------- # main # --------------------------------------------------------- # The main program to test the following functions that you # write: (1) power_set, (2) hamming, (3) reflexive, (4) symmetric # and (5) transitive. Note that we will test your solution with # a different main function so be sure that your solution is # fully general. Match the format of the sample output transcript. # --------------------------------------------------------- def main(): # Power Sets are introduced in section 6.1 # The power_set function can return the power set of its input in any order. print_set("{x,y,z}", power_set("xyz")) # Hamming Distance is introduced in section 7.1 print("The Hamming distance between 64 and 63 =", hamming(64, 63)) print("The Hamming distance between 4 and 4 =", hamming(4,4)) print("----------------") relation_properties(3, [[0,0], [0,1], [0,3], [1,0], [1,1], [2,2], [3,0], [3,3]]) relation_properties(3, [[0,0], [0,2], [0,3], [2,3]]) relation_properties(3, [[0,1], [2,3]]) # --------------------------------------------------------- main()