Computer Science, asked by sanasona9008, 3 months ago

what is a tuple? how literals of type tuples writen? given example​

Answers

Answered by nehabhosale454
19

Answer:

Tuple Literal Values

A tuple is created by surrounding objects with ()'s and separating the items with commas (,). An empty tuple is empty ()'s. An interesting question is how Python tells an expression from a 1-tuple. A 1-element tuple has a single comma: (1,). An expression lacks the comma: (1). A pleasant consequence of this is that an extra comma at the end of every tuple is legal; for example, (9, 10, 56, ).

Examples:

xy= (2, 3)

personal= ('Hannah',14,5*12+6)

singleton= ("hello",)

The elements of a tuple do not have to be the same type. A tuple can be a mixture of any Python data types, including other tuples.

Answered by Itzkrushika156
9

Explanation:

\huge \mathcal {\fcolorbox{red}{black}{\green{A}\pink{N}\orange{S}\purple{W}\red{E}\blue{R}}}

A tuple is created by surrounding objects with () 's and separating the items with commas ( , ). An empty tuple is empty () 's. A 1-element tuple has a single comma: (1,) . ..

FOLLOW ME

Similar questions