|
| 1 | +# find the favorite food based on the score |
| 2 | + |
| 3 | +food = ['donuts', 'pancakes', 'bacon', 'waffles', 'eggs', 'bagels'] |
| 4 | +score = [0, 0, 0, 0, 0, 0] |
| 5 | + |
| 6 | +d = {'donuts': 0, 'pancakes': 0, 'bacon': 0, 'waffles': 0, 'eggs': 0, 'bagels': 0} |
| 7 | + |
| 8 | +print("Answer y for yes and n for no.") |
| 9 | +user_input = input("Do you like foods with holes? ") |
| 10 | +if user_input == 'y': |
| 11 | + score[0] = score[0] + 1 |
| 12 | + score[5] = score[5] + 1 |
| 13 | + d["donuts"] += 1 |
| 14 | + d["bagels"] += 1 |
| 15 | +user_input2 = input("Do you like food that usually come with syrup?") |
| 16 | +if user_input2 == 'y': |
| 17 | + d["bacon"] += 1 |
| 18 | + d["eggs"] += 1 |
| 19 | +user_input3 = input("Does your food have red and white? ") |
| 20 | +if user_input3 == 'y': |
| 21 | + d["waffles"] += 1 |
| 22 | + |
| 23 | +user_input4 = input("Does your food start with a b?") |
| 24 | +if user_input4 == 'y': |
| 25 | + d["bagels"] += 1 |
| 26 | +user_input5 = input("Does your food have yolk in it?") |
| 27 | +if user_input5 == 'y': |
| 28 | + d["eggs"] += 1 |
| 29 | +user_input6 = input("Does your food have a smooth surface without holes?") |
| 30 | +if user_input == 'y': |
| 31 | + d["pancakes"] += 1 |
| 32 | + |
| 33 | +print("score list of food is:", score) |
| 34 | +sorted_food = sorted(d.items(), key=lambda t: t[1], reverse=True) |
| 35 | + |
| 36 | +rank = 1 |
| 37 | +print("Your Favorite food in order of score is : ") |
| 38 | +print("rank, Food, score") |
| 39 | +for ele in sorted_food: |
| 40 | + print(rank, ele[0], ele[1]) |
| 41 | + rank += 1 |
0 commit comments