1
I am a beginner in programming and I have the following situation:
I have a class called TEST. Within this class has the function RANDOM.
I have a second class called CHECK. Inside this class has the CHECK function.
I want the output of the TEST.RANDOM function to be used in the CHECK function.CHECK.
In the code below every time I run the function CHECK.VERIFIES it calls again the function TEST.RANDOM, which ends up bringing me a new value.
How do I REUSE the output of the TEST.RANDOM function?
=========
import random
class teste():
def __init__(self, x = 0):
self.x = x
def aleatorio(self):
a = random.randint(0,100)
return a
class verificar():
def __init__(self, y = 0):
self.y = y
def verifica(self):
b = teste().aleatorio()
return b
print (teste().aleatorio())
print (verificar().verifica())
==========
In advance, I thank everyone who is willing to help.
You want only one random value to be generated and used in both calls?
– Woss
I want the random value, generated in the TEST.RANDOM function, also to be used in the CHECK function.CHECK.
– Danilo