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]
9 months 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]9 months 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
What kind of testing is basically checking whether a game or feature works as expected by the developers?
Setler [38]
Compatibility testing or functional testing I believe. I’m guessing functional
4 0
3 years ago
Most airlines use very modern hardware and software.<br><br><br> True<br><br> False
torisob [31]
True definitely. They have to use very modern tech in order to make people trust and use them.
3 0
3 years ago
I
Naily [24]

Answer:

True

Explanation:

Not(False) OR False = True OR False = True

4 0
3 years ago
What colorful format should you use to bring attention to an important sentence or phrase
lidiya [134]

Answer:

Highlight

Explanation:

6 0
3 years ago
Now now now now mowewweedeeee
gavmur [86]

Answer:

15

Inside the type declaration, you specify the maximum length the entry can be. For branch, it would be 15.

I can't seem to type the full "vc(15)" phrase because brainly won't let me.

4 0
3 years ago
Other questions:
  • "which part of an information system consists of the rules or guidelines for people to follow?"
    9·1 answer
  • What is your understanding of the difference between a stream cipher and a block cipher?
    14·1 answer
  • Which of the following is the correct code to link the text "Sunny Days" to the website www.sunnysunshine.com?
    15·1 answer
  • What is the rarest Supercar/hypercar you have ever seen?
    7·1 answer
  • How do the principles behind the Agile Manifesto suggest approaching architecture?A. Architecture emergesB. Architecture is not
    10·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    5·1 answer
  • Write programs in python to display “Valid Voter”. (condition : age of person should be
    15·1 answer
  • 8.7 Code Practice: Question 2 edhesive
    14·2 answers
  • What font family is Times New Roman an what font family is Arial?
    9·2 answers
  • What is the difference between EPROM and EEPROM, explain why​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!