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
Arada [10]
1 year ago
14

Write a program that allows a user to choose to roll between 1 and 100 dice between 1 and 1000 times

Computers and Technology
1 answer:
s344n2d4d5 [400]1 year ago
8 0

Answer:

Here is a Python program that allows a user to choose to roll between 1 and 100 dice between 1 and 1000 times. The program uses a while loop to continuously prompt the user for input until they enter a valid number of dice and rolls. It also uses a for loop to simulate the dice rolls and a random module to generate random numbers for the dice rolls.

import random

while True:

   # Prompt the user for the number of dice to roll

   num_dice = int(input("Enter the number of dice to roll (1-100): "))

   if num_dice < 1 or num_dice > 100:

       continue

   # Prompt the user for the number of rolls to perform

   num_rolls = int(input("Enter the number of rolls to perform (1-1000): "))

   if num_rolls < 1 or num_rolls > 1000:

       continue

   # Simulate the dice rolls and print the results

   for i in range(num_rolls):

       roll = 0

       for j in range(num_dice):

           roll += random.randint(1, 6)

       print(f"Roll {i+1}: {roll}")

   # Ask the user if they want to roll again

   again = input("Roll again? (Y/N): ").upper()

   if again != "Y":

       break

Explanation:

In this program, we first import the random module to use its randint function to generate random numbers for the dice rolls. We then enter a while loop that will continuously prompt the user for input until they enter a valid number of dice and rolls. Within the while loop, we prompt the user for the number of dice to roll and the number of rolls to perform. If the user enters an invalid number of dice or rolls, we continue back to the beginning of the loop and prompt the user again.

Once the user has entered a valid number of dice and rolls, we use a for loop to simulate the dice rolls. For each roll, we use another for loop to roll the specified number of dice and add up the results. We then print the total for each roll. After all of the rolls have been performed, we ask the user if they want to roll again. If they enter "Y", we continue back to the beginning of the while loop to prompt them for new input. If they enter anything else, we break out of the while loop and end the program.

Overall, this program allows a user to choose to roll between 1 and 100 dice between 1 and 1000 times, and simulates the dice rolls using random numbers and loops.

You might be interested in
__ provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debu
grin007 [14]

Answer:

java IDE

Explanation:

<h2><u>Fill in the blanks </u></h2>

<u>Java IDE</u> provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debugging, and online help are integrated in one graphical user interface.

7 0
3 years ago
What is the meaning of <br>computer<br>viruses ?​
Brut [27]

Answer:

Viruses are made from people all over the internet these days. they can be made from links you click on or things you download. Some are obvious some are not. gotta be careful on the internet these days!

Explanation:

7 0
3 years ago
You want to establish the validity of a test designed for computer technicians using a predictive criterion-related validation s
fgiga [73]

Answer:

(C) people applying for computer technician jobs in your company.

Explanation:

According to my research on information technology, I can say that based on the information provided within the question in order to establish the validity of the test you should give the test to people applying for computer technician jobs in your company. Then examine and compare their score with their job performance if hired.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

6 0
3 years ago
Marissa, a 21-year-old young woman, is working as an intern at a software company. She has recently graduated from college. She
Zigmanuir [339]

Answer:

She is experiencing the features of feeling in between.

Explanation:

Because she graduated from college currently and she thinks about moving seriously with her boyfriend or best friend and she also thinks about the convenience and safety which she gets in her parents' house. She confused because she is not completely in the adult stage and currently, she passed through from the stage of adolescence, so that's why she experiencing feeling in between.

3 0
4 years ago
Write a function called show_info that takes a name, a home city, and a home state (a total of 3 arguments) and returns a full s
Delicious77 [7]

Answer:

Below are the function for the above question in java Language---

void show_info(String name,String home,String state)

    {

        System.out.println("Your name is "+name+" and you live in "+ home+" ,"+state +".");

    }

Output:

  • If the user inputs name="Gaus",city="LosAngeles" and state="California" then the output will be "Your name is Gaus and you live in LosAngeless, California."

Explanation:

  • The above function is in java language which takes three argument names, state, and the city.
  • The name will be stored on the name variable of the string type.
  • The state will be stored on the state variable of string type.
  • The city will be stored on the city variable of the string type.
  • Then the Output will be displayed with the help of the print function.
  • '+' is used to merge the string.
5 0
3 years ago
Other questions:
  • A type of font that has a decorative tail is A.Serif font B. Sans serif font C. Bubbles font D. Reading font
    7·1 answer
  • The inner planets are called terrestrial because they
    11·2 answers
  • Developers and organizations all around the world leverage ______ extensively.
    9·2 answers
  • Let’s say you are given a number, a, and you want to find its square root. One way to do that is to start with a very rough gues
    15·1 answer
  • How do you use a iPad when it has a password ?
    9·2 answers
  • To generate a report with exact results based on specific criteria it is best to base the report on a(n) ____________________ cr
    6·1 answer
  • Which programming language represents data in the form of a series of zeros and ones​
    7·1 answer
  • Differences between formula and function as used in spreadsheet​
    13·1 answer
  • Away message:
    14·2 answers
  • A new printer has recently been installed in the office, but it does not print. What is the first source to check for informatio
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!