Ask Question
3 November, 21:54

A game rolls a die 10 times and counts how many times the number 5 or 6 shows up.

(a) If there are a total of seven or more times, the win is 2 dollars.

(b) a total of four or more times but less than seven, the win is 1 dollars.

(c) a total of three or less, the win is 0 dollars.

Write a function called payOut that has an input row array of 10 integers representing the ten rolls of dice, and calculates the pay out.

+1
Answers (1)
  1. 3 November, 22:14
    0
    Let's do this in python. We can start by filtering the result by 5 and 6. Then we will count the number of items in the filtered array. Finally, a conditional statement to output the result.

    def payOut (ten_rolls):

    five_or_six = [roll for roll in ten_rolls if roll in [5,6]]

    count_5_or_6 = len (five_of_six)

    if count_5_or_6 > = 7:

    return 2

    elif count_5_or_6 >=4:

    return 1

    else return 0
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “A game rolls a die 10 times and counts how many times the number 5 or 6 shows up. (a) If there are a total of seven or more times, the win ...” in 📗 Engineering if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers