0

I have been trying but struggling to make a rolling dice simulator in Python that is an assignment for school and am looking for some help for it. These are the instructions:

This project involves writing a program that simulates rolling a dice. When the program runs, it will randomly choose a number between 1 – 6. Have the dice roll 100 times. The program will count if it is a 1 or 2 or 3 or 4 or 5 or 6. After rolling the dice 100 times the program will output how many times each number was rolled. It should then ask you if you’d like to roll again, answer (1 for Yes) and (0 for No).

What you will be Using : Variables Integer Random Print For Loop and/or While Loop

I have two sections of code that I need to loop over:

    import random
    for x in range(100):
       value = random.randint(1, 6)
       print(value)

and:

    value = input("Wanna roll? 1 yes 2 no:\n")
    print(f'You entered {value}')
    y={value}
    while y=1
    print(value)

What is an idiomatic way of doing this in Python?

Allyl Isocyanate
  • 13,306
  • 17
  • 79
  • 130
bokoblin96
  • 11
  • 1
  • 1
    Show us the code you've written so far. – John Gordon Mar 24 '20 at 18:54
  • Welcome to Stack Overflow. Can you please read https://stackoverflow.com/help/how-to-ask for information on asking a question that will lead to a good solution to your problem. In the meantime can you please post what code you have tried so far? – Rashid 'Lee' Ibrahim Mar 24 '20 at 19:00
  • so far i put this but idk if its right – bokoblin96 Mar 24 '20 at 19:07
  • 1
    I would suggest putting the code you've written in the body of your question (using a code block, for readability). If you're just getting started with python, the python tutorial (https://docs.python.org/3/tutorial/index.html) might help; otherwise, if you have a specific python question, make sure that is clear. – baum Mar 24 '20 at 19:08
  • 1
    A previous comment suggested the "how to ask" page. Again, please follwo that protocol. – Prune Mar 24 '20 at 19:09
  • Okay, I added it to the body of the paragraph – bokoblin96 Mar 24 '20 at 19:11
  • Put the 1st code into a function, then call that in the `while` block of the 2nd code and counting how many times you've called it. Repeat the loop *while* the count is not yet 100. See [How do I repeat a program in python?](https://stackoverflow.com/q/41365922/2745495). – Gino Mempin Mar 25 '20 at 04:13
  • Does this answer your question? [How do I repeat the program in python](https://stackoverflow.com/questions/41365922/how-do-i-repeat-the-program-in-python) – Gino Mempin Mar 25 '20 at 04:16

0 Answers0