+ 1
What is the tuples?
please help me
6 odpowiedzi
+ 12
A tuple is a sequence of immutable Python objects. Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.
https://www.tutorialspoint.com/python/python_tuples.htm
Tuples are very similar to lists, except that they are immutable (they cannot be changed).
Also, they are created using parentheses, rather than square brackets.
https://www.sololearn.com/learn/Python/2452/
+ 2
Tuples are Python sequences like strings, they are immutable objects meaning cannot be changed once created.
Unlike strings, which can contain only characters, tuples can contain elements of any type.
Tuples use parentheses eg (Tiger, Coffee, 1, 'a', 10.50, b)
Strings use quotes eg 'Hello', "Hello", '"Hello"'
Lists are the 3rd type of sequence although you didn't ask about it. I assume you have to know about them also.
List are mutable - use brackets eg [Tiger, coffee, 1, 'a', 10.50, 'b']
+ 1
Here is my primer on *args in Python - hope you find it useful!
https://code.sololearn.com/cce88fWlK7L7/?ref=app
0
List vs Tuple
List:
-Can use mutating function, method etc
Tuple:
-Can’t
Both in common:
-can access values:
Ex) in,len,etc
———————————
Tuples are used like in here
List1=[‘A’,’B’,’C’,’D’]
List2=List1
List1[0]=‘Q’
print(list1)
print(list2)
_____________
Result:
[‘Q’,’B’,’C’,’D’]
[‘Q’,’B’,’C’,’D’]
#1
the reason why this occurs is because list 2 is a mutable list. And list2=list1 means —-list2=list1= [‘A’,’B’,’C’,’D’]—-
#2
also tuples are used as dictionary keys too.
0
In addition:
Empty_list=[]
Empty_list=list()
Empty_tuple=()
Empty_tuple=tuple()
0
invite me in WhatsApp bra 0734866612,and please challenge me in java or Python.am not good in HTML