Questions tagged as 'python'

2
answers

Programming in Python

I downloaded python 3.4 on the site, but some commands do not work in this version compared to python2.7 does it make any difference? In the python2.7 manual, and can I install two?     
asked by 15.05.2015 / 21:42
2
answers

IDLE closing by pressing single

Until today I was using the terminal itself to program in Python, however today I decided to download the IDLE. When I try to put the single quotation mark (') it simply closes. Can anyone help me?     
asked by 19.05.2015 / 01:36
2
answers

Problem with the randint function

Hello, I'm having a little problem in my code. I try to generate a list of 4 random integers that do not repeat, but ... list_num = [] c = 0 v = random.randint(0, 9) while c < 4 and v not in list_num: list_num.append(v) c += 1...
asked by 23.03.2015 / 17:17
2
answers

Revert a string and possibility of method addition on native objects in Python

In Python, we have method reverse within List . It reverses the order of a list . Example: [1, 2, 3].reverse() // [3, 2, 1] But this method is not present in a string. example (Python): myString = "The String" myS...
asked by 13.01.2015 / 16:07
1
answer

How to improve common maximum divisor algorithm - URI 1028

I'm solving this URI problem that basically asks for the maximum common divisor between two values. I originally resolved with math.gcd on half a dozen lines, but the code was not accepted since the URI uses a version of Python 3 pri...
asked by 05.08.2018 / 15:46
2
answers

DataFrame Pandas - Calculate column based on other

I have a dataframe in the following format: colunas = [ 'COMEDY', 'CRIME', 'Classe Prevista' ] precisao_df = pd.DataFrame(columns=colunas) precisao_df['COMEDY'] = y_pred_proba[:,0] precisao_df['CRIME'] = y_pred_proba[:,1] precisao...
asked by 31.10.2018 / 05:31
2
answers

How to check the versions of modules installed in Python?

I installed two modules in Python via anaconda (conda install): zipfile36 ; MySQLdb . Using the anaconda prompt I get the version of both and all my other modules using the command: conda list But I would like to know, how ca...
asked by 30.10.2018 / 15:29
1
answer

What are file and directory descriptors?

I am studying módulo os of the Python default library and I realize that in many cases a function is allowed to receive as a parameter descritor de arquivo ou diretório some examples are:    os.fchdir(fd)   Change...
asked by 26.10.2018 / 05:04
2
answers

Send objects to a template base.html Django

My situation is as follows, I have a file base.html where more than one page of a extend in it. My question is, how do I send two objects to this file, so that these objects are shown in all other views, that extend the page (base....
asked by 20.07.2015 / 20:57
2
answers

How to return a query in JSON format with extra values and custom keys?

I want to return the result in JSON following this format: {"cadastros": [ {"id": 1, "STATUS": true, "pessoas": [], "podeEscrever": true}, {"id": 2, "STATUS": false, "pessoas": ['Maria', 'Ana'], "podeEscrever": true}, ], 'princi...
asked by 29.07.2015 / 00:28