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
-
-2
votes0
answers13
viewsSAVE PYTHON TABLE IN EXCEL WITH EXCEL NAME BEING A VARIABLE
I have a code to do a simple cleaning in a table that I import from excel by pandas. The file that is imported is obtained through a code that recognizes the last modified file within a folder. When…
pythonasked 3 years, 2 months ago Walter Gabriel 1 -
-2
votes0
answers20
viewsCreate game in python
How can I stop creating a matching game in python?
pythonasked 3 years, 2 months ago Barretowow 1 -
-2
votes1
answer90
viewsproblems with IF and ELSE
I’d like to know how to get the program back to the first if or elif if the user’s answer does not fit the distance question. I put a else with a print("responda sim ou não") and if the answer is…
-
-2
votes1
answer129
viewsOptimization for code that tests if a number is prime
Hello! My question is about a code that I built, where the user inserts a certain number of their choice, and the program will test whether it is prime or not, however, it is testing all the numbers…
pythonasked 4 years, 9 months ago Bismarck1871 9 -
-2
votes1
answer73
viewsCode does not work [PYTHON]
I wrote a simple script that captures student grades through an auxiliary list and then plays everything within a larger list, including the average of students that is calculated during the code. I…
-
-2
votes1
answer93
viewsProgram restarts alone and only closes after 2 valid entries
Guys, I was doing some exercises of Gustavo Guanabara and I came across an intriguing situation: my code restarts and his does not!!! It’s Python World 3 Class 22 Exercise 112. I used a 3 file…
pythonasked 4 years, 9 months ago Paulo Oliveira 9 -
-2
votes1
answer792
viewsHow to compare python array in an array list and return the same or nearest array
I would like to know how I can enter with a vector and search in a list of vectors which has more equal or similar values using Python. Example: I have the following vector: search =…
-
-2
votes1
answer97
viewsGetting HTML attributes with python
I’m wanting to get the information from arial-label, href and title tag a down: <a aria-label="AS MAIS TOCADAS NO BAILE FUNK 2019 #1 - SET DE FUNK by Funk 24por48 10 months ago 39 minutes…
-
-2
votes1
answer128
viewsQuery data in a txt file with python Tkinter
I’m creating a simple system to query employee data stored in a file txt. def read_from_file(): with open('dados.txt') as file: for line in file: line = line.rstrip('\n') nome, matricula,…
-
-2
votes3
answers347
viewsCreate list with the sum of consecutive equal numbers
That’s my structure, but the if, elif and even the else (although not in the code), they are not working. The code is printing several lines as if they were if'separate s and the function has to add…
-
-2
votes1
answer38
viewspandas and sqlalchemy
Hello, I’m trying to create a mysql database connection in a python program, follow the code import pandas as pd import sqlalchemy engine =…
-
-2
votes1
answer36
viewsExclude items from another list
I wanted to know how I could delete from a list, the elements from another list (which will be used #for training) and stay with only the elements for testing, contained within the initial list. I…
-
-2
votes1
answer59
viewsWhy is error returned if you add a String with a Number?
If I type the following in the terminal of the Python no error is returned and the result is displayed normally. In the terminal: >> 10 + "10" # 20 But if I put in variables and try to add up…
pythonasked 4 years, 8 months ago felipe cardozo 275 -
-2
votes1
answer322
viewsCode creation in Pyhton
Hello I would like a help, I need to resolve the following question: Suppose a cashier has only 1, 10 and 100 real notes. Considering someone is paying for a purchase, write an algorithm that shows…
-
-2
votes1
answer105
viewsError using matplotlib
Good afternoon, you guys. I’m starting to work with python and need to generate a graph of a txt, this is divided into 3 columns (where it represents x,y and z) and these are separated by 3 white…
-
-2
votes1
answer99
viewsHelp to send data by python post method
I’m making a Checker for studies, I have a login api, but I keep coming up with this error: <Response [403]> I also tried to request post by Postman and gave the following error: { "sucesso":…
-
-2
votes2
answers81
viewsCompare dates - Text Mining
I made a code for texte Mining, but I’m having difficulty comparing if the date that was identified has already passed + 1 year. I would like a help or a vision that can help in my understanding.…
-
-2
votes2
answers159
viewsI would like to know all the combinations of 5 numbers between 0 and 100 that add up to 100
Good night, I need to find all combinations of 5 natural numbers, between 0 and 100 (can be 0,0,0,100 (can repeat)) that sum up to 100, I adapted the code below to do this, but for some reason the…
pythonasked 4 years, 7 months ago RODRIGO ZAMENGO 7 -
-2
votes1
answer1350
viewsPython Selenium does not perform the send_keys function
I’m trying to make a bot to comment alone on youtube video, it’s working normally, until it’s time to type the comment. I have already researched everything that is place and I found nothing that…
-
-2
votes1
answer42
viewsI cannot make two modules of the same package "recognize"
Good evening, I’m learning more about importing and creating packages. But I can’t get two modules to "communicate", follow the link: https://github.com/Gramosa/Importacao_teste If you look at the…
-
-2
votes1
answer108
viewsPrint np.array, formatting
Full class: class Tupla: def __init__(self, keys, palavras): self.keys = list(keys) self.palavras = list(palavras) self.op = dict(zip(self.keys, self.palavras)) def __getitem__(self, key): return…
-
-2
votes1
answer69
viewsFiltering information from . JSON
I have the following script: import json import requests def clima_semana(): requisicao = requests.get('http://api.openweathermap.org/data/2.5/forecast?q=Rio de…
-
-2
votes1
answer181
viewsLoad a variable from a file with module. Django/Python
Hello, my name is Marvin, I’m a beginner in the area and I have a problem giving a 'POST' a 'file.py' variable to my local server Django. I use a module called 'openpyxl' that serves to load a table…
-
-2
votes1
answer136
viewsRemove lines less frequently from pandas.dataframe
I own a dataframe with more than 13000 lines and would like to remove some based on the frequency with which they appear taking into account the column named variedade. df.variedade.value_counts()…
-
-2
votes5
answers9733
viewsplaying mp3 files in Python
I was doing Video Course exercises on Python and I stagnated on Challenge 21, whose goal is to make a program that touches an mp3 file. However, I have tried as shown in the video and it did not…
-
-2
votes1
answer29
views(Python) I also have a text file with a few words
def carrega_palavras(): with open("palavras.txt", 'r', encoding='utf-8') as arquivo: palavras = [] for linha in arquivo: linha = linha.strip() palavras.append…
pythonasked 4 years, 6 months ago Raphael Theodoro 1 -
-2
votes2
answers224
viewsHelp in college exercise
The statement is: Create a program that receives as input the total amount of a debt (natural number greater than zero) and the maximum amount that the debtor can pay every month (natural number…
-
-2
votes1
answer1094
viewsRead Python Json file (beginner)
Good morning! I’m starting in python and I’m not able to read two specific fields in the generated json, with the following format: [ { "nomeArq": "arquivoA", "dataAnt": "28042020", "dataAtu":…
-
-2
votes2
answers155
viewsHow can I do this recursive function
Implement a recursive file_recursive function it receives a list and a number and returns the list, except every time the number appears For example filtro_recursivo([0,1,2,1,4],1) returns [0,2,4]…
-
-2
votes1
answer74
viewsPrint elements of a regex in sequence in python
Good afternoon guys, I am new in python and I am learning a few with this I would like to ask help from you, I have the following source code taken from a site: <div class='numerando'>1 -…
-
-2
votes1
answer255
viewsHow do I navigate through a Python list for each function call?
I have this code as an example: # 0 1 2 3 4 lista = ['1','2','3','4','5'] def nexxt(): for item in range(len(lista)): item += 1 print(lista[item]) def back(): for item in range(len(lista)): item -=…
-
-2
votes1
answer421
viewsscraping google
Regards I am writing a script in python3 to perform news searches and tbm images... and created queries for Bing google using Apis mechanicalsoup and requests. the case is over with google, after a…
-
-2
votes1
answer497
viewsIdentify if a matrix is triangular upper, lower or diagonal
I need to receive a matrix and identify if it is an upper triangular matrix, a lower triangular matrix or a diagonal matrix (upper+lower) I wrote a code initially to find out if it is diagonal…
-
-2
votes1
answer147
viewsPython Dictionary - Most Common Word Count
good night. I am studying dictionaries, I have developed the following algorithm for word accounting in articles contained in TXT’s files and display of more frequent words, but I am not able to…
-
-2
votes2
answers56
viewsI can’t find the highest value in a flip-book dictionary
I need to find the highest dictionary value using a function running with the 'for' loop I was able to find the values of all the other sets, except the dictionary values. To generate the dictionary…
-
-2
votes1
answer67
viewsPython: Error in . write() method
I wrote a code that would run on my Desktop. The script would write a text in another directory. To switch directories, I used os.chdir(), then used subprocess.check_output() to execute a shell…
-
-2
votes2
answers94
viewsHow to make a replacement using the tuple list in python
The question asks for : A buffet restaurant offers only five basic types of food. Think of five simple dishes and store them in a tuple. • Use a for loop to display each dish offered by the…
-
-2
votes1
answer36
viewsCan someone help me for when to give Else:print("Sorry but there is no such option"), he restart the program?
print("--- Calcular Queda Livre ---")`insira o código aqui` opcao=int(input("""Digite: 1 para Função Horária da posição; 2 para Função Horária da velocidade; 3 para Equação de…
-
-2
votes1
answer85
viewsPython Array - Highest list value
I’m having trouble solving an array exercise in Python, can help? Description: A store with 4 branches wants to register the daily sale of each branch for 1 week period. Create an array to store the…
-
-2
votes1
answer50
viewsHow to break this code if return is two equal numbers
good afternoon! I have a problem where if the user type, two equal cities, the loop is interrupted. However, even putting a conditional and adding BREAK, the loop does not stop, you can help me?…
-
-2
votes2
answers873
viewsPython Note Release Exercise
Hi, I’m a beginner in programming, and I have a college exercise to do, I managed to do a part, but I don’t know how to program the rest of it. It’s a three-note-release python program per student,…
pythonasked 4 years, 5 months ago Breno Leonetti 33 -
-2
votes1
answer351
viewsI’m having trouble making the character move in python with pygame
import pygame pygame.init() tela = pygame.display.set_mode((800,600),0,32) personagem = pygame.image.load('./você.png').convert_alpha() def…
-
-2
votes1
answer121
viewsJupyter Notebook does not rotate, I do not know what can be
import csv import pandas as pd import matplotlib.pyplot as plt import numpy as np import seaborn as sns %matplotlib inline %matplotlib notebook caminho_dataset =…
pythonasked 4 years, 5 months ago Josney Faryj 1 -
-2
votes1
answer232
viewsHow to automate PDF download with Selenium?
I’m trying to automate a daily entry to the Official Gazette, http://www.imprensaoficial.com.br find the date, the desired section and download each page of the pdf section. Page numbering changes…
-
-2
votes1
answer57
viewsHow to sort a list through an object attribute?
I am doing an activity, and wanted to make the list come out alphabetically from the name of the project, someone would have some solution ? class Projeto: def __init__(self, nomep, contato):…
-
-2
votes1
answer782
viewsInitial values of an exponential moving average in python pandas
Hello, I’m trying to implement the calculation of an exponential moving average with the python pandas package. I know there are several ways of exponential weighting for a moving average, but the…
-
-2
votes1
answer90
viewsCalculator of a P.A in python
print('='*50) print('Digite X para calcular o que você não sabe em um P.A') print('='*50) a1=int(input('Digite o 1° Termo:')) r=int(input('Digite a RAZÃO da P.A:')) an=int(input('Digite o ULTIMO…
pythonasked 4 years, 3 months ago CHFerreira 11 -
-2
votes1
answer70
viewsin my code is always giving the following error 'name (name) is not defined'
print('-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-') print('Welcome(to) koalas' log screen!') print('register now, it’s simple, fast and easy!')…
-
-2
votes1
answer43
viewsIn this program, I wanted it to include in the final list the even numbers of the first list and the odd numbers of the second, why doesn’t this happen?(python)
*In the final list, numbers appear that were not supposed to be there, for example 103, which is an odd number from the first list. lista_1 = [10,24,50,103,30,12] lista_2 = [13, 16, 39, 14, 107, 35]…
-
-2
votes1
answer64
viewsHow to find the accuracy between two columns of a data frame?
I have two columns of the same order csv, one that was written and the other that should have been written. I have three questions 1 How do I find the accuracy between them (or the more the lines in…