Questions tagged as 'python-2.7'

1
answer

Finding values in a python array and assigning specific values

I have the following vector: posicao = [47, 62, 24, 18, 47, 62, 63, 78, 68, 87, 24, 18, 68, 87, 63, 78] I need to look at this vector for values [24, 18]. After locating all, I need to assign a random value to these positions, but EQUAL....
asked by 10.08.2017 / 03:49
1
answer

Correlating vectors through indexes in Python

I have the following vectors: posicao_1 = [4, 62, 24, 18, 47, 62, 63, 78, 68, 87, 24, 18, 6, 8, 12, 17] posicao_2 = [43, 61, 21, 19, 46, 63, 68, 72, 66, 89, 29, 10, 8, 7, 6, 15] I need to look at the vector POSITION_1 the value [24, 18]....
asked by 11.08.2017 / 00:50
1
answer

Correlate vectors through the index and assign different values

I have the following vectors: posicao_1 = [4, 62, 24, 18, 47, 62, 63, 78, 68, 87, 24, 18, 6, 8, 12, 17] posicao_2 = [43, 61, 21, 19, 46, 63, 68, 72, 66, 89, 29, 10, 8, 7, 6, 15] I need to look at the vector POSITION_1 the value [24, 18]....
asked by 12.08.2017 / 01:17
1
answer

Go through a vector up to a certain number of indexes and form a list with the values

I have the following vector: a = [10, 10, 10, 10, 10, 20, 20, 20, 20, 20] I need every 5 indexes to list them. It would look like this: b = [(10, 10, 10, 10, 10), (20, 20, 20, 20, 20)] I think it's something simple, but I can not ex...
asked by 20.08.2017 / 03:05
1
answer

IndexError: image index out of range using PIL

I'm starting to work with image processing and I need to do a simple exercise to double the size of one. I have the following script: from PIL import Image imagem = Image.open("local_da_Imagem", "r") largura, altura = imagem.size fator =...
asked by 20.08.2017 / 15:32
1
answer

How to include labels in matplotlib

I have the following code: import matplotlib.pyplot as plt AP_X = [10,20,30,40] AP_Y = [50,60,70,80] plt.scatter(AP_X, AP_Y, color="green") plt.ylim(0, 100) plt.xlim(0, 100) plt.show() It displays a graph with the x, y positions of my 4 p...
asked by 26.07.2017 / 03:48
1
answer

Text Processing in csv file

I have a database with more than a thousand reviews (text) in a csv file, however I need only texts that contain more than 5 words to be in my file. The problem is to make a code that scrolls the entire document line by line and leave only opini...
asked by 14.06.2017 / 01:38
1
answer

Transform varchar to float

I made a code that takes data from the DB to generate a graph with matplotlib , but the data in the DB is as varchar and for data creation it must be in the format% with%. How can I do the conversion? # -*- coding: utf-8 -*- import MyS...
asked by 29.05.2017 / 22:31
2
answers

How to create a user-sized tray and display it as text using python?

I'm trying to create a program in Python 3.6.1 that creates a tray according to the size entered by the end user and prints the result in the shell. It needs to be displayed as text, and you can not use any library. As much as the library is...
asked by 14.04.2017 / 09:01
1
answer

TypeError: 'float' object is not iterable in CHOICE function in 2D Python List

I have the code below and I can not get it to work. For, I need a vector from my 2D list to be chosen randomly with the CHOICE function and sum the values that are less than 85.0 and subtract the values when it is larger. However, the following...
asked by 24.02.2017 / 12:34