Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need solution to code
#1
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
Reply
#2
Show what you have tried, and we will be glad to help.
Reply
#3
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.
Reply
#4
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.
Reply
#5
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
Reply
#6
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...")
Reply
#7
You need to read up on basic python commands, then rethink your approach to the problem
Reply
#8
@manish1m97
that worked thank you.

i found some sources that i can use. thank you
Reply
#9
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")
        break
it 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.
Reply
#10
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")
    break
i 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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  please looking for typo in my code (solution please) jamie_01 1 1,239 Jan-12-2022, 06:45 AM
Last Post: Gribouillis
  Newbie - code solution explained Stjude1982 2 1,790 Sep-16-2021, 08:54 AM
Last Post: Stjude1982
  Quick Help - Timers - Need Small Solution for Working Code EwH006 5 3,976 Nov-17-2020, 04:09 AM
Last Post: EwH006
  Multiplication Recursive Solution - What's Going On Inside the Code? emerger 1 2,592 Mar-04-2018, 07:11 AM
Last Post: ka06059
  Question on babynames.py solution code? Athenaeum 3 4,438 Feb-20-2018, 06:20 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020