Questions tagged as 'python-3.x'

1
answer

Decorator with parameters in Python

I need to implement a decorator with classes or functions that receive parameters, like the following example @MyDec(flag='foo de fa fa') def bar(a,b,c): print('En bar(...) : ',a,b,c)     
asked by 11.08.2018 / 21:53
4
answers

Minimum value of a list

I'm putting together a list lista.append(['{}{}'.format('Metros: ', metros),nombre,direccion]) and the output is: [['Metros: 405', 'edificio A', 'San Lorenzo'], ['Metros: 1843', 'edificio B', 'Eusebio Blanco'], ['Metros: 3067', 'edificio...
asked by 10.04.2018 / 17:07
2
answers

How to know in Python if the elements in a list are different?

I want to know how I can do to verify that the elements of a list are all different (none repeated). Ex: lista=[1,-1,1,3,9,5] codigo_verificador() Exit: True # Hay un elemento repetido How can I know that there are repeated elements...
asked by 13.10.2018 / 03:02
2
answers

Add integers of an array in python

This is a simple question but I have not found any post related to this topic. matriz=[[1,2,3],[4,5,6][7,8,9]] I would like to add all the grids of this matrix to each other (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) so that I returned 45 in a new...
asked by 23.05.2018 / 23:43
1
answer

Problems copying data to csv file (to bytes-like object is required, not 'str')

I'm having trouble copying a column of data into a csv file. The original csv file looks something like this: ID;texto 1;El niño juega 2;La rana salta 3;Mi código no funciona The code I use reads data from a csv file, and generates a lis...
asked by 04.11.2017 / 19:30
1
answer

Is the result incorrect with Numpy in Python 3?

I was doing matrix exercises with numpy, but apparently it generated an error in the final answer: As we can see the final result of Z*Z is: [[9,4,1], [1,0,1], [1,4,9],] But after a suspicion I compared the results by hand w...
asked by 13.07.2016 / 06:13
4
answers

How to install pygame in Python3 with pip

How can I install pygame for python3 using pip ?. I have the version of Python 3.6.3. I tried with pip install pygame but it was installed in python 2.7. Thank you.     
asked by 27.12.2018 / 17:34
3
answers

Multiply matrices in python

This is a question a bit simple but I can not solve it on my own, and I have not found any post related to this topic, my question is this: matriz=[[1,1,1],[1,1,1],[1,1,1]] print(matriz) matriz[0]=matriz[0]*2 print(matriz) What I want to...
asked by 21.05.2018 / 22:37
1
answer

Delete a file with all its contents in Python

I would like to delete a directory that contains several files inside. It has the following structure: carpeta fichero1.txt fichero2.txt I tried to delete it directly with os.removedirs('carpeta') but it gives me the error...
asked by 20.09.2017 / 22:30
2
answers

Instance of an object in python

from Tree import Node q = Node(p) The problem with the code is that I get this message:    'Node' is not callable   This inspection highlights attempts to call objects which are not callable, like, for example, tuples. This does not le...
asked by 22.07.2017 / 01:14