Most voted "python" questions
Python is a dynamic and heavily typed programming language whose design philosophy emphasizes usability. Two similar but incompatible versions of Python are in use (2 and 3). Please mention the version you are using when asking a question about Python.
Learn more…8,642 questions
Sort by count of
-
0
votes1
answer1151
viewsHow to create a registration form with Django
I have been studying Django recently, but I came across a problem in creating forms, I tried to go in the official Framework documentation but I could not find the solution. Forms.py from django…
-
0
votes1
answer140
viewsPython Method resolution order (MRO)
Let’s say I have something like this: # -*- coding: utf-8 -*- class Base(object): @classmethod def foo(cls): pass def grok(self): pass class A(Base): @classmethod def foo(cls): print('A')…
-
0
votes1
answer63
viewsSlice an array
I’m having trouble with x2 values when trying to slice to display in graph 2 does not appear anything and I can’t see where I am missing? import matplotlib.pyplot as plt import numpy as np xold =…
-
0
votes1
answer90
viewsHow to return Python value series
I have a function that reads line by line a TXT file on disk and format it extracting only what interests me, getting a list like this: Swi 04/11/2018 Basel Lugano 3 2 2 0 Swi 03/11/2018 Grasshopper…
pythonasked 6 years ago Stefano Emmanuel 7 -
0
votes0
answers44
viewsGenerate histogram in Jango
I’m trying to generate a histogram in Django for a project I developed. The code usually generates the histogram without difficulties in the first attempt, however, when I try again, it returns me…
-
0
votes0
answers56
viewsHow to convert video to memory with moviepy?
I’m converting videos into python and I’m using the moviepy library. I’m using the instructions: clip = VideoFileClip('/home/developer/Pictures/aa.mov')…
pythonasked 6 years, 5 months ago Vinicius Morais 1,293 -
0
votes0
answers60
viewsResult of paged loop instead of unified
I’m having trouble getting a result formatted in JSON paged. My code instead of returning the result of the joined is bringing the result per page! import requests def __init__(self, usuario,…
-
0
votes1
answer3268
viewsPython Back-end for Front-end
I made a simple application that registers some data in a sqlite3 database, all this part of the Back-end is done in Python with.py files running in the same terminal, for my use already serves me…
pythonasked 6 years ago Stefano Emmanuel 7 -
0
votes1
answer55
viewsHow to test if all elements are 2-element tuples
I am solving an exercise that I first have to test whether the argument received is a Double. If yes, I have to test if all its elements are tuples of 2 elements, where the first is a string, and…
-
0
votes2
answers139
viewsSet functions for equal values and values in ascending order - Python
Hello, I set a function to read 100 records, containing name, gender and age, and now I need a separate function to show on the screen how many people are male and another separate function to show…
-
0
votes1
answer287
viewsmoviepy: reduce video to 100mb
I’d like to know if there’s any way to narrow a video down to 100mb. I have some videos and I want to convert it to 100mb, regardless of the quality it will stay. In this example, I reduce to 360p…
pythonasked 6 years ago Luan pedro 609 -
0
votes1
answer1271
viewsSaves float array in a txt file
After saving array in txt I want to be able to work with each of the values doing all the mathematical manipulations, but the way q I am saving I am not getting. Someone can help me. import numpy as…
-
0
votes1
answer40
viewsHow can I do that without needing this global variable?
The problem I have is the following I have a method that should be called 4 times, once every 750 ms. The problem is that the way it is called I can’t pass arguments to it, why it is called via…
-
0
votes1
answer479
viewsParking class in Python
I’m learning to code in Python. Right now I need to implement a class that has the following features: A class called parking, which simulates the operation of a car park. -The class receives an…
-
0
votes1
answer43
viewsAverages of elements in various lists
I need to calculate the sum of several elements in different lists (from index 0). lista1 = [154,12,998,147] lista2 = [897,123,998,59877] lista3 = [3,789,111,555,699] That would be the simplistic…
pythonasked 6 years ago Murilo Mendes 1 -
0
votes1
answer295
viewsWhat is the difference between Train Test Split and Holdout?
From what I have already researched, both divide the set into two subsets of training and testing. There is some difference between the two?
-
0
votes1
answer86
viewsFind a value in a given column in a.txt file
I am trying to search for a value at a certain position in the column of a text file and generating another file with these lines, but without success Follows the code: arquivo = open('arquivo.txt',…
-
0
votes1
answer689
viewsHow is the text of the python-kivy text_input used?
I’m having trouble using text_input text to store in the database. Python code: from kivy.app import App from kivy.uix.screenmanager import ScreenManager, Screen from kivy.core.window import Window…
-
0
votes1
answer33
viewsA (CTRL + A) in telnet client
I’m making a telnet client in python and I need to send a code to another machine but the code needs to put a Ctrl + To (CODE) but when I put ^A (code) does not work, heeelp me serv = raw_input("[+]…
-
0
votes1
answer103
viewsGenerate a random combination on each line
I made a number generator that looked like this: import random import math for i in range(10): c1 = (random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9])) c2 = (random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9])) c3…
-
0
votes1
answer227
viewsPandas: How to make a Serie fragment in the field (Column) of the Dataframe
I have this excel below: NÚMERO "URL NÚMERO 16571 SICAN" "URL DECRETOS 2011 PRINCIPAL" 1 CCIVIL_03/Atos/decretos/1991/D00001.html CCIVIL_03/decreto/1990-1994/D0001.htm 4…
-
0
votes1
answer2857
viewsCalculate arithmetic mean of a vector
import numpy as np matriz = [] medias = [] alunos=1 while True: print("Informe o número do aluno ou um valor negativo para terminar:") valor=int(input('Digite o…
-
0
votes1
answer571
viewsPython Class Method Call
I’m doing a work of a playing card and I’m having a problem calling the class methods Deck(), I tried to redo some parts of the code and sometimes as an undefined object, I redo it again and still…
pythonasked 6 years, 5 months ago Pedro Henrique 1 -
0
votes0
answers35
viewsFunction being called before being called by GUI
I have a software that I am using Tkinter as GUI, to receive some parameters that the user will pass me. In this software I have 1 problem and a doubt. the problem is this, just when I run the…
-
0
votes1
answer46
viewsHow to make one class interfere with another with python
I want to make a switch button with kivy style, when one is true, the other is false, however, when I change a variable in the class of the first, it is not changed in the second, and remains with…
-
0
votes2
answers2072
viewshow to delete a column in a python csv file
How do I delete a column from a csv file? example: nome;nota;idade joao;10;12 maria;8;13 jose;6;8 to look like this: nome;idade joao;12 maria;13 jose;8 and how do I place a new column from that file…
-
0
votes1
answer31
viewsShodan implementation(Api) No return result
Good afternoon. So people are doing a test with Shodan to implement in another program. However when I type $:python python_test.py.py + ip or query It does not display the result and rtorna to the…
-
0
votes2
answers2500
viewsHow to use a function within another function in python3?
I wanted to take the result of the name function input and use inside the intro function, but the way I’m trying, I get just one error. code: def nome(): name = str(input('Poderia nos dizer seu…
-
0
votes1
answer361
viewsAllocate day period to hours
I have the following df: df = pd.DataFrame({'hora completa':['21:35:00', '22:16:00', '00:50:00', '09:30:00', '14:30:00']}) print(df) hora completa 0 21:35:00 1 22:16:00 2 00:50:00 3 09:30:00 4…
-
0
votes1
answer546
viewsMinimum value of each Python array column
import numpy as np X = np.random.rand(4,3) print("X: \n", X) XMin = np.zeros((1,3), dtype=np.float64) for j in range(3): print("X[{0}]: {1}".format(j,X[j])) minimo = np.amin(X[j]) print("minimo: ",…
-
0
votes1
answer2728
viewsDetermine recursive Python derivative calculus
I need to create an algorithm so that it determines in N times the derivative of a X function. However I still have some problems to implement recursive functions, I still can’t get a good idea of…
-
0
votes1
answer120
viewsHow to pass array in a gRPC?
I’m testing some code using gRPC with the Python language, and I’m not able to manipulate array. The code consists of passing an array per parameter, the server receives this array and sorts. code .…
-
0
votes1
answer116
viewsI need to read a . csv file and rewrite it into another . csv file without stopwords using Python
from nltk.corpus import stopwords from nltk.tokenize import word_tokenize from string import punctuation import csv texto = open('arquivo_sujo.csv','r').read() with open('arquivo_limpo.csv', 'w') as…
-
0
votes2
answers424
viewsHow do I calculate the average running time of a function?
To calculate the execution time of a function I am using inicio=time.time() # código fim=time.time() How do I calculate the time repeatedly and then calculate the average of that time?…
pythonasked 5 years, 12 months ago Priscila Guedes 35 -
0
votes1
answer138
viewsPython set String where the cursor is
Good afternoon I need to set a string where the cursor is stopped. Examples are: - Blinking cursor stopped in a notepad, play a string in the notepad. - Blinking cursor stopped in any input field,…
-
0
votes0
answers108
viewshow to solve problems with "referenced before assignment"?
from tkinter import * from tkinter import messagebox jan = Tk() jan.title("Pontuacao") jan.geometry("200x200") pontos = 0 a = Label(jan, text="pontos") a.place(x=0,y=0) def aumentar_pontos(): pontos…
-
0
votes1
answer38
viewsImport packages inside tests with python
I have a project with the following structure: __init__.py setup.py - convert_keys/ - __init__.py - convert.py - tests/ - test_convert_keys.py Inside my file of tests I tried to import the following…
-
0
votes1
answer1078
viewsHow to break a list into two distinct lists to use in Gnuplot python?
A gnuplot online feature allows you to place your data in two columns separated by space, and it understands how the axes "x" and "y" http://gnuplot.respawned.com/ I am trying to use gnuplot python.…
-
0
votes2
answers129
viewsPYTHON formatting
can give me a hint on how to print the following problem in the correct way? while True: m = int(input()) mlen = m sm = 1 aux = 1 matriz = [] if m == 0: print() break for i in range(m): linha = []…
pythonasked 6 years, 5 months ago feecarvalho 3 -
0
votes1
answer127
viewsRecursion Problem in Python
It’s my first question here, so I’ll be brief: I’m having trouble with the code below: def nat(n): if n == 50: return 0 else: return nat(n+1) print(nat(1)) Turns out it’s a recursive question in…
pythonasked 5 years, 12 months ago Leidenschaft 3 -
0
votes1
answer540
viewsHow to assign the elements of a list to different variables in Python?
I have a list, like the following: lista = [1, 2, 3, 4, 5] Even without knowing how many elements there are inside the list, how do I assign each element of the list to a distinct variable? (as in…
-
0
votes1
answer682
viewsLogin 2.0 Django, authentication
I’m trying to make a login page, but I’m having some difficulties. For some reason that I can’t understand, every time I type the user and the password, whether right or not, gives the answer that…
-
0
votes1
answer804
viewsHow to create a list of objects of variable size, and assign their attributes without listing them one by one?
I need to read a file and pass your information to a list of objects. The file is in format: "attribute 1", "attribute 2", "attribute 3", ...,"attribute" each row contains the information of a…
-
0
votes0
answers2263
viewsPython stopped working visual studio code
I created 2 classes, being that one imports from another and gave error in the import. I searched the internet and told to go in the command palette and choose the interpreter (on my system only has…
-
0
votes2
answers116
viewsTry and except block
I need to carry out this program: Rewrite your payment program using Try and except for that the program treats non-numeric entries amicably by printing a message and exiting program. The following…
-
0
votes1
answer237
viewsFind a sub-string in the first column of a csv file
I am starting learning in python and do not know how to continue this code. I need to check the first column of a csv file, and if I don’t have a date in a cell in that column, insert the one that…
-
0
votes0
answers141
viewsHow to import pydensecrf.densecrf?
I’m getting the following error when I try to run the code: ImportError: No module named densecrf I’m using Jupyter Notebook 5.5.0 from Anaconda on Ubuntu 18.04 Does anyone know what could be? I try…
-
0
votes2
answers1297
viewsWhat is the difference between string.split(',') and string.rsplit(',') in python?
Using these lines in the python terminal, I couldn’t find any difference between them. I searched but found nothing about, at least in Portuguese. What would be the difference between them ? x =…
-
0
votes1
answer207
viewsKanade Lucas Tomasi (KLT) optical flow algorithm in Python
Hello. I searched all over the Internet and couldn’t find. Someone has an alternative to perform feature extraction on images with the python Kanade Lucas Tomasi (KLT) algorithm?
python opencv image-processing artificial-intelligence computer-scienceasked 5 years, 11 months ago FabianoF 55 -
0
votes1
answer82
viewsHow do I write a tabular file in an instance of Azure Data Lake Store with the Python API?
Suppose I have an instance of Data Lake Store in my Azure inscription and I would like to create a Python script to write a tabular file with tab (CSV type or similar) in that instance. Without…