Questions tagged as 'python'

1
answer

How to create a method that pause and one that resumes a Thread?

The following script shows the x variable every 3 seconds, while the xx class running on a thread increases the value of x every second. I would like, when the value of x reaches 13, the thread where the xx class is being executed would stop....
asked by 11.02.2017 / 22:40
3
answers

Difference between two codes

Code 1, if variable num is 1 or 2 for example, when conv() is called again and I choose option 3 to exit then it runs print I hope I have been useful (: program does not close, only the next time I choose option 3. In code 2 the...
asked by 13.03.2017 / 18:34
1
answer

Other ways of doing matrix

I have been able to develop here, you should not print spaces after the last element of each line, which causes the exercise to go wrong, does anyone know of another method? minha_matriz= [[1,2,3],[4,5,6],[7,8,9]] def imprime_matriz(minha_mat...
asked by 24.02.2017 / 16:48
1
answer

Go through 2D list in Python

I have the code below and I want to go through and display item by item from this list. However, I can not do this because the entire list is displayed. I ask for your help. lista = [[10,20,30,40],[50,60,70,80]] i = 0 for i in range(2): pr...
asked by 23.02.2017 / 20:29
2
answers

How to convert the date difference from seconds to hours / days?

I made a program in python that it takes the current time, time, convert in seconds and subtract one from the other to know the difference between it. My question is, how do I convert those seconds to hours and days? Code that converts date t...
asked by 24.08.2017 / 00:49
2
answers

Python fill values with data from other rows

Good morning, I'm having a big data failure problem on my df . I need to find the CO2 value similar to another time using conditions I can not do with the line information. I have df of 1 year with values of 30 em 30 minut...
asked by 21.03.2017 / 14:13
1
answer

Python / R Check for density peaks in ggplot2

I have two sets of data formed as follows: A = {id1: 0.3, id2: 0.1, id3: 0.3 ... idn: 0.2} B = {id1: 0.01, id2: 0.04, id3: 0.75 ... idn: 0.9} I used the ggplot function of R to plot the density values in the same graph, thus:...
asked by 26.05.2017 / 23:11
1
answer

Python, how to validate if the variable is None?

I'm not able to check if the variable has no value (None) View: endereco_id = request.POST.get('endereco_id', None) if formCliente.is_valid() and formEndereco.is_valid(): print('********** endereco_id **************') print(endereco...
asked by 14.04.2017 / 19:10
1
answer

Game of life, what's wrong? [closed]

I'm training Python and recently I've been trying to recreate the famous "Game Of Life", I've managed to avoid code failures but it still is not behaving correctly. The program was supposed to behave this way: link Note that the game is sti...
asked by 24.01.2017 / 02:51
2
answers

How to compress a folder with everything inside using zipfile in python?

I'm trying to compress a file and a folder that has multiple files inside it into a single .zip file using Python. The script is as follows: from zipfile import ZipFile,ZIP_DEFLATED def zipar(lista): with ZipFile('teste.zip','w',ZIP_DEFLA...
asked by 26.01.2017 / 21:59