Bottom Page

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
Quote
#2
Show what you have tried, and we will be glad to help.
Quote
#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.
Quote
#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.
Quote
#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
Quote
#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...")
Quote
#7
You need to read up on basic python commands, then rethink your approach to the problem
Quote
#8
@manish1m97
that worked thank you.

i found some sources that i can use. thank you
Quote
#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.
buran wrote Feb-27-2019, 11:15 AM:
closing tag should use forward slash /, not backslash \
Quote
#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
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Fix the solution of “Binary period” sonia 0 169 Jul-22-2019, 02:46 PM
Last Post: sonia
  maze solution jenya56 5 350 Mar-27-2019, 05:11 PM
Last Post: ichabod801
  Python modeling a math solution Masterwoot 1 210 Mar-01-2019, 08:50 AM
Last Post: buran
  Quick Help - Timers - Need Small Solution for Working Code EwH006 2 365 Jan-20-2019, 12:27 AM
Last Post: snippsat
  How can I put an np.arange in equation's solution? pianistseb 3 362 Dec-22-2018, 02:50 AM
Last Post: SheeppOSU
  pyad time conversion error (plus solution) PapaZod 2 408 Nov-25-2018, 02:42 PM
Last Post: PapaZod
  Recursive Solution - Greatest Common Denominator emerger 2 717 Mar-17-2018, 03:01 PM
Last Post: emerger
  Multiplication Recursive Solution - What's Going On Inside the Code? emerger 1 582 Mar-04-2018, 07:11 AM
Last Post: ka06059
  Question on babynames.py solution code? Athenaeum 3 1,008 Feb-20-2018, 06:20 AM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)