Advertisement
earlution

(std) Task 1 - part 3

Nov 4th, 2021
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 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.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement