Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I want to get random number from 1 to 6 whenever i run this but i only get 1. from random import randint class die

I want to get random number from 1 to 6 whenever i run this but i only get 1.

from random import randint

class die : def __init__(self): self.value = 1

def roll(self): self.value = randint(1,6)

def getvalue(self): return self.value

def __str__(self): return("the number on the die is {}".format(self.value))

t = die()

print(t)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions