earlution

(adv) Task 1 - part 2

Nov 4th, 2021 (edited)
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.78 KB | None | 0 0
  1. components = ("Processor",
  2.               "RAM",
  3.               "Storage",
  4.               "Screen",
  5.               "Case",
  6.               "USB ports")
  7. choices = ("P3",
  8.            "P5",
  9.            "P7",
  10.            "16GB",
  11.            "32GB",
  12.            "1TB",
  13.            "2TB",
  14.            "19\"",
  15.            "23\"",
  16.            "Mini Tower",
  17.            "Midi Tower",
  18.            "2 ports",
  19.            "4 ports")
  20. prices = (100, 120, 200, 75, 150, 50, 100, 65, 120, 40, 70, 10, 20)
  21.  
  22.  
  23. def get_components_sublist(component, case):
  24.     if component == "Processor":
  25.         if case == "upper":
  26.             subcomponents = choices[:3]
  27.         elif case == "lower":
  28.             subcomponents = [processor.lower() for processor in choices[:3]]
  29.     elif component == "RAM":
  30.         if case == "upper":
  31.             subcomponents = choices[3:5]
  32.         elif case == "lower":
  33.             subcomponents = [ram.lower()  for ram in choices[3:5]]
  34.     elif component == "Storage":
  35.         if case == "upper":
  36.             subcomponents = choices[5:7]
  37.         elif case == "lower":
  38.             subcomponents = [storage.lower()  for storage in choices[5:7]]
  39.     elif component == "Screen":
  40.         if case == "upper":
  41.             subcomponents = choices[7:9]
  42.         elif case == "lower":
  43.             subcomponents = [screen.lower()  for screen in choices[7:9]]
  44.     elif component == "Case":
  45.         if case == "upper":
  46.             subcomponents = choices[9:11]
  47.         elif case == "lower":
  48.             subcomponents = [case.lower()  for case in choices[9:11]]      
  49.     elif component == "USB Ports":
  50.         if case == "upper":
  51.             subcomponents = choices[11:]
  52.         elif case == "lower":
  53.             subcomponents = [usb_port.lower()  for usb_port in choices[11:]]        
  54.     return subcomponents
  55.  
  56.  
  57. def get_prices_sublist(component):
  58.     if component == "Processor":
  59.         subprices = prices[:3]
  60.     elif component == "RAM":
  61.         subprices = prices[3:5]
  62.     elif component == "Storage":
  63.         subprices = prices[5:7]
  64.     elif component == "Screen":
  65.         subprices = prices[7:9]
  66.     elif component == "Case":
  67.         subprices = prices[9:11]
  68.     elif component == "USB Ports":
  69.         subprices = prices[11:]
  70.     return subprices
  71.  
  72.  
  73. def output_component_info(component, subcomponents, subprices):
  74.     print(component)
  75.     print("Your choices (with prices) are: ")
  76.     for choice, price in zip(subcomponents, subprices):
  77.         print(choice, str(price))
  78.    
  79.        
  80. def main():
  81.     processor_choices = get_components_sublist("Processor", "upper")
  82.     processor_prices = get_prices_sublist("Processor")
  83.     output_component_info("Processor", processor_choices, processor_prices)
  84.     processor_choices = get_components_sublist("Processor", "lower")
  85.  
  86.  
  87.  
  88.  
  89.    
  90.    
  91.  
Add Comment
Please, Sign In to add comment