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

9th May 2019, 4:52 AM
Elijah
6 Respostas
+ 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():
9th May 2019, 6:47 AM
David Ashton
David Ashton - avatar
+ 2
Change line 21 to def generateProblem():
9th May 2019, 4:57 AM
Diego
Diego - avatar
+ 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
9th May 2019, 5:02 AM
Elijah
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.
9th May 2019, 6:16 AM
Daniel Adam
Daniel Adam - avatar
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.
9th May 2019, 6:55 AM
Elijah
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):
11th May 2019, 7:28 AM
Rahul Shrivastav
Rahul Shrivastav - avatar