tuples and named tuples tuples are objects that can store specific number of other objects in order they are immutableso we can' addremoveor replace objects on the fly this may seem like massive restrictionbut the truth isif you need to modify tupleyou're using the wrong data type (usually list would be more suitablethe primary benefit of tuplesimmutability is that we can use them as keys in dictionariesand in other locations where an object requires hash value tuples are used to store databehavior cannot be stored in tuple if we require behavior to manipulate tuplewe have to pass the tuple into function (or method on another objectthat performs the action tuples should generally store values that are somehow different from each other for examplewe would not put three stock symbols in tuplebut we might create tuple of stock symbolcurrent pricehighand low for the day the primary purpose of tuple is to aggregate different pieces of data together into one container thusa tuple can be the easiest tool to replace the "object with no dataidiom we can create tuple by separating the values with comma usuallytuples are wrapped in parentheses to make them easy to read and to separate them from other parts of an expressionbut this is not always mandatory the following two assignments are identical (they record stockthe current pricethe highand the low for rather profitable company)stock "fb" stock ("fb" if we're grouping tuple inside of some other objectsuch as function calllist comprehensionor generatorthe parentheses are required otherwiseit would be impossible for the interpreter to know whether it is tuple or the next function parameter for examplethe following function accepts tuple and dateand returns tuple of the date and the middle value between the stock' high and low valueimport datetime def middle(stockdate)symbolcurrenthighlow stock return (((high low )datemid_valuedate middle(("fb" )datetime date( )the tuple is created directly inside the function call by separating the values with commas and enclosing the entire tuple in parenthesis this tuple is then followed by comma to separate it from the second argument