0
Meaning for parentheses
hi tell me the answer please
5 Antworten
+ 11
The word means the bracket signs:
() - for tuples and for mathematical/logical precedence issues
[] - for lists and arrays
{} - for dictionaries and sets
+ 6
Adam Thanks for the native speaker input :)
+ 2
for clarification:
() are parenthesis
[] are brackets
{} are braces
a final type is
<> are chevrons or angle brackets
+ 1
thank you
+ 1
parentheses () are like in maths, statements inside parentheses are calculated first.
Also functions use parentheses ()
some examples print() len() input() float(), but often function parentheses have arguments.
Parentheses () are also used for Tuples, which are unchangeable lists, but tuples doesn't always need parentheses.
Parentheses () are also used for another kind of lists, Sets, an empty set is done by set(), sets are lists, that can't have 2 same objects inside them. Sets can also be done with curlybrackets, but an empty pair of curlybrackets will create an empty dictionary.
Curlybrackets {} will create dictionary, they are lists, with Key:value pair.
Squarebrackets [] creates a simple list.
Squarebrackets [] can be used for indexing items from lists, for example:
A_List = [1, 2, 3, 4 ,5]
print(A_List[0])
This prints the element of the list which index is 0, if I would use an outranged index, it could produce an error.
Anyways I think these didn't help you much, so I suggest you to keep studying.