First work first, we make the function ,and you know how to so !
def abc():
b = random.randrange(3)
return b
Secondly we need to know that return returns the output in the location where we called the function.
for example:
def example():
return "learning"
print (example()) #"learning" is sent to this line because example() is called here!
I hope you are clear about return now! Finally for your seeing output - you can print the output inside the function ,which would be a bad practice!
def abc():
b = random.randrange(3)
print (b)
return b
Also print the output from where it was called (like I said before)!
random_number = abc() # if you want to store the returned result somewhere
print(random_number)
or (works same)
print(abc()) # directly print the result; no storing the result
printitprint(b)in your function, orprint(abc())in your script.