Questions tagged as 'python'

3
answers

Search for a sequence from a list in another list

I'm trying to find a sequence from a list in another list. But I do not understand why my exit is "no". all: is not a solution because it returns true even if the elements are not in order set: is not a solution because I need the repe...
asked by 14.09.2017 / 16:04
3
answers

sort a list in python

I want to make a program where I ask the user names and he keeps them and orders them alphabetically. This is what I have now: names = input("What are the names? ") print(names) sorted_names = sorted(names) print(sorted_names) but whe...
asked by 17.10.2017 / 19:06
3
answers

How to create a List of setters and getters in python?

This is how it looks in java, I have to pass it to python and I have no idea how to do it. public List<Archivo> getArchivos() { return archivos; } public void setArchivos(List<Archivo> archivos) { this.a...
asked by 08.09.2017 / 16:00
2
answers

Mutable objects as default arguments in python

I have a question with the passage of arguments in python , when mutable data structures are passed as arguments, for example a lista , and another simple argument, in the following way: def arguments_mutables(arg, arg1=[]): "...
asked by 26.03.2016 / 17:59
1
answer

Use of * args and ** kwargs in python [closed]

I have seen examples of code in which the functions receive parameters *args and **kwargs . I do not understand that syntax nor in what cases it should be used. Although I have tried to read about it, I have only found informatio...
asked by 20.09.2018 / 07:48
2
answers

Is there any way to deny something like isinstance () in Python?

To make my question clearer, I give an example in code R which is the language in which I have a little more experience. Suppose I have the simple variable "a" that is worth 5. First of all I want to validate if it is numeric using is.num...
asked by 16.11.2018 / 20:50
2
answers

Why do the private attributes of a class change despite assigning them to another variable?

You define a class with a 'private' attribute called __rango then you want to make a copy of this attribute in the variable rangoT to modify it without affecting the original attribute, but both change its value. Class definitio...
asked by 10.04.2018 / 21:06
2
answers

problem with list in python

The exercise asks me to store 5 numbers read in a list and to show the POSITIONS of the largest number, but I do not know how to do it, because if the higher number is repeated 1 time, the program works for me, but if it is repeated several time...
asked by 30.09.2018 / 06:27
1
answer

I do not understand how Or works in python I refer to the following code

Someone can help me because and how it works in python because I try to do it according to the documentation and it gives me different results import operator operator.or_(2,8) 10 operator.or_(8,2) 10 8 | 2 10 2 | 8 10 2 or 8 2 2 | 8 10...
asked by 04.01.2019 / 16:04
1
answer

Is there really more efficiency in the Cocktail Sort than in the Bubble Sort?

I have these two codes the following which represents the bubble sort is the following: lista = [5, 4, 3, 2, 1] def bubble_sort(A): #Se comienza con el primer elemento for i in range(len(A) - 1): for j in range(len(A) - 1):...
asked by 16.07.2017 / 05:21