I'm working through problem set 1 and have a question about some of the comparison terms. What does += and -= mean? everything else in the solution file makes sense to me but I'm struggling with understanding these terms.
can you show the text of the actual problem please?
also what language is this java, c, c++ ?
in C/C++/java check the following page - scroll down to the section on "Assignment Operators" http://www.tutorialspoint.com/cprogramming/c_operators.htm Here is an excerpt: += means "Add AND assignment operator, It adds right operand to the left operand and assign the result to left operand" example: C += A is equivalent to C = C + A and -= means "Subtract AND assignment operator, It subtracts right operand from the left operand and assign the result to left operand: example: C -= A is equivalent to C = C - A There are also other combinations with = like *=, /=, ...
Python supports these "shorthand" notations. a += b is shorthand for a = a + b. Subtraction, division and multiplication are also supported.
a+=b means a=a+b a*=b means a=a*b a/=b means a=a/b a-=b means a=a-b a=+b is very different from a+=b so be careful with these typing errors that can lead to very annoying problems.
Join our real-time social learning platform and learn together with your friends!