Given a list of balls = [(Red, 10), (Blue, -20), (Green, 30), (Black, 100), (Yellow, 60), (Cyan, 40), (Brown, 80), (White, 88), (Pink, 10), ()]. Have the user pick 3 colors. Report the total value of the colors picked. The user is allowed to pick repeated colors. Input validation is not required. Write a code for this (PYTHON).
For example,
INPUT:
Pick 3 colors from (Red, Blue, Green, Black, Yellow, Cyan, Brown, White, Pink): Red, Blue, Cyan
OUTPUT:
Your Score is: 30
balls = [("Red", 10), ("Blue", -20), ("Green", 30), ("Black", 100), ("Yellow", 60), ("Cyan", 40), ("Brown", 80), ("White", 88), ("Pink", 10), ()] print("Pick 3 colors from (Red, Blue, Green, Black, Yellow, Cyan, Brown, White, Pink): Red, Blue, Cyan") s = 0 for i in range(3): color = input() for j in range(len(balls)): if len(balls[j])==2 and color == balls[j][0]: s += balls[j][1] print("Your Score is:",s)
Get Answers For Free
Most questions answered within 1 hours.