“Ejemplo de tuple de Python” Código de respuesta

Tuplein Python

a=(1,2,3,4)
print(a[-3])

Coder Cat

Ejemplo de tuple de Python

# Creating a Tuple with
# the use of Strings
Tuple = ('Geeks', 'For')
print("\nTuple with the use of String: ")
print(Tuple)
      
# Creating a Tuple with
# the use of list
list1 = [1, 2, 4, 5, 6]
print("\nTuple using List: ")
Tuple = tuple(list1)
  
# Accessing element using indexing
print("First element of tuple")
print(Tuple[0])
  
# Accessing element from last
# negative indexing
print("\nLast element of tuple")
print(Tuple[-1])
  
print("\nThird last element of tuple")
print(Tuple[-3])
No Name

tuples en Python

  strs = ['ccc', 'aaaa', 'd', 'bb']  print sorted(strs, key=len)  ## ['d', 'bb', 'ccc', 'aaaa']
 #the list will be sorted by the length of each argument
Happy Heron

Tuple Python

tupel python
Ma

Tuple en Python

name_of_students = ("Jim" , "yeasin" , "Arafat")
print(name_of_students.index('Arafat'))
YEASIN ARAFAT

Python creando una tupla

# Different types of tuples

# Empty tuple
my_tuple = ()
print(my_tuple)

# Tuple having integers
my_tuple = (1, 2, 3)
print(my_tuple)

# tuple with mixed datatypes
my_tuple = (1, "Hello", 3.4)
print(my_tuple)

# nested tuple
my_tuple = ("mouse", [8, 4, 6], (1, 2, 3))
print(my_tuple)
SAMER SAEID

Respuestas similares a “Ejemplo de tuple de Python”

Preguntas similares a “Ejemplo de tuple de Python”

Más respuestas relacionadas con “Ejemplo de tuple de Python” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código