Ejemplo n.º 1
0
class Iterate:
    def __init__(self):
        self.util = Utility()

    def iterate_num(self):
        num_set = set([0, 1, 2, 3, 4, 5])
        self.util.iterate_set(num_set)
Ejemplo n.º 2
0
class Iterate:
    def __init__(self):
        self.util = Utility()

    def display_dict(self):

        d = {'Black': 1, 'Yellow': 2, 'Orange': 3}
        self.util.iterate_dict(d)
Ejemplo n.º 3
0
class RemoveSet:
    def __init__(self):
        self.util = Utility()

    def rm_set(self):
        day = {
            "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
        }
        print(day)
        items = input("which item you want to remove")
        i = self.util.validate(items)
        if i:
            print("Please enter string")
        else:
            remove = self.util.remove(day, items)
            print("Set:", remove)
Ejemplo n.º 4
0
class Unique:
    def __init__(self):
        self.util = Utility()

    def unique(self):
        sample_dict = [{
            "V": "S001"
        }, {
            "V": "S002"
        }, {
            "VI": "S001"
        }, {
            "VI": "S005"
        }, {
            "VII": "S005"
        }, {
            "V": "S009"
        }, {
            "VIII": "S007"
        }]
        print("original list:", sample_dict)

        while 1:
            try:
                print(
                    "1.Find unique values in dictionary\n2.Display Original Dictionary\n3.Exit"
                )
                ch = input("Enter your choice")
                choice = self.util.validate(
                    ch)  # call to object of util class with its methods cll

                if choice:
                    ch = int(ch)  # conversion string to int

                    if ch == 1:
                        unique_data = self.util.unique_val(sample_dict)
                        print(unique_data)
                    elif ch == 2:
                        print("Original Dictionary:", sample_dict)
                    elif ch == 3:
                        exit()
                    else:
                        print("Enter choice b/w 1-3")
                else:
                    print("please enter valid choice")
            except Exception as e:
                print(e)
Ejemplo n.º 5
0
 def __init__(self):
     self.util = Utility()