A tuple is list of python. Tuple uses parentheses (). Tuple does not use square brackets [].
Tuple items are ordered. Tuple items cannot be change. Tuple allows duplicate values.
In tuple you can write any type of value like int, float, string, boolean, etc.
Syntax
tuple_name = (item-1,item-2,item-3,.......)
example:
my_tuple = (100,200,True,'Hi',500,300)
The len() function used to get length of tuple in python program.
The len() is a predefined function in python.
The type() is function used to get data type of tuple.
If you want to create a tuple with single element then write comma(,) after element in tuple.
The square brackets [] are used to write elements in the list but parentheses () are used to write elements in the tuple.
The list is mutable but the tuple is not mutable. It means you can change or modify the list item but you cannot change or modify the tuple item.
Comsysapp.com is an educational website. Students and software developers can learn programming language tutorials. Comsysapp is very useful for beginners and professional developers. Comsysapp provides tutorial in easy language. Comsysapp.com has focus on simplicity.
Comsysapp.com provides free tutorials like c, html, css, etc. All tutorials are free for beginner and professionals.
comsysapp.com is not responsible for any mistake. We are not responsible if information made available on our website is incomplete or invalid. But comsysapp.com always try for zero-zero mistake.
comsysapp.com does not collect any data from users. We use Google AdSense advertising on our website. We never ask personal or private information.
copyright © 2023