0

Trying to solve No dice? No problem in python core

Don't what is wring with my code import random random.seed(int(input())) #please don't touch this lane for i in ramge(n): #generate the random values for every dice dice1 = random.randint(1,6) dice2 = random.randint(1,6) print(dice1) print(dice2)

6th Apr 2021, 12:20 PM
Simisola Osinowo
Simisola Osinowo - avatar
10 odpowiedzi
0
why are you using the loop? are the loops already given in the code? Well, I don't know the use of random.seed() This might work: import random random.seed(int(input())) #please don't touch this lane dice1 = random.randint(1,6) dice2 = random.randint(1,6) print(dice1) print(dice2)
6th Apr 2021, 12:53 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 1
Thanks It worked
6th Apr 2021, 12:56 PM
Simisola Osinowo
Simisola Osinowo - avatar
0
I hope this solves your problem import random #please don't touch this lane n=int(input()) for i in range(n): #generate the random values for every dice dice1=random.randint(1,6) dice2=random.randint(1,6) print(dice1) print(dice2) Just give a no for range of input. Like n=5 Or try this import random #please don't touch this lane n=randim.randint(1,100) for i in range(n): #generate the random values for every dice dice1=random.randint(1,6) dice2=random.randint(1,6) print(dice1) print(dice2)
6th Apr 2021, 12:25 PM
Aditya
Aditya - avatar
0
Both did not work
6th Apr 2021, 12:31 PM
Simisola Osinowo
Simisola Osinowo - avatar
0
Can you give me the question along with the sample input and output?
6th Apr 2021, 12:37 PM
Aditya
Aditya - avatar
0
Two friends want to play backgammon, but have lost the dice. Create a program to replace the dice. When the program is run, it should roll the dice and output the result of each die. Hint Use random.randint() function to generate random values in the range of 1 to 6 for each dice.
6th Apr 2021, 12:39 PM
Simisola Osinowo
Simisola Osinowo - avatar
0
You will see a random.seed(int(input())) line in sample code. It initializes the pseudorandom number generator and, in this case, ensures functionality of test cases.
6th Apr 2021, 12:39 PM
Simisola Osinowo
Simisola Osinowo - avatar
0
But it did not work
6th Apr 2021, 12:47 PM
Simisola Osinowo
Simisola Osinowo - avatar
0
If som is interested in the random.seed(int(input())): https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/ref_random_seed.asp
17th Nov 2021, 9:10 AM
Stefan Bartl
Stefan Bartl - avatar
0
Did anyone got the right code for the above
29th Dec 2021, 10:59 AM
Shalini