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
Lana71 [14]
3 years ago
5

Write a Python programs to do frequency counting of the sum of two dice. Your function should accept an integer n parameter to r

un n trials (i.e., multiple rollings of the two dice); You can use the Python function randrange(1, 7) to simulate the roll of one die; After running the n trials, your function should return the sum of two dice that occurs most frequently.
Computers and Technology
1 answer:
NARA [144]3 years ago
4 0

Answer:

Explanation:

The following program uses Numpy import to detect the frequency of all the elements in an array and ouput the one that appears the most. The function creates random dice rolls and adds them to the array, looping the number of times that the trials parameter states. Then finally printing out the original array and the sum that appeared the most frequently.

from random import randrange

import numpy as np

def highestFrequency(trials):

   products = []

   for x in range(trials):

       product = randrange(1, 7) * randrange(1, 7)

       products.append(product)

   x = np.array(products)

   print("Original Array: " + str(list(products)))

   print("Most frequent value in the above array:")

   print(np.bincount(x).argmax())

highestFrequency(7)

You might be interested in
Which model represents scenarios thatchange over time?
Alex17521 [72]

Answer: Dynamic models represents scenarios that changes over time.

Explanation:

As, dynamic model is used to represent the scenarios and the behavior of an object or structure over time. It is used to describe the one or more elements over the time as a set of states that occurred in a proper sequence. Dynamic model is the simple representation of real world entity.

7 0
3 years ago
What is another name for an unmanaged switch?
Natalka [10]

Answer:

The answer is "Plug and play".

Explanation:

A switch with minimum debugging tools for log-and-play simplicity and also no IP address. The Unmanaged switches are cost-effective and also have limited power, and other choices are not correct, which can be described as follows:

  • Fast Ethernet provides 10 to 100 Mbps speeds, that's why it is not correct.
  • Gigabit provides bandwidth, which is up to 1 Gbps speed, and it is 10 times faster than Ethernet Fast, that's why it is wrong.
  • The trunk provides the link design that's why it is not correct.
7 0
3 years ago
What is the value of the variable answer after the following code is executed?
Nitella [24]

Answer:

false

Explanation:

8 0
3 years ago
Why is experience in their own factory setting
Nataly [62]

Answer:

How to Manage Manufacturing Operations Effectively

Ensure High-Quality Products. ...

Ensure High-Quality Equipment. ...

Know How To Maximize Resources. ...

Look Into Technological Advancements. ...

Check Your Customer Service. ...

Consider Reducing Waste. ...

Conclusion.

Explanation:

5 0
3 years ago
Write a recursive method to return the number of uppercase letters in a String. You need to define the following two methods. Th
satela [25.4K]

Answer:

<u>Recursive function with two parameters that return the number of uppercase letters in a String</u>

public static int count(String str,int h)//Defining function

{

      if(str.charAt(0)>='A' && str.charAt(0)<='Z')//Checking the characters from A to Z

{

          h++; //incrementing the counter

          if(str.length()>=2){

              return count(str.substring(1),h);//recalling function

          }

      }

      if(str.length()>=2){

              return count(str.substring(1),h); //recalling function

      }

      return h;

  }

This is the recursive function with the name count of return type integer,having parameters str of string type and h of integer type.In this we are checking the characters at a particular position from A to Z.

<u>Recursive function with one parameter that return the number of uppercase letters in a String</u>

public static int count(String str)//Defining function

{

      if(str.charAt(0)>='A' && str.charAt(0)<='Z')//Checking the characters from A to Z

{

          count++; //incrementing the counter

          if(str.length()>=2){

              return count(str.substring(1));//recalling function

          }

      }

      if(str.length()>=2){

              return count(str.substring(1)); //recalling function

      }

      return count;

  }

This is the recursive function with the name count of return type integer,having parameters str of string type .In this we are checking the characters at a particular position from A to Z.

<u>Java program that return the number of uppercase letters in a String</u>

import java.util.*;

public class Myjava{

static int count =0;//Defining globally  

 

public static int count(String str,int h)//Defining function

{

      if(str.charAt(0)>='A' && str.charAt(0)<='Z')//Checking the characters from A to Z

{

          h++;

//incrementing the counter

          if(str.length()>=2){

              return count(str.substring(1),h);//recalling function

          }

      }

      if(str.length()>=2){

              return count(str.substring(1),h);

//recalling function

      }

      return h;

 

  }

  public static void main(String[] args)//driver function

  {

      System.out.println("Enter a string");//taking input

      Scanner scan = new Scanner(System.in);

      String s = scan.nextLine();

      int h =0;

      System.out.println("Counting the Uppercase letters: "+count(s,h));

  }

}

<u>Output</u>

Enter a string  WolFIE

Counting the Uppercase letters: 4

4 0
3 years ago
Other questions:
  • What is Gamekit Loa3's all questsions
    14·1 answer
  • Tomi is testing all of the links on her web page by clicking on each one in a browser. What type of testing is this considered?
    6·2 answers
  • Suppose you have an int variable called number. What Java expression produces the second-to-last digit of the number (the 10s pl
    13·1 answer
  • Please help me ! All you do is just put it it all in your own words ! Please this is for my reported card!i don't know how to pu
    15·1 answer
  • Indicate whether the scenario below is safe or unsafe : when storing a flammable liquid, you decide to separate it from other ma
    9·1 answer
  • A new company will have 40 workstations in one building sharing a single network. All users must be able to share files and prin
    9·1 answer
  • Any device that uses light to read and write information.
    9·2 answers
  • The space that helps you organize your PowerPoint or Web Page is called ______.
    13·1 answer
  • Which three IP addresses may be pinged by the Test Management Network feature in the ESXi hosts DCUI
    12·1 answer
  • Which programming language in order takes the most lines code​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!