need solution to code - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: need solution to code (/thread-16319.html) |
need solution to code - mccluregamer4472 - Feb-23-2019 I need some help as i am currently learning to code and i have to make a specific piece of code but not understanding it at all at the moment. Basically i have to make a code that creats a batch and components that are in the batch. When the program generates a batch it must create a batch number with the date and order number so "ddmmyyyy9999" and same with components but the components have the batch number which is the "ddmmyyyy9999" but has "-9999" on the end to show how many products there are within the batch. if anyone has any solutions or ideas let me know, thank you RE: need solution to code - Larz60+ - Feb-23-2019 Show what you have tried, and we will be glad to help. RE: need solution to code - mccluregamer4472 - Feb-23-2019 i did have my code but cant find the file so restarted and it doesnt work lol but this is what i have batch_list = ["batch number", "no of components"] component_list = ["Winglet Strut A320 Series", "Winglet Strut A380 Series", "Door Handle A320 Series", "Door Handle A380 Series", "Rudder Pin A320 Series", "Rudder Pin A380 Series"] input_list = ["1", "2", "3", "4", "5", "6"] p1 = input("select a meterial: ") if input == "1": print("you have selected 1") break elif input == "2": print("you have selected 2") elif input == "3": print("you have selected 3") elif input == "4": print("you have selected 4") elif input == "5": print("you have selected 5") elif input == "6": print("you have selected 6") else: print("invalid input")i havent finished it yet. each number is a component and i have to create a batch number and that moves into a seperate file showing them in order and all the components inside that batch. RE: need solution to code - Larz60+ - Feb-23-2019 Since this an assignment, I moved it to homework. You should always post the assignment exactly as received, otherwise you may be asking for help without us knowing all of the conditions. For example, are you allowed to use dictionaries, or are lists required. RE: need solution to code - mccluregamer4472 - Feb-23-2019 thank you everything is allowed im sure. Ive just to find solutions to what i could have in my code for it. this is what its based on CREATE NEW BATCH BATCH NUMBER YYYYMMDD0001 HOW MANY COMPONENTS IN THIS BATCH (1 TO 9999)? > 3 SELECT COMPONENT TYPE (1. winglet strut, 2. door handle, 3. rudder pin) > 1 SELECT SIZE/FITMENT TYPE (1. a320 series, 2. a380 series) > 2 THIS BATCH CONTAINS 3 A380 WINGLET STRUTS IS THIS CORRECT Y/N? Y BATCH AND COMPONENT RECORDS CREATED AT HHMM ON YYYYMMDD PRINT BATCH DETAILS Y/N? Y BATCH NUMBER: YYYYMMDD0001 MANUFACTURE DATE: YYYYMMDD COMPONENT TYPE: WINGLET STRUT COMPONENT SIZE/FITMENT TYPE: A380 NUMBER OF COMPONENTS IN BATCH: 3 SERIAL NUMBERS: [YYYYMMDD0001-0001, YYYYMMDD0001-0002, YYYYMMDD0001-0003] COMPONENT STATUS: [ YYYYMMDD0001-0001 MANUFACTURED-UNFINISHED, YYYYMMDD0001-0002 MANUFACTURED-UNFINISHED, YYYYMMDD0001-0003 MANUFACTURED-UNFINISHED ] PRESS ANY KEY TO RETURN TO MENU RE: need solution to code - manish1m97 - Feb-23-2019 I think I got what you want. let me know does it work. batch_list = ["batch number", "no of components"] component_list = ["Winglet Strut A320 Series", "Winglet Strut A380 Series", "Door Handle A320 Series", "Door Handle A380 Series", "Rudder Pin A320 Series", "Rudder Pin A380 Series"] input_list = ["1", "2", "3", "4", "5", "6"] p1 = input("select a meterial: ") try: if p1 == "1": print("you have selected 1") elif p1 == "2": print("you have selected 2") elif p1 == "3": print("you have selected 3") elif p1 == "4": print("you have selected 4") elif p1 == "5": print("you have selected 5") elif p1 == "6": print("you have selected 6") else: raise ValueError except ValueError: print("Oops! That was no valid number. Try again...") RE: need solution to code - Larz60+ - Feb-23-2019 You need to read up on basic python commands, then rethink your approach to the problem RE: need solution to code - mccluregamer4472 - Feb-23-2019 @manish1m97 that worked thank you. i found some sources that i can use. thank you RE: need solution to code - mccluregamer4472 - Feb-27-2019 ive wrote this code so far. class batch: def _init_(self, batch_number, components_in_batch): self.batch_number = batch_number self.components_in_batch = components_in_batch class component: def _init_(self, type, size): self.type = type self.size = size def batch_number(): batch_number = batch_number + 1 print("batch number is " + currentDT.strftime("%d%m%y") + str(batch_number).zfill(4)) components_list = ["1 = Winglet Strut", "2 = Door Handle", "3 = Rudder Pin"] print(components_list) #if ( component == 1 # and size == 1 # ): # print("you have selected Winglet Strut A320 Series") #if component == 1 and size == 2: # print("you have selected Winglet Strut A320 Series") print("please select an option")# print("1 = create a batch") print("0 = exit") while True: choice = input("> ") if choice == '1': print("welcome to the program") break elif choice == '0': print("you have selected to exit program") break else: print("invalid choice") print() while True: print("what component?") component = input("> ") if component == '1': print("you have selected Winglet Strut.") break elif component == '2': print("you have selected Door Handle") break elif component == '3': print("you have selected Rudder Pin") break else: print("invalid choice") sizes_list = ["1 = A320 Series", "2 = A380 Series"] print(sizes_list) while True: print("Please select the size of the of the component") size = input("> ") if size == '1': print("you have selected the A320 Series") break elif size == '2': print("you have selected the A380 Series") break else: print("invalid choice") while True: if component == 1 and size == 1: print("you have selected Winglet Strut A320 Series") break elif component == 1 and size == 2: print("you have selected Winglet Strut A380 Series") break elif component == 2 and size == 1: print("you have selected Door Handle A320 Series") break elif component == 2 and size == 2: print("you have selected Door Handle A380 Series") break elif component == 3 and size == 1: print("you have selected Rudder Pin A320 Series") break elif component == 3 and size == 2: print("you have selected Rudder Pin A380 Series") break else: print("invalid process") breakit works until the last while loop it goes straight to invalid process on that one so not sure how to get it to read the results from the previous 2 while loops. RE: need solution to code - mccluregamer4472 - Mar-04-2019 this is what i have so far class batch: def _init_(self, batch_number, components_in_batch): self.batch_number = batch_number self.components_in_batch = components_in_batch class component: def _init_(self, type, size): self.type = type self.size = size components_list = ["1 = Winglet Strut", "2 = Door Handle", "3 = Rudder Pin"] print(components_list) def chosen_component(): print() def chosen_size(): print() print("please select an option")# print("1 = create a batch") print("0 = exit") while True: choice = input("> ") if choice == '1': print("welcome to the program") #batch_number = batch_number + 1 #print("batch number is " + (currentDT.strftime("%d%m%y") + str(batch_number).zfill(4)) break elif choice == '0': print("you have selected to exit program") break else: print("invalid choice") print() while True: print("what component?") component = input("> ") if component == '1': print("you have selected Winglet Strut.") chosen_component == 'component' break elif component == '2': print("you have selected Door Handle") chosen_component == 'component' break elif component == '3': print("you have selected Rudder Pin") chosen_component == 'component' break else: print("invalid choice") sizes_list = ["1 = A320 Series", "2 = A380 Series"] print(sizes_list) while True: print("Please select the size of the of the component") size = input("> ") if size == '1': print("you have selected the A320 Series") chosen_size == 'size' break elif size == '2': print("you have selected the A380 Series") chosen_size == 'size' break else: print("invalid choice") while True: if chosen_component == 1 and chosen_size == 1: print("you have selected Winglet Strut A320 Series") break elif chosen_component == 1 and chosen_size == 2: print("you have selected Winglet Strut A380 Series") break elif chosen_component == 2 and chosen_size == 1: print("you have selected Door Handle A320 Series") break elif chosen_component == 2 and chosen_size == 2: print("you have selected Door Handle A380 Series") break elif chosen_component == 3 and chosen_size == 1: print("you have selected Rudder Pin A320 Series") break elif chosen_component == 3 and chosen_size == 2: print("you have selected Rudder Pin A380 Series") break else: print("invalid process") breaki need to create the batch number still, ive tried a few solutions but it hasnt worked and i also need the final while loop to work as it needs to read from the 2 previous outputs to get its information |