# Standard Library import datetime # Library {} # from datetime import datetime LEVEL 1 import subprocess # import datetime, subprocess Pythonic class Orders: def __init__(self, orderID, productSku, productPrice): self.orderID = orderID self.productSku = productSku self.productPrice = productPrice self.orderDate = datetime.datetime.now() # subprocess def calculate_total(self): qty = int(input("Enter quantity: ")) # input() total_price = self.productPrice * qty # int(qty) return total_price def log_order(self): log_message = f"Order ID: {self.orderID} | Order Date: {self.orderDate}\n" # method 1 use the CURRENT process with open("order_log_process.txt", "a" ) as logfile: logfile.write(log_message) # method 2 use a subprocess to handle the logging #subprocess.run(["echo", log_message, ">>", "order_log_subprocess.txt", shell=True]) subprocess.run(["powershell", "-Command", f"Add-Content -Path order_log_subprocess.txt -Value \"{log_message}\""], shell=True) # Process with subprocess if __name__ == "__main__": # Create an instance of Orders order = Orders("1001", "SKU1234", 19.99) # Line Item total total = order.calculate_total() # input() user * price print(f"${total:.2f}") #Log the order #subprocess order.log_order()