If this yields the answer inside the function yields the output below:
ip1 = “10.20.30.40”
def myFunction():
ip1 = "192.168.100.200"
print("This IP address is: " + ip1)
myFunction()
Output: This IP address is: 192.168.100.200
Then why does this use the number 105 when its outside of the function, as well as
answer = 105
# do not edit below this line
number = 105
def sample_function():
number = 37
return number
print(number)
if number == answer
print(f"Submitted answer: {answer} | Correct!")
else:
print(f"Submitted answer: {answer} | Try again")
AND
answer = 105
# do not edit below this line
number = 105
def sample_function():
number = 37
return number
print(number)
sample_function()
if == answer:
print(f"Submitted answer: {answer} | Correct!")
else:
print(f"Submitted answer: {answer} | Try again")
AND
answer = 105
# do not edit below this line
number = 105
def sample_function()
number = 37
return number
print(number)
if number == answer:
print(f"Submitted answer: {answer} | Correct!")
else:
print(f"Submitted answer: {answer} | Try again")
sample_function()
All yield 105 as the answer, despite moving all of the items within the function? Shouldn’t the encapsulation within the function force the code to use 37 instead of the 105 which is outside of the function?