Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- components = ("Processor",
- "RAM",
- "Storage",
- "Screen",
- "Case",
- "USB ports")
- choices = ("P3",
- "P5",
- "P7",
- "16GB",
- "32GB",
- "1TB",
- "2TB",
- "19\"",
- "23\"",
- "Mini Tower",
- "Midi Tower",
- "2 ports",
- "4 ports")
- prices = (100, 120, 200, 75, 150, 50, 100, 65, 120, 40, 70, 10, 20)
- def get_components_sublist(component, case):
- if component == "Processor":
- if case == "upper":
- subcomponents = choices[:3]
- elif case == "lower":
- subcomponents = [processor.lower() for processor in choices[:3]]
- elif component == "RAM":
- if case == "upper":
- subcomponents = choices[3:5]
- elif case == "lower":
- subcomponents = [ram.lower() for ram in choices[3:5]]
- elif component == "Storage":
- if case == "upper":
- subcomponents = choices[5:7]
- elif case == "lower":
- subcomponents = [storage.lower() for storage in choices[5:7]]
- elif component == "Screen":
- if case == "upper":
- subcomponents = choices[7:9]
- elif case == "lower":
- subcomponents = [screen.lower() for screen in choices[7:9]]
- elif component == "Case":
- if case == "upper":
- subcomponents = choices[9:11]
- elif case == "lower":
- subcomponents = [case.lower() for case in choices[9:11]]
- elif component == "USB Ports":
- if case == "upper":
- subcomponents = choices[11:]
- elif case == "lower":
- subcomponents = [usb_port.lower() for usb_port in choices[11:]]
- return subcomponents
- def get_prices_sublist(component):
- if component == "Processor":
- subprices = prices[:3]
- elif component == "RAM":
- subprices = prices[3:5]
- elif component == "Storage":
- subprices = prices[5:7]
- elif component == "Screen":
- subprices = prices[7:9]
- elif component == "Case":
- subprices = prices[9:11]
- elif component == "USB Ports":
- subprices = prices[11:]
- return subprices
- def output_component_info(component, subcomponents, subprices):
- print(component)
- print("Your choices (with prices) are: ")
- for choice, price in zip(subcomponents, subprices):
- print(choice, str(price))
- def get_component_choice(component, subcomponents):
- component_choice: str = input("Make your choice: ")
- while component_choice.lower() not in subcomponents:
- print("That is not a valid choice of " + component)
- component_choice: str = input("Please choose again: ")
- print()
- return component_choice
- def main():
- processor_choices = get_components_sublist("Processor", "upper")
- processor_prices = get_prices_sublist("Processor")
- output_component_info("Processor", processor_choices, processor_prices)
- processor_choices = get_components_sublist("Processor", "lower")
- processor_choice = get_component_choice("Processor", processor_choices)
- ram_choices = get_components_sublist("RAM", "upper")
- ram_prices = get_prices_sublist("RAM")
- output_component_info("RAM", ram_choices, ram_prices)
- ram_choices = get_components_sublist("RAM", "lower")
- ram_prices = get_component_choice("RAM", ram_choices)
- storage_choices = get_components_sublist("Storage", "upper")
- storage_prices = get_prices_sublist("Storage")
- output_component_info("Storage", storage_choices, storage_prices)
- storage_choices = get_components_sublist("Storage", "lower")
- storage_prices = get_component_choice("Storage", storage_choices)
Add Comment
Please, Sign In to add comment