0
Missing 2 required positional arguments
My code is super rough because not having the int1 and int2 variables defined currently has me stuck. The goal is to have my function generate an addition problem. Easy difficulty will select two random integers between 0 and 10. Intermediate will select two random integers between 0 and 20. Hard will select two random integers between - 20 and 20. I will ask the user three problems in there chosen difficulty then grade there quiz and give them the percentage. I'm currently stuck just trying to get my question to print though. https://code.sololearn.com/cdSnYPcjcLhV/?ref=app
6 Réponses
+ 5
Your function is defined with 2 parameters but you are not passing any arguments to the function.
Try changing
def generateProblem(int1, int2):
to
def generateProblem():
+ 2
Change line 21 to
def generateProblem():
+ 1
Thank you for your replies. I thought I had to give it the two variables though. I reposted this because my first post wasn't very clear. I'm still trying to get my head around functions and unfortunately my teacher is terrible. I believe he's knowledgeable but his ability to teach is lacking
0
I did not read everything but first of all: AVOID global variables in functional programming! This is not side effect free as the order of your calls will change your apps behavior, without making it obvious. And I realy wonder if it is possible to define global variables within a function.
0
That got the results but I don't understand the why of the fix though. I don't really understand functions that well or how they work. My understanding of them is that they package code and can be called later, but I don't understand how they work or how they are formatted that well.
0
Your function is defined with 2 parameters but you are not passing any arguments to the function.
Try changing
def generateProblem(int1=null, int2=null):