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
andrezito [222]
3 years ago
12

Create a function that should simulate a game involving the rolling of a standard six-sided dice between two players. The functi

on takes in the integer number of rounds, which corresponds to how many games to play. Each game consists of both players rolling the dice five times each, whichever player has the highest average die roll from their five rolls wins the round.
Computers and Technology
1 answer:
Law Incorporation [45]3 years ago
4 0

Answer:

import random

def roll_dice(r):

   score1 = 0

   score2 = 0

   for i in range(r):

       for j in range(5):

           score1 += random.randint(1,6)

           score2 += random.randint(1,6)

           

       avg1 = score1/5

       avg2 = score2/5

       

       if avg1 > avg2:

           print("Player1 won the " + str(i+1) + ". round ")

       elif avg1 < avg2:

           print("Player2 won the " + str(i+1) + ". round ")

       else:

           print("Tie")

       

       score1 = 0

       score2 = 0

           

roll_dice(3)

Explanation:

Import the random module

Create a function called roll_dice that takes one parameter r

Initialize two scores as 0 for the players

Create a nested for loop. The outer loop will simulate the rounds and inner loop will simulate the each roll.

Inside the inner loop which iterates five times, generate random numbers for two players and add these numbers to their score.

When the inner loop is done, calculate the average score of the players. If the first average is greater, player1 wins the round. If the second average is greater, player2 wins the round. Otherwise, it is a tie. Also, set the scores to zero so that they start again.

Call the function with parameter 3, simulating 3 rounds

You might be interested in
Example 4-1: The styles for the main content of an HTML document main { clear: left; } main h1 { font-size: 170%; } main h2 { fo
jek_recluse [69]

Answer:

The clear property stops floating of the main element to the right of the preceding block elements

Explanation:

The clear property specifies that which sides of the elements floating element are not allowed to be float.

It returns or sets the positions of an element in relation to the floating objects. If an element can be fitted horizontally in space next to other elements which is floated.

Syntax:

clear: none | left | right | both | initial;

6 0
3 years ago
A user asks for a checkbox to be automatically ticked if the annual revenue field is greater than a million. Which formula to tr
Otrada [13]

Answer:

AnnualRevenue > 1000000

Explanation:

First, represent the field for annual revenue with AnnualRevenue

From the question, we understand that this field must be greater than 1000000 before a certain action can be performed.

Base on the given condition, the formula that triggers this action is: AnnualRevenue > 1000000

<em>Further explanation is in the attachment</em>

<em></em>

<em>From the attachment, we have that:</em>

If the condition is true, the checkbox be ticked

However, if the condition is false; the checkbox remain unchanged because no specific action is stated for this, in the question.

<em></em>

6 0
3 years ago
The _______ dialog box displays formatting tabs for Font, Number, and Alignment
statuscvo [17]

Answer:

The <u>Format Cells</u> dialog box displays formatting tabs for Font, Number, and Alignment

Explanation:

In MS Excel, Format Cells dialog box option, we found the following formatting tabs:

  • Number
  • Font
  • Alignment

To access the format cells dialog box, we follow the following steps.

  1. In MS Excel, Right click in Cell that needs formatting
  2. A drop down menu Show, Click on Format Cells option from the list.
  3. A dialog box appears that have different tabs of Number, Font, Alignment and protection
  4. Select the tab, where you want to change the format.

5 0
3 years ago
Marie wanted to make sure that the information in her presentation was well organized. She should _____.
Sauron [17]
Marie could either ask a friend or her parents to peer edit it and tell her if its good enough or if she should work on it more.<span />
4 0
3 years ago
What is abstraction and how does it relate to how computers store information?
Anton [14]

Answer:

Definition - What does Abstraction mean?

Abstraction is a fundamental principle in some types of computer science. It is a key design aspect of object-oriented programming languages and application programming interfaces. It's also one of the least understood ideas in programming, partially for semantic reasons.

PLEASE MARK BRAINLIEST

Abstraction is commonly defined as the extraction of relevant information from a larger data set, where utilizing abstraction allows engineers and others to simplify a codebase.

Techopedia explains Abstraction

The reason this is confusing to many people is that abstraction doesn't “sound like” what it is, semantically. It sounds like making something more vague, because that's how we use it in general language.

However, in computer science, abstraction typically means simplification and separating the signal from the noise in order to make programming more efficient and effective.

Explanation:

3 0
4 years ago
Read 2 more answers
Other questions:
  • What are the tiny little dots that make up a digital photograph?
    8·2 answers
  • Given that it takes 0.08 ms to travel from one track to the next of a hard drive; that the arm is originally positioned at Track
    6·1 answer
  • You are setting up a RAID system in a server designed for optimum fault tolerance, accuracy, and minimal downtime. Which HDD is
    7·1 answer
  • what are the Technologies in regarding of communication technology? Please help me I'll rate you as brainliest!​
    13·1 answer
  • According to what theory did the universe expand explosively into existence 13.7 billion years ago?
    13·2 answers
  • to minimize wrist injury switch frequently among touch gestures the keyboard and the mouse true or false
    15·1 answer
  • What are the "..........." called leading up to a page number?
    14·1 answer
  • What is the Purpose and function of the Global Positioning System (GPS)?
    7·1 answer
  • Use a for/else loop to traverse through the key names in the dictionary below in order to find Mr. Potatohead’s mailing address.
    7·1 answer
  • What percentage of teens say they have witnessed cyberbullying?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!