Advertisement
earlution

(std) Task 1 - part 4

Nov 4th, 2021
1,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.95 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 choose_set(component, choice, price):
  24.     print("Your choice was: ", components[component], choices[choice], prices[price])
  25.  
  26.  
  27. def output_processor_info():
  28.     #output for user
  29.     print("Processors")
  30.     print("Your choices are: ")
  31.     for choice in choices[:3]:
  32.         print(choice)
  33.     print("The prices are: ")
  34.     for price in prices[:3]:
  35.         print(price)    
  36.  
  37.  
  38. def choose_processor():  
  39.     #create a sublist of processors formatted to lowercase
  40.     processors = []
  41.     for processor in choices[:3]:
  42.         processors.append(processor.lower())
  43.  
  44.     #input validation
  45.     processor_choice = input("Make your choice: ")
  46.     while processor_choice.lower() not in processors:
  47.         print("That is not a valid choice.")
  48.         processor_choice = input("Please choose again: ")
  49.     print()
  50.    
  51.     return processor_choice
  52.  
  53.  
  54. def output_ram_info():
  55.     #output for user
  56.     print("RAM")
  57.     print("Your choices are: ")
  58.     for choice in choices[3:5]:
  59.         print(choice)
  60.     print("The prices are: ")
  61.     for price in prices[3:5]:
  62.         print(price)    
  63.  
  64.  
  65. def choose_ram():  
  66.     rams = []
  67.     for ram in choices[:3]:
  68.         rams.append(ram.lower())
  69.  
  70.     ram_choice = input("Make your choice: ")
  71.     while ram_choice.lower() not in rams:
  72.         print("That is not a valid choice.")
  73.         ram_choice = input("Please choose again: ")
  74.     print()
  75.    
  76.     return ram_choice
  77.  
  78. #PART 4 TODO - all other choose_component() functions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement