Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Tuple in python language with example

Posted on June 18, 2017January 22, 2020

Table of Contents

  • Tuple in python  language with example
    • Accessing element of tuple
    • Access element from one tuple through another tuple

Tuple in python  language with example

In this tutorial, we will discuss the concept of Tuple in python programming language

 

In python language, tuple is similar to a list with some difference. the differents between both are we can not changed the elements of tuple once after is is assigned. but list elenment can be changed

Creating tuple

When we create a tuple in Python, we can be place all elements inside the paranthisis and seperated by commas.

A tuple can be any type of data type(int, float, list etc) and any nyumber of elements

Accessing element of tuple

1. print every element from tuple

Output
Zeroth index element mathan
first index element mohan
second index element seelan
third index element sutha
forthh index element mugunthan
fifth index element neela
2. print element continuosly with out ‘comma’ from tuple
 
Output
mathan mohan seelan sutha mugunthan neela

3. print any element using array index
 
                1, dislay zero index element given tuple
       Output
              Zero index element : Maths
               2. dislay zero in to zero index element given tuple
Output
Zero in to Zero index element : M

Access element from one tuple through another tuple

 
1. print Element same tuple of subject
output
Zero index Element: English
Output
First index Element: student
Access element from one tuple through another tuple
 
below Example shown as access element from subject tuple through school tuple
 

 

Output
Zero index Element:  (‘Maths’, ‘Science’, ‘English’, ‘Tamil’, ‘Music’, ‘Arts’)
Zero in to Zero index Element:  Maths
Zero into Zero into Zero index Element:  M

Related post

Data type in Python                                     List in Python       

Dictionary in Python

Set Data type in Python

 
 

 

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes