top of page
learn_data_science.jpg

Data Scientist Program

 

Free Online Data Science Training for Complete Beginners.
 


No prior coding knowledge required!

Writer's pictureRohit Roy

Roll A Die

The idea is to play die game using python.To do so we will take help from "Random Library". Random Library will allow us to generate random values which is defined within the limits of user to do so.

Step 1.Import Random Library import random Step 2. Define a Variable

x = "y"

Step 3. Use a loop to define the limits of the values for random function

while x == "y": num = random.randint(1,6)

Step 4. Terminate the loop at users will x=input("Press Y to roll again and N to exit:")


Application

Hence by doing this we will able to play any game which uses die.For example you need next number for snake and ladders is 3 and below is the output which you will see.

[-----] [ ] [0 0 0] [ ] [-----]

Click on the image to check the code.


1 comment

Recent Posts

See All

1 comentário


Data Insight
Data Insight
19 de set. de 2021

What does your code do? Give an example of the use of your code.

Curtir
bottom of page