Questions tagged as 'tupla'

2
answers

What is the main difference between a Tuple and a List?

What are the differences between Tuple and List in Python ? Example: >a = [1, 2, 3] # [1, 2, 3] >b = (1, 2, 3) # (1, 2, 3) The Tuple , grotesquely speaking, is a constant that accepts List ?     
asked by 03.03.2015 / 16:12
2
answers

Is Tuple the same thing as creating an object?

I've used Tuple a few times today came the doubt, this: public class User{ public String Name {get; set;} public String LastName {get; set;} } new User(){ Name = "Leonardo", LastName = "Bonetti" } Is it the same as...
asked by 13.08.2018 / 17:05
1
answer

How to sort a list of tuples by the nth element?

I have a list of tuples of the form: [(0, 1), (2, 3), (4, -5), (6, -3)] I want to sort this list by the second value of each tuple (that is, in case we would have [(4, -5), (6, -3), (0, 1), (2, 3)] . How to do that?     
asked by 14.12.2013 / 23:00
1
answer

What is the difference between sorted () and .sort ()?

Why is the sorted() function considered more direct than the .sort() method used in lists with tuples?     
asked by 29.04.2016 / 19:32
1
answer

Is it possible to de-structure an array in PHP equal to or similar to the list in Python?

In Python we can de-structure a list like this: lista = [ "Maça", "Pera" ] maca, pera = lista print(maca, pera) The output will be: Maça Pera I know that in PHP it is possible to get the result using the function list $lista...
asked by 07.11.2018 / 00:26
3
answers

Why in Python can we define an index of a Dict as a Tuple?

I noticed that in Python, we can add values of type tuple as index of a dict (dictionary). Example: test = {} test[(1, 2, 3)] = ("um", "dois", "tres") print test // {(1, 2, 3): ('um', 'dois', 'tres')} And after the defini...
asked by 17.06.2015 / 17:17
1
answer

Tuples in database

I know what a tuple is in Python but not in a database, so the question follows: What is a tuple in the database context?     
asked by 08.11.2016 / 16:27
2
answers

Make word search within a list and return ordered tuples in PYTHON

The algorithm should receive a string, count as many words as possible, and return a list of tuples with the words that appear the most in the string and how often it appears. The problem is that in searches are words that start out the same cou...
asked by 05.11.2016 / 12:01
2
answers

Assign Tuple return in two variables

It has a method that returns a tuple with two strings . The return I want to write to two different variables, but I'm having to call the method twice to pick up one item at a time. string retorno1 = SearchTerra(artista, musica).item1...
asked by 12.04.2017 / 22:27
1
answer

Python: unsupported operand type (s) error for /: 'tuple' and 'int'

Hi, I have a problem with a function in Python, which involves a tuple of tuples. When executing this assembly function calling the tuple of tuples votes: votacoes = ( (0, 15729, 220408, 1297, 0, 3040, 993, 0, 1354, 1046, 0, 3284, 99652, 1...
asked by 08.11.2015 / 16:24