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
-
1
votes2
answers7309
viewsHow to concatenate items from a python list?
Let’s say I got the result of a list: ['_', '_', '_', '_', '_', '_', '_'] how can I turn her into this?: ['_ _ _ _ _ _ _'] Or even in a variable with the above value…
-
1
votes1
answer94
viewsHow to store information in a Python (write) file?
Hello, I’m writing a program in Python with a code I have in Fortran. I have a problem writing this excerpt (from Fortran): do i=1,n write(3,350)r(i),(ener(j)*alfa,j=1,6) !meV end do I tried to…
-
1
votes1
answer125
viewsDjango. Only change in the database via html
I’ve been developing in Django for a little while, I have an image like on my site, when I click on it I would like to only change a field in the bank without reloading or resending the page and…
-
1
votes2
answers1572
viewsHow to invert a column in Python?
I would like to know how to invert "First Name, Last Name, Age" to "Age, First Name, Last Name" Follows my code: import pandas as pd #Importa a biblioteca "Python Data Analysis" df =…
-
1
votes3
answers733
viewsDisplay only words that have an even number of vowels within a sentence
I need to make this code in which you scroll through a list and print to the user the words that have an even number of vowels. Follow the code: frase = ["Foi magnifica a festa ontem."] palavras = 0…
-
1
votes2
answers114
viewsReplace numbers that are within a word
I want to remove numbers in the middle of letters, but I do not want to remove all numbers from the text, example: Vini12cius I want to turn into Vinicius, but without changing a possible CPF that…
-
1
votes2
answers77
viewsReturn pieces of an eternal
Implement a generator function, chunker, which takes an iterable and returns a specific piece of size at a time. Resorting to the function like this: for chunk in chunker(range(25), 4):…
-
1
votes1
answer262
viewsConstructor method in inheritance classes
Using Python3, as would the constructor method of the class Z? class W: def __init__(self, atributo1): self.atributo1 = atributo1 def metodo1(self): print("Metodo1") class X(W): def __init__(self,…
-
1
votes1
answer82
viewslist index out of range - From Fortran to Python
I wrote a program in Fortran and now I’m trying to write it in Python. However, it’s giving an error: D[i][j+1] = - u_med[i+1]/(delta_r[i]*delta_r[i+1]) Indexerror: list index out of range I’m a…
-
1
votes0
answers235
viewsRetrieve value of variables within a Class in a Python function (partial_fit)
I am creating a new algorithm to run along with the algorithms provided by the package sklearn in python, however the dataset used is extremely large and I am using the function partial_fit…
-
1
votes1
answer3978
viewsSubstituting values in a list
I need to replace values in a list of agreements with some criteria. Criteria: if the value is an integer and less than the reported value is replaced by -1 if the value is a floating point number…
-
1
votes1
answer2400
viewsPython: Tkinter. Run button
Dear friends, good evening! See if you can give me an idea, please! Problem to be solved: I created the TKINTER interface for my program. This interface was in a separate file from the code. I would…
-
1
votes2
answers183
viewsHow to implement this while not from Python in C?
I’m studying a Python code I need to turn to C, but the part that’s confusing me is this: while not(f1 == 0 and fn == 1): ... How would this same code be in C language?…
-
1
votes2
answers106
viewsPython - libraries without import "*"
How do I create a library without having to matter like that: from x import * or from x import y? Only by importing import x. Who will answer me, please use the script below as a library example.…
-
1
votes1
answer619
viewsAssign text in TXT file to a variable
Good morning! I am running a project that is working normally, but I would like to automate it more to gain time in operation. In case my project takes in a text file the main words I described…
-
1
votes1
answer79
viewsCode is skipping lines - Python
Good afternoon! I would like a help in my project that seeks words (file: Variables.txt) inside of another file (Answers.txt) and marks if you find a word. But skipping a few sentences leaving blank…
-
1
votes1
answer2245
viewsScript to recognize similarity between images
Good afternoon Everybody, all right? I am starting my studies in Python together with Opencv, and I want to perform the reading of images and display the degree of similarity between them. Ex: I…
-
1
votes1
answer3835
viewsRead specific line of a txt file
I have a file of 1000 lines and I want to read line 952. I don’t want to have to use a loop to go through all these lines, there’s some more optimized way to do this?
-
1
votes2
answers1051
viewsPython Build a multiplate parabola chart with matplotlib
I’m trying to chart the figure, but only the red line which is a multilard parabola. It is part of a neural network that I have ready, but I cannot generate the function that generates this…
-
1
votes1
answer197
viewsWhy is such a simple game getting so heavy?
This is the first project I developed using Pygame. Because it’s a simple card game, I hoped it would be very light, but not really. As I am using a very weak computer (single core 1gb ram) it is…
-
1
votes1
answer141
viewsWhy doesn’t this factor function work?
def fatorial(n): fat = 1 if n == 0 or n ==1: return 1 else: for i in range(1,n+1): fat=i*fat return fat def main(): n = int(input("Digite um numero que quer ver o fatorial: ")) print(str(n) + "! =…
pythonasked 6 years, 2 months ago user125799 11 -
1
votes0
answers111
viewsKivy using Raspberry pi 3
I’m using HDMI output from Raspberry Pi 3. Using a code Python that opens a window Kivy, this window fills the whole screen and overlap everything else(open windows, pointer mouse...). Apparently…
-
1
votes1
answer25
viewsError trying to install watson_developer_cloud
I am trying to install watson_developer_cloud using pip. After some time and after some dependencies to be installed I get the following error: Command "c: users i appdata local Programs python…
-
1
votes0
answers59
viewsHow to run engine on GPU?
I’m studying a simulator called Simian (http://pujyam.github.io/simian/), I am basing mainly on this article here: https://ieeexplore.ieee.org/document/7408239/ In this article, where one of the…
-
1
votes1
answer286
viewsConfigure unittest in vscode
I am unable to configure the unit test feature of Visual Studio Code. The extension keeps informing that no test has been found: My argument setting is in default mode, ie: #// Arguments passed in.…
-
1
votes1
answer456
viewspass input when running bat
Good afternoon, I have one. bat to run a python file, it needs to receive an entry, but I’m not able to run this input while running . bat, does anyone know how to? follows information from the bat:…
-
1
votes2
answers354
viewsScrapy xpath href or span inside the div
Hello, I’m trying to do a scraping where I have to pick up a link and text but I’m struggling because of page variations. I have three possible variations: 1. <div> <strong> <span…
-
1
votes1
answer2698
viewsMultiplication algorithm by sum for any integer
I have to develop a sum multiplication algorithm for any integer in the most optimized way possible. I thought the following: x*y=z;x,y belongs to the whole, so z=x+x y times. I know practically…
-
1
votes1
answer38
viewstranformative
def eR(k,x): if k<=1: return 1 else: return (x**k)/eR(k-1,x)*k x=int(input("Insira o X:")) k=int(input("Insira o número de…
-
1
votes3
answers126
viewsFormal definition of operations = and ==
What is the formal definition of the use of = and of == in Python? I can identify in the examples when I have to use which, but when I try to identify these operations by a formal definition as…
-
1
votes1
answer332
viewsScratch parameters of a post method, with scrapy in python!
I need to collect information from a website using Spiders within Scrapy in Python, but the site is a method post and I’m learning the language while developing the project. I found a model of post…
-
1
votes1
answer192
viewsproblems with return "None" in Python
Hello, I’m trying to get data from an API for a university job, but when trying to print the data I get the following error: Attributeerror: 'Nonetype' Object has no attribute 'text' Follows the…
-
1
votes4
answers658
viewsDebug showing variable name and value?
Often when I need to debug the value of a variable at runtime I use the print(). But when there are many variables, I need to identify the variable name along with the value. In this way, the print…
-
1
votes1
answer1460
viewsScroll (Scroll Screen) with Selenium in Python: Error
I have a list of items on the screen, in which I need to click one by one to parse data. It turns out that at some point, Selenium can’t click anymore, because when it tries, the following error…
-
1
votes1
answer130
viewsHow to create a "trigger" function when a variable changes value?
Watching pygame.Surface.get_rect(), I realize that when I change a variable, for example left, pygame automatically recalculates all class variables (center, right, etc.). I’d like to know how it’s…
-
1
votes1
answer641
viewsHow to create dictionary from lists
How to associate lists to keys and values to create a dictionary in Python? Is that the problem? I have a large csv file and I need to read the first line (I turn it into a list) that should be used…
-
1
votes1
answer5594
viewsThe python programming language can be used together with html
The programming language python can be used together with html? If so, how do I merge the two languages? In my knowledge, to call a file js in hmtl we can do it in 2 ways, by writing the script…
-
1
votes1
answer113
viewsError running web application in flask - Python
Hello, I am trying to run this application in Flask and when I try to view the page in the browser appears server error, when I delete the line of code that creates a list of items in which each…
-
1
votes1
answer1287
viewsReturn from a sub menu to the main menu of a Python function
I created a simple Python application for an agenda system with Sqlite3. There are 3 files in the main menu agenda.py the of contato.py and usuario.py who log in to the system. In the file…
-
1
votes1
answer130
viewsRecursive function of natural numbers is showing negative
I need a recursive function (exercise) that prints all natural numbers between A and B: def cont(a, b): if a < b: print(a) cont(a + 1, b) cont(-3, 12) The problem is that the way I did, the…
-
1
votes1
answer54
viewsDoubt regarding the Python syntax
Good evening guys, my question is about a piece of code I found in a book about Python and Opencv. The author created the function that I will put below: @property def frame(self): if…
-
1
votes1
answer339
viewsAbort a specific Thread
How do I interrupt a specific thread? for example: from _thread import * from time import sleep result = 0 def soma(nome, numero, delay): global result while True: result += numero print('{}: {}…
-
1
votes0
answers41
viewsFunction integration returns error "only length-1 arrays can be converted to Python scalars"
I’m trying to integrate a function into a certain range that shows the particle flux in a zero-angle (theta) direction as a function of the E energy of the particles. I’ve tried a lot of different…
-
1
votes1
answer176
viewsPython Guessing game
I have the following problem: every attempt of the user, the code does not accuse if it is cold, hot, warm, boiling. That is, does not give the tips to the player. If anyone can help me I…
-
1
votes1
answer88
viewsIf you have this word in the Curl answer, print "OK"
I made a Python URL to check some information of my client, everything is going well, the answer of my api is json, I would like to know how I do for if the api has, for example "userid", it samples…
-
1
votes1
answer85
viewsUrls accumulating in DJANGO
My urls are accumulating. When I pass via tag a[href="exemplo"] he sends it to url http://localhost:8000/index/, but if I click again on some other link from the same menu, it will redirect to…
-
1
votes1
answer198
viewsProblem with Python zipfile logic
I’m trying to make a python script to zip xls files. I managed to get it inside directory and is adding everything inside a file .zip. However I wanted it to go through all subdirectories and be…
-
1
votes1
answer534
viewsHow to remove list item within loop?
I’m trying to delete an item within a loop. I’ve heard it’s not possible. I’m seeing how to implement a comprehensive list. But I still don’t understand how it works. I tried to do so: result = [x…
pythonasked 6 years, 6 months ago Diego Souza 16,524 -
1
votes1
answer122
viewsLoaning another Jango user
Good Morning I checked user sessions through login and logout: In the login before logging it makes an Insert in my table: cursor.execute("INSERT INTO usuarios_sessoes (usuario, datahorainicio)…
-
1
votes1
answer55
viewsWhat does this variable mean?
I’m dealing with python and pycuda, studying codes and so on and came across the following question: What exactly is happening in the second line ? service will receive some attributes, in the first…
pythonasked 6 years, 6 months ago Dyonatha Kramer - Dean Cowboys 23