Here is the arg asd qwert of te for majnu
""" chatapp """import sysdef decode(key, message):"""function to decode the message""" decoded_result = "" i = 0 while i < len(message): num = "" start = i while i < len(message) and message[i] != "0": num += message[i] i += 1 if len(num) != 0: index = int(num[0]) - 1 if index >= len(key): return "Error" else: character = key[index][len(num) - 1] if start > 1 and message[start - 2] == "0": character = character.upper() decoded_result += character i += 1 if message[0] == "0": decoded_result = decoded_result[0].upper() + decoded_result[1:] return decoded_resultdef encode(key, message):"""function to encode the message""" encoded_result = "" for c in message: if c.isdigit(): encoded_result += "0" if c.isupper(): encoded_result += "0" index = -1 for i in range(len(key)): if c.lower() in key[i]: index = i break if index == -1: return "Error" char = str(index + 1) times = key[index].index(c.lower()) + 1 char = char * times encoded_result += char encoded_result += "0" return encoded_resultdef main():"""driver code""" filename = sys.argv[1] reader = open(filename, encoding="utf-8", mode="r") fileinput = reader.readlines() reader.close() key_input = fileinput[0].strip().split(",") key = [s.strip() for s in key_input] operation = int(fileinput[1].strip()) message = fileinput[2].strip() if operation == 1: result = encode(key, message) elif operation == 2: result = decode(key, message) else: result = "Error" print(result)if __name__ == "__main__": try: main() except Exception as e: print("Error")"""importing sys to get arguments from command line"""import sysdef num_balloons_per_color(pattern, start, end):""" function to count the number of balloons of each color in a specified range.""" pattern_len = len(pattern) # find the total number of occurrences of each color in the full pattern total_counts = {"b": pattern.count("b"),"o": pattern.count("o"),"w": pattern.count("w"), } # Calculate the number of occurrences of each color in the given range will # be equal to the number of occurrences of each color in the full pattern # times # the number of full patterns that fit in the given range range_len = end - start + 1 range_counts = {"b": total_counts["b"] * (range_len // pattern_len),"o": total_counts["o"] * (range_len // pattern_len),"w": total_counts["w"] * (range_len // pattern_len), } # loop through the remaining characters in the given range and increment # the count for each color for i in range(start, start + (range_len % pattern_len)): char = pattern[i % pattern_len] range_counts[char] += 1 # prepare the result string pattern_str = ("b"+ str(range_counts["b"])+"o"+ str(range_counts["o"])+"w"+ str(range_counts["w"]) ) print(pattern_str)def main():"""driver code""" try: filename = sys.argv[1] reader = open(filename, encoding="utf-8", mode="r") fileinput = reader.readlines() reader.close() pattern = fileinput[0].strip() start_index = int(fileinput[1].strip()) end_index = int(fileinput[2].strip()) num_balloons_per_color(pattern, start_index, end_index) except Exception as e: passif __name__ == "__main__": main()"""It is the implementation of the an eCommerse store using OOP concepts.Design pattern which I followed is 'Factory Pattern', which is basicallya creational design pattern.Main entities in this design are:- User- NormalUser- StoreManager- Admin- Vendor- Item"""class User: def __init__(self, username, user_type): self.username = username self.user_type = user_type def view_items(self, items):"""View a list of items.""" print(f"{self.username} is viewing items:") for item in items: print(item)class NormalUser(User): def buy_item(self, item):"""Buy an item.""" print(f"{self.username} is buying item: {item}")class StoreManager(NormalUser): def add_item(self, vendor, item):"""Add an item to a vendor's inventory.""" vendor.add_item(item) print(f"{self.username} added item {item} to vendor {vendor.name}")class Admin(StoreManager): @staticmethod def create_vendor(name):"""Create a new vendor.""" vendor = Vendor(name) print(f"Admin created a new vendor: {vendor.name}") return vendor @staticmethod def create_user(username, user_type):"""Create a new user.""" user = User(username, user_type) print(f"Admin created a new user: {user.username}") return userclass Vendor: def __init__(self, name): self.name = name self.items = [] def add_item(self, item):"""Add an item to the vendor's inventory.""" self.items.append(item) print(f"Item {item} added to vendor {self.name}")class Item: def __init__(self, item_id, name, price, stock): self.item_id = item_id self.name = name self.price = price self.stock = stock def __str__(self):"""String representation of an item.""" return f"{self.name} (ID: {self.item_id}, Price: ${self.price}, Stock: {self.stock})"# driver Codeif __name__ == "__main__": # create instances admin = Admin("admin", "admin") store_manager = StoreManager("manager", "store_manager") normal_user = NormalUser("user", "normal_user") # create a vendor vendor_electronics = admin.create_vendor("Electronics") vendor_clothing = admin.create_vendor("Clothing") # add items to the electronics vendor item1 = Item(1, "Laptop", 1000, 10) item2 = Item(2, "Smartphone", 500, 20) store_manager.add_item(vendor_electronics, item1) store_manager.add_item(vendor_electronics, item2) # add items to the clothing vendor item3 = Item(3, "T-Shirt", 10, 100) item4 = Item(4, "Jeans", 20, 50) store_manager.add_item(vendor_clothing, item3) store_manager.add_item(vendor_clothing, item4) # view items normal_user.view_items(vendor_electronics.items) normal_user.view_items(vendor_clothing.items) # buy items normal_user.buy_item(item1) normal_user.buy_item(item2)ignore below thisIt is the implementation of the an eCommerse store using OOP concepts.Design pattern which I followed is 'Factory Pattern', which is basicallya creational design pattern.
Main entities in this design are:
- User
- NormalUser
- StoreManager
- Admin
- Vendor
- Item