← Back to all posts

Hello again Repel community,
I am stuck on a CodeHS question. Can you guys please help me with this, it means the world to me, thank you <3
Here is the problem :)

In the following code:
MAX_NUMBER = 10

def sum(x, y):
result = x + y

``````//Point A

return result``````

num1 = random.randint(0, MAX_NUMBER);
num2 = random.randint(0, MAX_NUMBER);
print( sum(num1, num2) );

Question: Which variables exist at point A? In other words, which variables are in scope at point A? Which variables could you type at point A and the program would still work?

a. result only
b. result, x, and y
c. result, x, y, and MAX_NUMBER
d. result, num1, num2, and MAX_NUMBER
e. result, x, y, num1, num2, and MAX_NUMBER

hotnewtop
Whacko (323)

np @SimplyMiah
it was fun doing these riddles, even if the comments are messed up, and I didn't always get them right.

Whacko (323)

and by the way, python comments are like this:

``# Comment``

This is not:

``//comment``

Those are JavaScript comments, not Python.

SimplyMiah (1)

@Whacko I’m not sure but I feel like it’s c but idkkkkk

Whacko (323)

@SimplyMiah hmmmm
it doesn't tell you?

Coder100 (18071)

`num1` and `num2` haven't been declared yet (so they can't be used), but `MAX_NUMBER` has been! `x` and `y` are parameters so they are also defined, and that's it!

Coder100 (18071)

can you send repl insetad of just copy and pasting?

SimplyMiah (1)

@Coder100 oh sorry. i just commented a picture of the problem

Coder100 (18071)

oh, it's fine, now you know :) @SimplyMiah

Coder100 (18071)

also did my solution work @SimplyMiah

SimplyMiah (1)

@Whacko wait but would num1 be allowed to be in the function when it’s already outside it?

Whacko (323)

hmmmm this a tough one...