Assuming the following code:
state = 'Mississippi' state.replace('s','f',4) state.replace('i','u',1)
What will the value of the state variable be after the code is executed? Think hard. Maybe even back to one of your true/false answers...
A. 'Mississippi'
B. 'Miffiffippi'
C. Mufsissippi'
D. 'Muffiffippi'
The answer is option A.
Value of the variable state after execution will remain the same as it is assigned in the first line, which is, 'Mississippi
This is so because strings are immutable in python, and when we are executing line 2 and 3 we are not storing the results in the variable state, Hence afthe executions of these lines the result they return are not stored in variable state,
Therefore the value of the variable does not changes.
Therefore the first option is correct.
We can also test on the console:
FOR HELP PLEASE COMMENT,
THANK YOU
Get Answers For Free
Most questions answered within 1 hours.