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
Anyone know why my desktop won’t turn on, I upgraded my ram and my monitor won’t turn on
Kay [80]

Answer:

RAM Slots

Explanation:

RAM is most probably in the wrong slots.

Check BIOS

Check with Motherboard User Manual.

7 0
2 years ago
To change the print orientation from portrait to landscape, tap or click the ____ button on the print preview tab.
lianna [129]
<span>In certain instances, it makes sense to print documents in landscape orientation. Some examples include spreadsheets and tables, where the content within the document is wider than it is longer. If you print in portrait mode, it would cut off parts of the table or spreadsheet. In this case, you'll want to change the print settings to landscape. To change it to landscape, simply click the "landscape" button on the print preview tab.</span>
4 0
3 years ago
Select the correct answer.
Bess [88]

Answer:

equals operator...............

6 0
3 years ago
A website whose URL ends with .gov, .edu, or .org is necessarily a reliable source. True or False
natali 33 [55]
True because they are educational anything .com and sometimes .net because .gov is from the government so it is very safe to use and .edu is for education it is always used to help people with education etc and .org is   public which other people can say false and save you from false information
7 0
3 years ago
Character literals are enclosed in ________; string literals are enclosed in ________. Group of answer choices double quotes; do
adelina 88 [10]

Answer:

Single quotes; Double quotes

Explanation:

Character literals is a type of literal in Java programming used for denoting constant valued character. Examples are 'g', '6', 'A' '+' etc.

String literals is a type of literal in Java programming used for representing or displaying of a sequence of characters or string values. Examples are "Hello Brainly user"

In Java programming, Character literals are enclosed in single quotes, string literals are enclosed in double quotes.

7 0
3 years ago
Other questions:
  • Whereas lines of competition are clearly defined in the more established industries, in the Internet industry they are blurred a
    9·1 answer
  • What term is used to describe a function that uses an algorithm to convert an input of letters and numbers into an encrypted out
    9·1 answer
  • Write a function max arguments. write a program that reads three floating-point numbers, uses the max function, and displays the
    5·1 answer
  • The manager of a sports club has data about the club members' ages in a workbook. He wants to find which age is most common. Whi
    13·2 answers
  • Yahoo and Google are examples of __________ used to perform Internet research.
    14·2 answers
  • Which is better analog music or digital music
    15·2 answers
  • In the ____________________ approach, the project is initiated by upper-level managers who issue policy, procedures and processe
    8·1 answer
  • Write a program that prompts the user to input five decimal numbers. The program should then add the five decimal numbers, conve
    5·1 answer
  • Assume that sentence is a variable that has been associated with a string consisting of words separated by single space characte
    5·1 answer
  • Your program will be used by many departments at the university. Your comments will be important to their IT people. What would
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!