mirror of
https://bitbucket.org/Mattrixwv/pytutorial.git
synced 2025-12-06 10:13:58 -05:00
Updated to use variables instead of magic numbers
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#This is an example of a simpel random number generator
|
||||
|
||||
_BOTTOM_NUMBER = 1
|
||||
_TOP_NUMBER = 101
|
||||
_BOTTOM_NUMBER = 1 #The lowest number to generate
|
||||
_TOP_NUMBER = 101 #The number you want to generate below
|
||||
|
||||
import random
|
||||
|
||||
@@ -11,7 +11,7 @@ print("I will generate " + str(numbersToGenerate) + " numbers between " + str(_B
|
||||
|
||||
#Use that variable to generate that many random numbers
|
||||
for x in range(numbersToGenerate):
|
||||
print(str(random.randint(1, 101)))
|
||||
print(str(random.randint(_BOTTOM_NUMBER, _TOP_NUMBER)))
|
||||
|
||||
#After testing it seems that the random number generator is seeded automatically
|
||||
"""Results:
|
||||
|
||||
Reference in New Issue
Block a user