

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is syntax of tuple declaration in Python?
A tuple is a comma separated sequence of items. The sequence can be optionally put inside parentheses.
>>> t1=(1, "Ravi", 23, 546) >>> t1 (1, 'Ravi', 23, 546) >>> type(t1) <class 'tuple'> >>> t1=1, "Ravi", 23, 546 >>> t1 (1, 'Ravi', 23, 546) >>> type(t1) <class 'tuple'>
Parentheses are essential if a null tuple or tuple with one element has to be created
>>> a=() >>> a () >>> type(a) <class 'tuple'> >>> a=(1,) >>> a (1,) >>> type(a) <class 'tuple'>
- Related Questions & Answers
- What is correct syntax of Python if statement?
- What is basic syntax of Python for Loops?
- What is basic syntax of Python if...else statement?
- What is Syntax Tree?
- What is tuple unpacking in Python?
- What is the syntax of Python if...elif...else statement?
- What is Implementation of Syntax Directed Translators?
- What is correct syntax to create Python tuples?
- What is correct syntax to create Python lists?
- What is correct syntax to create Python dictionary?
- What is the proper declaration of main in C++?
- What is python .. ("dot dot") notation syntax?
- What is Types of Syntax Directed Translation Schemes?
- What is the basic syntax to access Python Dictionary Elements?
- What is the use and syntax of SEQUENCE in DB2?
Advertisements