Question: Given the following code: def subtract _ one ( num ) : num = num - 1 print ( ' inside function: ' + str
Given the following code:
def subtractonenum:
num num
printinside function: strnum
printbefore function call: strval
subtractoneval
printafter function call: strval
The code will print out:
before function call:
inside function:
after function call:
Why does the value of val not become after the function call? Select all that apply.
The variable val is a global variable and cannot be changed inside a function.
Changing the parameter num inside the function does not change the value of val outside the function.
The function subtractone should return num, and it should be assigned back to val.
The parameter num should be declared as global inside the function.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
