Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Mutability. Mutable objects can be changed. Immutable objects cannot.
p0 is immutable because it is an integer. It is reassigned with each iteration, not mutated.
The test code calls this function with:
Test.assert_equals(nb_year(1500, 5, 100, 5000), 15)
1500 was not harmed during the execution of this function.
If you assigned p0 to the value 1500 and then passed p0 in the calling function, p0 would still point to 1500 upon funtion completion.
If you want a funtion to change your objects, pass a mutable object, like a list.
Generally, if x = [], then x[0] = 1 (mutating) and x = [1] (reassigning) are two different operations. both x-es have the same value, but the mutating version will change x in the calling function, and the assignment has local scope.
Please correct me if I am wrong.
Yes.
The . just makes it into a float correct? Same function as
100.0
?This comment is hidden because it contains spoiler information about the solution