1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
bonufazy [111]
2 years ago
14

Write a function named dice_eval that accepts two parameters representing numeric dice values and returns a string describing th

e results. If the sum of the dice is 7 or 11, return 'Winner!'. If the sum of the dice is 2, 3, or 12, return 'Crxps!'. For all other values, return a string of the form 'Point is xx', where xx is the sum.
Computers and Technology
1 answer:
Zigmanuir [339]2 years ago
4 0

Following are the "dice_eval" method code into python language.

Program Explanation:

  • Defining a method "dice_eval" that takes two variables "d1,d2" in its parametes.
  • Inside the method, multiple conditional statements were used that adds the parameter values and calculates its value which can be defined as follows:
  • In the if block, it adds the parameters and uses or gate that check its value that is equal to 7 or 11. so, it will return a string message that is 'Winner!'.  
  • In the elif block, it adds the parameters and uses or gate that check its value that is equal to 2 or 3 or 12. so, it will return a string message that is ' C r aps ! '.
  • In the else block, it uses a return keyword that adds parameter value and prints a string value.
  • Outside the method "d1,d2" is declared that inputs the value from the user-end, and passes the value into the method, and prints its value.

Program:

def dice_eval(d1, d2):#defining a method dice_eval that takes two parameters

if (d1+d2)==7 or (d1+d2)==11:#defining if block that adds parameter value and use or operator to check its value

return 'Winner!'#return string value

elif (d1+d2)==2 or (d1+d2)==3 or (d1+d2)==12:#defining elif block that adds parameter value and use or operator to check its value

return 'C r aps!'#return string value

else:#defining else block

return 'Point is '+str(d1+d2)#return string value with adding parameter

d1=int(input())#defining d1 that input value

d2=int(input())#defining d2 that input value

print(dice_eval(d1,d2))#calling method and print its return value

Output:

Please find the attached file

Please find the complete code in the attached file.

Learn more:

brainly.com/question/15011927

You might be interested in
Enables you to temporarily hide all the open windows except the one you are viewing.
solniwko [45]
Minimizing the other windows or full screen the one your looking at with F11 button
7 0
3 years ago
How do you optimize a website using JavaScript?
GenaCL600 [577]
You can edit the website (using Wordpress) -if it is your website of course-, and code JavaScript commands into the page that’s going to be uploaded.

Check out my website: www.birdbloggersblog.com

I coded that with HTML.
4 0
2 years ago
Lesson 9 looping and random numbers
Pavlova-9 [17]

Answer:

??????????????????????????????????????????////

Explanation:

8 0
2 years ago
How many feet do you have to stop away from a school bus
mr_godi [17]
You are required by law to stop twenty feet away from a school bus when driving.
7 0
2 years ago
Write the code for invoking a method named sendVariable. There is one int argument for this method. Assume that an int variable
malfutka [58]

Answer:

The code to this question is "sendVariable(x);".

Explanation:

The explanation of the (method calling) code can be given as:

  • In the question, it is defined that there is a method that name is "sendVariable()". In this method, we pass an integer variable that is "x".
  • The variable x value is already declared and assigned and this variable is passed in the method.
  • This method is defined in the same class so the code for calling this method is "sendVariable(x);".

6 0
2 years ago
Other questions:
  • Ben uses a table that has few columns. He knows about a particular value in the first column and wants to find the corresponding
    8·2 answers
  • What is the key benefit of using RAM in a computer?
    12·1 answer
  • I stole you pokemon cards :o
    6·2 answers
  • How do you copy and paste plz let me know
    14·2 answers
  • What happens when the programmer tries to access an array cell whose index is greater than or equal to its logical size?
    7·1 answer
  • Previous
    11·1 answer
  • _________________ allows cloud controller to locate instances on separate zones to boost redundancy.
    14·1 answer
  • Fill in the word to complete the sentence.
    10·1 answer
  • Help! What is this graph and what does it represent?
    12·1 answer
  • Noi needs to send some documents to a client in another company. Which device can she use to make digital copies of the paper fi
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!