Since you love games of chance, you've decided to participate in a dice-rolling competition. The competition involves rolling three 6-sided dice, and the results of each die are represented by the integers a, b, and c respectively. Scores are calculated according to the following rules:
If all three dice had the same value (a = b = c) then you earn 1000 * a.
If exactly two of them are the same, you earn 500 * x (where x is the value of the two equal dice).
If all of them are different, you earn 100 * min(a, b, c).
Given the values of a, b, and c, your task is to calculate and return your total score.
Example
For a = 3, b = 3, and c = 3, the output should be diceTotalScore(a, b, c) = 3000.
Since all of the dice have the same value, your total score is equal to 1000 * 3 = 3000.
For a = 3, b = 6, and c = 3, the output should be diceTotalScore(a, b, c) = 1500.
Since exactly two of the values are the same (a = c = 3), your total score is equal to 500 * 3 = 1500.
For a = 3, b = 2, and c = 5, the output should be diceTotalScore(a, b, c) = 200.
Since all of these values are different, your total score is equal to 100 * min(a, b, c) = 100 * 2 = 200.
Input/Output
[execution time limit] 4 seconds (py3)
[input] integer a
An integer representing the value of the first die.
Guaranteed constraints:
1 ≤ a ≤ 6.
[input] integer b
An integer representing the value of the second die.
Guaranteed constraints:
1 ≤ b ≤ 6.
[input] integer c
An integer representing the value of the third die.
Guaranteed constraints:
1 ≤ c ≤ 6.
[output] integer
Return your total score
Pleasee use Python
def diceTotalScore(a, b, c):

Respuesta :

Answer:

See attachment for complete program

Explanation:

This imports the random module

import random

The function begins here

def diceTotalScore(a, b, c):

This checks if the outcome of the three dice are the same

    if [tex](a == b == c):[/tex]

         earnings = 1000 * a --->The earnings for this condition is calculated

This checks if the outcome of two dice are the same

    elif [tex]((a == b) or (a == c) or (b == c)):[/tex]

The following sub conditions checks for the outcomes that are the same

         if [tex](a == b):[/tex]

              [tex]x = a[/tex]

         elif [tex](a == c):[/tex]

              [tex]x = a[/tex]

         elif [tex](b == c):[/tex]

              [tex]x = b[/tex]

         earnings = 500 * x --->The earnings for this condition is calculated

This checks if no outcome are the same

    else:

         earnings = 100 * min(a,b,c) --->The earnings for this condition is calculated

The function returns then returns earnings    

    return earnings

The main begins here

The next three lines simulate the rolls of three dice

a = random.randint(1,6)

b = random.randint(1,6)

c = random.randint(1,6)

This calls the TotalScore function and returns the earnings

print("Earnings: "+str(diceTotalScore(a, b, c)))

Ver imagen MrRoyal