Roll a dice with python | Dice roller in python | Super simple | S.Raghavapriyan

 Hi guys, in this post I will teach you something interesting. Most of us have played board games.  In this post, I will teach you how to roll a dice in python.


 


The code:
import random
outcomes=['1', '2', '3', '4', '5', '6']
print("The dice has been rolled. The outcome is = ")
print(random.choice(outcomes))
 
Here we have used the random package. It comes with python so there is no need to download
it. Just import it into the program. Now we make a list of outcomes and the package will pick a random number
from the list. That is it. Hope you enjoyed this project. Stay tuned!   
 

Comments