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]
8 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]8 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 important are operating system in our devices?​
TiliK225 [7]

Answer:

Explanation:

An operating system is the most important software that runs on a computer. ... It also allows you to communicate with the computer without knowing how to speak the computer's language. Without an operating system, a computer is useless.

6 0
2 years ago
Read 2 more answers
Which quality of service (QoS) mechanism provided by the network does real-time transport protocol (RTP) rely on to guarantee a
Radda [10]

Answer:

The real-time transport protocol (RTP) carries the audio and video data for streaming and uses the real-time control Protocol to analyse the quality of service and synchronisation. The RTP uses the user datagram protocol ( UDP) to transmit media data and has a recommended Voice over IP configuration.

Explanation:

RTP is a network protocol used alongside RTCP to transmit video and audio file over IP networks and to synchronise and maintain its quality of service.

8 0
3 years ago
What is web browser <br>​
xeze [42]
An application used to access and view websites
7 0
3 years ago
Read 2 more answers
Create one of these on your desktop start menu and use it to quickly open a folder, data file, program, or other object?
mario62 [17]
<span>A shortcut is a used to quickly open a folder, data file, program, or other object. They are very convenient to have and make navigating through a computer extremely easy.</span>
3 0
3 years ago
Calculate the shear stress (lbf/in^2) for a given normal stress (lbf/in^2) that is applied to a material with a given cohesion (
LenaWriter [7]

MOHR-COULOMB FAILURE CRITERIA:

In 1900, MOHR-COULOMB states Theory of Rupture in Materials which defines as “A material fails due to because of a critical combination of normal and shear stress, not from maximum normal or shear stress”. Failure Envelope is approached by a linear relationship.

If you can not understand the below symbols see the attachment below

 f   f ()  

Where:      f = Shear Stress on Failure Plane  

       ´= Normal Stress on Failure Plane

 See the graph in the attachment

For calculating the shear stress, when Normal stress, cohesion and angle of internal friction are given. Use this formula:   shear stress =  f  c   tan 

Where,  

• f  is Shear Stress on Failure Plane

• c  is Cohesion

•  is Normal Total Stress on Failure Plane

•  is Friction Angle

8 0
3 years ago
Other questions:
  • In a program called Nature's Notebook, citizen volunteers make and report observations about seasonal changes in plants and anim
    15·1 answer
  • White meat and dark meat fish have slightly different nutritional characteristics. What are the nutrition characteristics of dar
    7·2 answers
  • Pleaseeee help me w this!
    10·1 answer
  • What three things in the third generation of computing helped get programming enthusiasts more involved with computers? Select 3
    12·2 answers
  • Write a short program using Python that will:
    10·1 answer
  • Which is true about lists and stacks?
    8·1 answer
  • When using color in a computer - generated presentation aids you should use?
    7·1 answer
  • Write a program to accept 10 different whole number from the user and store them in a
    11·1 answer
  • Write a function that accepts a positive random number as a parameter and returns the sum of the random number's digits. Write a
    10·1 answer
  • Assume there is a 30-byte heap. The free list for this heap has two elements on it. One entry describes the first 10-byte free s
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!