- 1
Need help solving this.
Can anyone solve this? With explanation. 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. 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.
9 Respuestas
+ 7
This Is Am ,
please do *NOT* start a new question inside an existing feed.
> it would be better if you start your own question, because the current discussion started years ago. hence people may not be aware of your question or issue.
+ 6
Ernie Magat , sure - we can solve this. but this not what sololearn is made for. we are a learning platform, but we are not going to do your homework or your sololearn exercises.
Before we will help you, please put your attempt in playground and link it here. if you have not done a try by yourself upto now, please do so. thanks for your understanding!
+ 6
This Is Am ,
according your question:
> what do you mean by saying *why this is not correct?*
> by using a dice, i assume that you expect to get randomly different numbers. in this case we should not use random.seed(...) with same arguments. using
the same argument value for seed will give the always the same result of output number.
> if we omit the argument for seed() or if the argument is *None*, it uses the current system time. this could be used in your case.
+ 2
Here you go. I struggled a lot to solve this problem.
import random #import random module
random.seed(int(input())) #please don't touch this lane
# you dont need separate for loop because this
# statement will work which accept an integer
dice1 = random.randint(1,6)
dice2 = random.randint(1,6)
print(dice1)
print(dice2)
+ 1
import random
random.seed(int(input())) #please don't touch this lane
#generate the random values for every dice
dice1 = random.randint(1,6)
dice2 = random.randint(1,6)
print(dice1)
print(dice2)
+ 1
can anybody post hidden test case for understanding!!!!
+ 1
it's okay, Tank U 👍
0
Thanks, Somnath !
0
Why this not correct ?
import random
random.seed(int(input())) #please don't touch this lane
#generate the random values for every dice
for i in range(6):
value1 = random.randint(1, 6)
value2 = random.randint(1, 6)
dice1 = value1
dice2 = value2
print(dice1)
print(dice2)