HW4Q5_NEW

 avatar
user_7676782
python
a year ago
950 B
2
Indexable
Never
def main():
    txtName1 = input("Enter first file name:")
    txtName2 = input("Enter second file name:")
    fileContent1 = open(txtName1, 'r')
    fileContent2 = open(txtName2, 'r')
    line1 = fileContent1.readline()
    line2 = fileContent2.readline()
    myList1 = line1.split()
    myList2 = line2.split()
    while line1 != '':
        mySet1 = set(myList1)
        mySet2 = set(myList2)
        print(mySet1)
        print(mySet2)
        # union of two sets
        mySet3 = mySet1.union(mySet2)
        print(mySet3)
        # Difference of two sets
        mySet3 = mySet1 - mySet2
        print(mySet3)
        mySet3 = mySet2 - mySet1
        print(mySet3)
        # Symmetric Difference of sets
        mySet3 = mySet1 ^ mySet2
        print(mySet3)
        line1 = fileContent1.readline()
        line2 = fileContent2.readline()
        myList1 = line1.split()
        myList2 = line2.split()


main()