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
votes0
answers81
viewsPush Notification and Django problems (vapid_private_key)
I was able to reproduce an example with the repository pywebpush to make the push notification. After breaking my head to understand, I was able to do it. However, when I tried to integrate with my…
python django push-notification progressive-web-appsasked 6 years, 12 months ago Guilherme IA 1,414 -
1
votes2
answers116
viewsSorting algorithm not working!
""" Arrange the elements of a list in ascending order """ #ordenação bolha #L = [5,3,1,2,4] L = [7,4,3,12,8] x = 0 while x < (len(L) -1): if L[x] > L[x+1]: L[x],L[x+1] = L[x+1],L[x] x += 1…
-
1
votes1
answer785
viewsRemove duplicate elements from a python chained list
My code returns error when trying to run: class No: def __init__(self,inidado): self.dado = inidado self.proximo = None def pegaDado(self): return self.dado def pegaProximo(self): return…
-
1
votes2
answers316
viewsProgram to ask multiplication questions
I intend to make a program in Python (2.7.14) that generates two numbers randomly (from 0 to 10), multiply them, ask the result for the user, and display whether the result is correct or wrong,…
-
1
votes1
answer1033
viewsAdjust Image Range using Python
I’m a beginner in python, but I have experience with other programming languages. I need to do some college work, but I don’t know how to proceed. I would like to know how to adjust the range of an…
-
1
votes1
answer1100
viewsfirst-fit, best-fit and Worst-fit python
I have to make one software implementing the memory management algorithms first-fit, best-fit and worst-fit, I know their concept, the first-fit puts the dice in the first space that fits, best-fit…
-
1
votes2
answers364
viewsLogic to get the lowest user read value
What’s wrong with my logic? I can’t return the smallest value def menor(size): size = size vet = [0] * size menor = 0 for i in range(size): vet[i] = int(input('Digite os valores: ')) if vet[i] >…
-
1
votes2
answers3726
viewsTurn columns into rows into a dataframe
I have a dataframe with the columns: LUC Contrato Fantasia Ano Mes 01 02 03 05 ... 30 Tatividade I need to turn these columns with the days of the month into rows. In each column has the value sold…
-
1
votes0
answers34
viewsMake it open and reopen every time a number of Python and Selenium tabs
I need this code of mine every hour to make the process of reopening all tabs or setting up or just closing everything and running this code every hour. Has as? from selenium import webdriver import…
-
1
votes1
answer153
viewsProgram to pick up on a web page events
source code here too: https://pastebin.com/DesqWJfY Objective: to catch events in http://www.bhaktiyogapura.com/2018/03/calendario-vaisnava-marco-2018/ Each month, the URL changes only the fine, for…
-
1
votes1
answer1502
viewsHow to print an element from a list of lists in python
I have a list of lists, like: [ ('name1',size1), ('Nome2', size2)] I want to print just the name of each list, how could I do it?
-
1
votes3
answers1877
viewsList a range of numbers and add one by one
I am with this doubt I do not know how to start, I wonder how could I do to add a number with another of a range for example: 2 = 2 3 = 5 4 = 11 And so on I’m not succeeding, if anyone can help me…
-
1
votes1
answer2170
viewsCalculation of sum of digits
Write a program that receives an integer number in the input, calculate and print the sum of the digits of this number in the output Example: >>>Digite um número inteiro: 123 >>>6…
pythonasked 6 years, 11 months ago Larissa Silva 13 -
1
votes1
answer143
viewsParse numerical set for sequential numbers
I have, small part, of the data below, sequence of numbers: a = [(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15),(6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 19, 20, 23, 24, 25),(1, 2, 3, 4, 10, 11, 12,…
-
1
votes6
answers2884
viewsmusic does not play
I have the following python code #*-coding:utf-8;-* import pygame pygame.init() pygame.mixer.music.load('ex1.mp3') pygame.mixer.music.play() pygame.event.wait() In this case, it should play a song…
-
1
votes0
answers327
viewsHow to send an image correctly via Socket in Python
I am trying to send a picture of the dir directory to another client of my network. The sockets are working properly, the image arrives at the destination and is saved, but when I try to open it I…
-
1
votes1
answer110
viewsHow to transform a numpy.array of size 497305 into a smaller 4999 without adding new elements in the calculation?
I’m analyzing an audio and my scikit ML model generates an array of probabilities that certain element in the array corresponds to a category "A" used to train the model. Each element of the array…
-
1
votes1
answer121
viewsSelect within for
Next, my doubt is more about logic anyway.. I have a python script in which I use psycopg2 to perform database searches. But I need to do this within a for. I have full notion that doing a search…
-
1
votes1
answer174
viewsGenerating functions: What are the advantages of using them?
Generating function: def geraQuadrados(n): for i in range(n): yield i**2 for i in geraQuadrados(5): print(i) no generating function: def novosQuadrados(n): l = [] for i in range(n): l.append(i**2)…
-
1
votes2
answers10008
viewshow to remove n from a python string
I’m trying to delete control sequences (\n, \t, \u) of strings in Python and I can’t even with replace, nor with re.sub(). How could I do? I tried, and they didn’t work : p = re.sub('\n', '', p)…
-
1
votes0
answers258
viewsLimiting the response time of a function
I did a script on python 3 that performs speed tests on my internet every 60 seconds and writes these results in a file .txt. Within this script I have a function called get_results which is the…
-
1
votes1
answer2967
viewsFigure Legends
I would like to know why a marker in the 2dB column on the 10 0 line appears in the image and how I can eliminate that without erasing the markers on the blue line, which is what I want? The code to…
-
1
votes1
answer952
viewsTXT File Manipulation using Python
Let’s say I have one arquivo.txt which is separating the information only by the comma, for example, X,Y,Z,W 1,2,3,4 How do I modify such a file and save it so that it is a table without the…
pythonasked 6 years, 7 months ago F. Oliveira 69 -
1
votes1
answer1300
viewsExchange of information between Python classes
How can I exchange information between two different classes? I need to pass data from one to the other. Each class is running in a different process. An example of the structure, the code is too…
-
1
votes1
answer3482
viewsSend POST form with python
I am developing an API in my work, and I need to develop something in python2 that sends a form to the server through the POST, I saw some questions here on the forum and I could not find anything…
-
1
votes1
answer252
viewsType error: not all strings converted during formatting
I’m trying to make a match or a match. The problem is that every time the sum of my move and that of the computer is 'even' this error message appears. I have tried other types of formatting and…
-
1
votes2
answers95
viewsHTML alignment using Python
I need to line up a html code, in some parts it comes totally "messy", example: <li><a href="dsadas">dsadaads</a></li><li><a…
-
1
votes3
answers648
viewsI can’t download "pygame" or "kivy" via the "Pip install..." command
When I try to download the pygame appears the following, remembering that my pc is windows 10 - 64bits. python 3.7.0b3 (64bits)
-
1
votes0
answers893
viewsHow to correctly read a JSON API and create list?
In Python3 I made a program to read an API (from the House of Representatives) and get the data in JSON import requests import pandas as pd url =…
-
1
votes1
answer120
viewsNumpy complex dType, with fixed array of variables, using fromfile function to import binary file
I am reading a complex binary file, where there is a fixed structure of 'array' of values, someone could help? The structure is: 8 bytes = Long Current Time (unixtime stamp) 8 bytes = Long Current…
-
1
votes0
answers330
viewsHow to use while on Tkinter to make Par or Odd game?
I’m starting now and so I’m super lost, this and my code: from random import choice from tkinter import * janela = Tk() janela.title("Jogo do PAR ou IMPAR!") fontPadrao = ("Arial", "10", "bold") def…
-
1
votes0
answers245
viewsExtract names and import into an excel spreadsheet
I need to read files TXT and remove from them names of persons and their respective "functions" of the text. They are minutes of hearing, where I need to find the name of the parties (Plaintiff and…
-
1
votes0
answers51
viewsAre tuples really immutable in Python?
t = (1,2,[4,6]) t is a tuple. If we do: t[2][0]="e" we shall have: (1, 2, ['e', 6]) Now the tuple t is (1, 2, ['e', 6]) We didn’t change the tuple? Be it s= "stackoverflow" It is not possible to do,…
-
1
votes1
answer1648
viewsIs there any way to pass a class instance as a parameter of a Python method?
I’m doing an implementation of the Star algorithm(A*). My doubt is just that of the title, I come from java and c++, and I do not know how to do this in python. def transfTo(Bucket a):…
pythonasked 6 years, 7 months ago Rafael Oliveira 13 -
1
votes2
answers690
viewsSubmit form in python
I’m trying to submit a form on the website https://www.loskatchorros.com.br/ucp/login.php ,but I’ve searched several ways here on stackoverflow how to submit a form, and found no way to solve this…
-
1
votes1
answer677
viewsCould someone help me identify the error? 1179 Vector IV Completion -URI
So guys, I’m studying Python during the college holidays and I came across this problem at the URI. I’m still a beginner in language and programming in general. Could someone tell me why the…
pythonasked 6 years, 11 months ago Jonatas Teixeira 11 -
1
votes1
answer356
viewsWhat is the AS in Python for?
Please someone help me with this. Explaining why, what and how AS works in Python.
-
1
votes2
answers778
viewsDoubt about the Slice function
To the answer back that one question that the Guilherme Nascimento P. did, opened up a doubt on the use of the function slice, until the moment I had no knowledge of it, and to find it in the…
-
1
votes1
answer197
viewsCassandra installation error - DRIVER in python
Hello, I’m trying to create a development environment with python and Cassandra, however I’m having difficulties to install the connector in python, follows below the environment I currently have…
-
1
votes0
answers589
viewsPython3.5 - Import multiple files from one folder
I have the following code: __author__ = 'Jones_Santos' # !/usr/bin/python3 import os from __init__ import mycursor, connection import csv import os from datetime import datetime, date, timedelta,…
-
1
votes0
answers46
viewsScript to deploy Pipenv (Python)
Hello, in the company where I work firewall rules do not allow servers intended for the intranet to have access to the web. Thus, work with venvs, where dependencies are installed with pipenv…
-
1
votes2
answers2726
viewsRecursive function to return string backwards
I need a recursive function that returns the string it takes as the inverted form parameter,arrived in this role: def stringinvert(palavra): if palavra < 10: print(palavra) return…
pythonasked 6 years, 7 months ago GratefullyDead 373 -
1
votes2
answers421
viewsDoubts of python
I’m new to python, and I’m looking to make a system, where you fill out a questionnaire, and consequently it already prints in html to just paste in the forum. What I rode was the following: from…
-
1
votes2
answers1944
viewsHow to repeat a code?
Hello I am new in python and I would like to know with respect the code soon after its termination. Since there are several If and Else in the code. Just in case here’s my code. print ("\n\t…
-
1
votes1
answer382
viewsCondition with Python letter
I want just a simple example of: test = input('Letra: ') ai if the typed letter is ' a' (here I’m having trouble) print('exemplo') I want when I type "a" to appear a message..........…
-
1
votes2
answers875
viewsIs it possible to replace the Javascript language with Python in web development?
It is possible to replace the Javascript language with Python, I mean, instead of using Javascript to interact with the user on the web page, there is some way for me to write this interaction in…
-
1
votes1
answer1281
viewsHow to delete an entry from a Python file without having to read the entire file?
I have a file with the following entries: Ana Joao Pedro José .... And I need to delete the line with the name Pedro, it would be easy for me to read the whole file, save in a list delete Pedro and…
-
1
votes1
answer42
viewsWhy does this method return me 2?
I have a code to analyze and I’m not sure understand why this method of my Binary Tree returns me 2. Code: class No: def __init__(self, dado): self.esq = None self.dir = None self.dado = dado class…
-
1
votes1
answer781
viewsSize of Binary Tree
I need to develop a method to calculate the size of a Binary Tree but I’m getting compiler error. Code: class No: def __init__(self, dado): self.esq = None self.dir = None self.dado = dado class…
-
1
votes1
answer90
viewsDjango Models with default value in another branch
I have a field that I added to another branch (which has status developing) calling for money, with default value: 0.00 in the model User. However, it is not yet being used in the production branch.…