I saw example of shape of array is (12,). what is difference between (12,) vs (12)?
Assuming that you are asking about the difference between these two Python code snippets
shape = (12,)
and
shape = (12)
The former gives shape
a tuple object, while the latter an integer. You can verify it by
print(type(shape))
The extra ,
in (12,)
is a syntax work around for Python to differentiate between normal parentheses, which are normally used to signify order of evaluation in an expression, and parentheses surrounding a tuple. If you take that extra ,
away then (12)
simply becomes 12
(just like how (12 + 1)
becomes 13
)
Thanks a lot.