Python Operators


#1

What’s the difference between 3(x+y) and 3*(x+y)
Do they not produce the same output?

For e.g. when x= 4 ,y = 5

3(x+y)
= 3(4+5)
= 3(9)
= 27

3*(x+y)
= 3*(4+5)
= 3*(9)
= 27

Is my working out incorrect?


#2

3(x+y) is a valid algebraic expression, however, however your need to include the * operator for it to work properly in Python.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.