Answers for "create tuples python"

52

what is a tuple in python

# 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.
tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = "a", "b", "c", "d";

# To access values in tuple, use the square brackets for
# slicing along with the index or indices to obtain value
# available at that index.
tup1[0] # Output: 'physics'
Posted by: Guest on March-03-2020
3

how to use tupels python

tupel = ('banana',10,True)
print(tupel[2])
Posted by: Guest on June-13-2020
0

create tuples python

values = [a, b, c, 1, 2, 3]

values = tuple(values)

print(values)
Posted by: Guest on December-15-2020
3

pyhton tuple

#It's like a list, but unchangeable
tup = ("var1","var2","var3")
tup = (1,2,3)
#Error
Posted by: Guest on March-11-2020

Python Answers by Framework

Browse Popular Code Answers by Language