Questions tagged as 'python-3.x'

1
answer

Approximation of the cosine function using the n first terms of a series

Data x real and n natural, compute an approximation for cos x through n first terms of the following series: cos x = 1/1 - (x**2)/2! + (x**4)/4! - (x**6)/6! + ... + ((-1)**k)*(x**2k)/((2k)!) My attempt to resolve: import math #x =1 #calc...
asked by 23.03.2018 / 18:50
1
answer

Encodings do not work in a file with OpenCV in Python 3

I followed the face detection tutorial using OpenCV and wrote in Python 3. In this file, print is not used. I already know that Python 3 is international, is UTF-8 compatible and does not need encodings. But even so, no accent appeared on...
asked by 18.03.2018 / 15:51
2
answers

Select in Python (with BD: Postgres)

I'm not able to do a select in the PostgreSQL database. Python 3. conn = psycopg2.connect(host="localhost", dbname='postgres', user='postgres', password=postgres) cur = conn.cursor() cur.execute("select id_log, nm_ip, dh_chamada, nm_tipo, nm...
asked by 11.06.2018 / 15:51
2
answers

How do I add values from list lists?

I have a list of lists, and I wanted to add the various values to index 3 of each list, but only if there is a certain string in this list. How can I do it? For example I have this list: [['ALABAMA', 'Abbeville', 2645, 11, 63], ['ALABAMA',...
asked by 12.06.2018 / 19:49
2
answers

How to multiply the number of lists by an integer?

If I have an integer in input and a list in input, is it possible to multiply the integer by the list? M = int(input()) C = (eval('[' + input() + ']')) That is, to have '' M '' lists according to the integer that I put in M, hence I will b...
asked by 20.05.2018 / 21:08
1
answer

Automate printing of files within a folder

I need to make any file that is in the folder, example c://imprimir , printed automatically, checks to see if it has something and sends it to the default printer . I've been researching in Python but I've basically been able to access...
asked by 02.03.2018 / 13:05
1
answer

How to open a file selection window in Python with GTK?

I have a Python application using GTK graphical interface. This interface consists of a screen with a data entry a button, The purpose of the program is to save data in spreadsheets in a specific directory . I need to click on the button to...
asked by 02.02.2018 / 16:23
1
answer

Doubt random.shuffle (), returns None (within print)

Because when random.shuffle() used within the string returns None ? I discovered afterwards that you can use shuffle to get out of print and put it on a single line but I do not understand why it hangs. Sample co...
asked by 03.02.2018 / 13:10
2
answers

Doubt when doing a ranking using django!

I'm making a game site using django and I want to do a ranking based on the score of all users! For now it looks like this: views.py : def index(request): perfis = Perfil.objects.all().order_by('-pontuacao_ultima') return render(re...
asked by 09.02.2018 / 00:38
1
answer

Output in two columns

The output of my code makes a list in a column. Code: path = '/home/allan/Área de trabalho/adjetivos.txt' i = 0 lista = [] conta = 1 with open (path) as file_obj: ler = file_obj.readlines() for le in ler: #print(le.rstrip()) li...
asked by 20.02.2018 / 03:57