From 1757cabb325ab1fbe6563a81e5eaa4209fe823a8 Mon Sep 17 00:00:00 2001 From: Ekaterina-Treushnikova Date: Sun, 26 Jul 2020 16:59:51 +0300 Subject: [PATCH] test my first task --- homework_lec_1_and_2/compare.py | 18 +++++++++ homework_lec_1_and_2/pizza.py | 67 +++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 homework_lec_1_and_2/compare.py create mode 100644 homework_lec_1_and_2/pizza.py diff --git a/homework_lec_1_and_2/compare.py b/homework_lec_1_and_2/compare.py new file mode 100644 index 0000000..61c7d87 --- /dev/null +++ b/homework_lec_1_and_2/compare.py @@ -0,0 +1,18 @@ +# list1=[1, 2.7, "Hi", 1] # for testing +# list2=[1, 2.7, "Hi", 1] # for testing + +list1=input("Enter list1 with '[]' or '()' and ',' ") +list2=input("Enter list2 with '[]' or '()' and ',' ") + +def compare_lists(list1,list2): + count = 0 # for now that this is end of lists + if ((type(list1) == type(list2)) and (len(list1)==len(list2))): # compare type and length of our lists + for i in list1: + if id(i) == id(list2[(list1.index(i))]): # or if (type(i)== type(list2[(list1.index(i))]) and i==list2[(list1.index(i))]): + count += 1 # if compare type and value of our lists is True + if len(list1) == count: # this is the last element of our list + return True + return False # if at least one condition isn't made + +print("Result of list1 = ", list1, "and", "list2 = ", list2) +print("is ", compare_lists(list1,list2)) \ No newline at end of file diff --git a/homework_lec_1_and_2/pizza.py b/homework_lec_1_and_2/pizza.py new file mode 100644 index 0000000..13d290e --- /dev/null +++ b/homework_lec_1_and_2/pizza.py @@ -0,0 +1,67 @@ +class Pizza: + def prepare_base(self): + print("Start cooking!") + print("On the basis we put: ") + + def prepare_ingredients(self): + pass + + def __cook(self): + pass + + +class PizzaMeat(Pizza): + def prepare_ingredients(self): + print("sauce, onions,tomato, cucumbers, meal, olives and sprinkle with cheese!") + self.__cook() + + def __cook(self): + print("We send it to the oven for 20 minutes...") + print("Meat pizza is done! Enjoy!") + + +class PizzaVegetable(Pizza): + def prepare_ingredients(self): + print("sauce, tomato, mozzarella, basil and sprinkle with cheese!") + self.__cook() + + def __cook(self): + print("We send it to the oven for 15 minutes...") + print("Vegetable pizza is done!") + + +class PizzaMushroom(Pizza): + def prepare_ingredients(self): + print("sauce, mushrooms, onions, dill and sprinkle with cheese!") + self.__cook() + + def __cook(self): + print("We send it to the oven for 17 minutes...") + print("Mushroom pizza is done!") + + +# scenario +while 1: + try: + pizza_type = int(input("Enter type's pizza(1-meat, 2-vegetable, 3-mushroom) for cooking: ")) + break + except ValueError: + print("Incorrect input! It isn't number.") + +if pizza_type == 1: + pizza_meat = PizzaMeat() + pizza_meat.prepare_base() + pizza_meat.prepare_ingredients() + +elif pizza_type == 2: + pizza_vegetable = PizzaVegetable() + pizza_vegetable.prepare_base() + pizza_vegetable.prepare_ingredients() + +elif pizza_type == 3: + pizza_mushroom = PizzaMushroom() + pizza_mushroom.prepare_base() + pizza_mushroom.prepare_ingredients() + +else: + print("This number isn't on the menu! Good bay!")