Okay, so this is a bit confusing to explain. Basically, I would like 'num1' to generate a random number every time it is called, however when inside the function, I would like the variable to stay the same, in order to give the correct answer.
#finding random numbers to be used in questions
import random
num1 = int(random.randrange(0,101,1))
num2 = int(random.randrange(0,101,1))
#defining a function that asks an addition question, using random numbers
def addition_question(num1,num2):
answer1 = num1 + num2
print("What is",num1,"+",num2,"?")
given1=input()
if given1==answer1:
print("Correct!")
else:
print("Sorry, wrong answer!")
print("Question 1:")
addition_question(num1,num2)
I think at the moment what it is doing is assigning a different value for num1 and num2 each time they are called.
Is there any way to solidify the values of the variables within the functions, while still kepping the value of them outside the function random?