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
topjm [15]
3 years ago
13

Define a function dice(n) that returns the sum of a random roll of n 6-sided dice. Example output in photo. Thank you

Computers and Technology
1 answer:
leonid [27]3 years ago
6 0

Answer:

code (in python) is in the explanation

Explanation:

import random

def dice(n):

   count = 1

   t = list()

   while count <= n:

       i = random.randint(1,6)

       t.append(i)

       count += 1

   print(sum(t))

Hope this helps!

You might be interested in
Write a class named Averager containing: An instance variable named sum of type integer, initialized to 0. An instance variable
vladimir1956 [14]

Answer:

The answer to this question can be given as:

Class definition:  

public class Averager  //define class Average.

{

private int sum = 0;

 //define variable sum.

private int count = 0;

 //define variable count.  

public int getSum() //define function getSum().

{

return sum;  //return value.

}

public void add(int x)

//define function add().

{

sum = sum + x;   //calculate sum

count=count+1; //increase value of count.

}

public int add(int x)

 //define function add().

{

return count;  //return value.

}

public double getAverage()  //define function getAverage().

{

return (double)sum/count;  //return value

}

}

Explanation:

The above class definition can be described as:

  • In the above class definition first we define a class that is " Averager". In this class we define two integer variable  that is "sum and count"  and assign a value that is 0. Then we define a functions :
  • First we define getSum() function in this function we does not pass any value and the return type of this function is int that will return an integer value.
  • Then we define add() function we use this function two times but both functions have different from each other.  
  • In first time implementation, we define this function and the return type of this function is void which means it does not return any value. In this function, we calculate the sum value and increase the value of the count variable by 1.  
  • In second time implementation, we define this function and the return type of this function is int which means it will return a value. In this function, we will return the count variable value.
  • At the last, we define a getAverage() that calculates the average of the added values in the sum variable and returns its value.
3 0
3 years ago
What do you mean by hardware and software?<br>​
rusak2 [61]

Answer:

I think the above information will help you a lot.

Have a nice day.

7 0
3 years ago
Read 2 more answers
Which osi layer is responsible for combining bits into bytes and bytes into frames?
Nastasia [14]
If you are breaking the computer down try in software it does change after a while
3 0
3 years ago
In which career field, would the Computing Technology Industry Association's CompTIA A+ certification be useful?
Anna [14]
It's geared towards system administration but would also be useful for devops.
5 0
4 years ago
A colleague asks you to research a CPU for a new server that will run Windows Server 2019. He explains the server roles that he
SashulF [63]

Answer:

a

Explanation:

just gesing

3 0
3 years ago
Other questions:
  • When computers are connected and operate through one main computer, it is called a _________ network
    14·2 answers
  • Why are computer programs so much longer now than they were in the late 1980?
    8·1 answer
  • What is credibility in the often-used framework of quality criteria?
    9·1 answer
  • Rachel wants to post content from digital cameras on the web. Which online tool will help Rachel to post and edit content on a w
    5·1 answer
  • What component of a processor handles all logical comparisons and calculations inside the processor?
    9·1 answer
  • The current standard for RFID is based off of Group of answer choices MIT standards IEEE standards ISO standards there is no agr
    12·1 answer
  • Send me the answers<br>​
    15·1 answer
  • What does l m a o actually mean?
    6·1 answer
  • Compute the average of a list of user-entered integers representing rolls of two dice. The list ends when 0 is entered. Integers
    12·1 answer
  • A security event popped up, alerting security of a suspicious user gaining access to, and copying files from, the %systemroot%\n
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!