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]
10 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]10 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
How does a color change if you add more gray to it
Tom [10]
Gray isn't a color to be exact it a shade or what some people call it a shadow just like black but if you add more gray to a look lets say RED it will make it kinda faddy and more darker then it was

6 0
3 years ago
Special computers, called __________, keep databases of IP addresses and their corresponding names
vitfil [10]
Name servers.
-----------------------------------------------------------
4 0
3 years ago
Set-In-Order includes making changes to the layout of the area.A) TrueB) False
Bogdan [553]

Answer:

A) True

Explanation:

Set-In-Order is part of a 5S system approach of making a workplace to be well arranged so there will be smooth operation of employees and working conditions.

Set-In-Order specifically deals with entities in the workplace apparently labeled after being well arranged in their respective places.

Hence, it is TRUE that Set-In-Order includes making changes to the layout of the area.

7 0
3 years ago
Which of the following is not true of hardware VPNs?A) should be the first choice for fast-growing networks.B) can handle more t
vfiekz [6]

Answer:

C) have more security vulnerabilities than software

Explanation:

Hardware VPN is a computer term that described a separate tool that serves the functions of a virtual private network. It has its own component and an internal processing unit.

However, some of the characteristics of Hardware VPN is the following:

1. It is expensive compared to software VPN

2. It is generally faster

3. It requires more than a beginner to handle

4. With an in-built firewall, it is generally more secure compared to a software VPN.

Hence, in this case, the correct answer is option C.

3 0
3 years ago
A short
alexandr402 [8]

Explanation:

Java Bitwise Operators

Operator Description Example

>> (right shift) Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. A >> 2 will give 15 which is

8 0
3 years ago
Other questions:
  • Chloe is building a kiosk-based Excel application. She wants to make some modifications to the screen elements in order to keep
    8·1 answer
  • A disadvantage of creating a website with tables, without CSS is
    15·2 answers
  • What tab must you click on to view any previously read messages from instructors in the message center?
    14·2 answers
  • Which of the four basic functions of a computer refers to the collection of data by a computer?
    11·2 answers
  • By Carl Sandburg
    6·1 answer
  • Write a program that lets a maker of chips and salsa keep track of sales for five different types of salsa: mild, medium, sweet,
    14·1 answer
  • In the list [0, 13, 5.4, "integer"], which element is at index 2?
    11·1 answer
  • What dd command would you use to copy the contents of a partition named /dev/drive1 to another partition, called /dev/backup?
    6·1 answer
  • What does a for loop look for in the sequence of data? Check all that apply.
    6·2 answers
  • What is the best way of farming exotics in destiny?
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!