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
-
-3
votes1
answer70
viewsHow to join three or more CSV files with something like PROCV and concatenating certain columns
Arquivo1.csv Codigo Nome Catego Geral Model Ano A1 JOGO LAMA FZ25-A|YS250|FA250AB 44CF 2017 A2 EMBLE LAMA FZ25-A|YS250|FA250AB 44CF 2017 A3 TUBO ADMI FZ25-A|YS250|FA250AB 44CF 2017 A4 PRESI ADMI…
-
-3
votes1
answer40
viewsError while converting bytes file into literal string in python
I select to bring an xml file that is stored as a blob in the oracle database. I read the file and save the contents in a variable. When checking the type of the variable is of type bytes. I do the…
-
-3
votes1
answer56
viewsReturn tag element in Beautifulsoup
Website: Subway network of the city of São Paulo. Goal: Scraping of the name of the stations of each line. Difficulty: I’m not able to isolate the names, for example: Jabaquara, Freedom... from bs4…
-
-3
votes1
answer163
viewsAlphabetic Triangle - Python
I have an exercise where, the enunciating informs the following: The Latin alphabet is composed of letters, beginning with 'A' and ending with 'Z'. There are twenty-six different characters, if we…
pythonasked 3 years, 8 months ago Mardoquel Gadi 13 -
-3
votes1
answer71
viewsPyqt5 - Identify who pressed F10 on a Qlineedit
How do I open a function by pressing the F10 key on a Qlineedit? Searching found the function "returnPressed" but only works for the "Enter" class Ui_MainWindow(object): def setupUi(self,…
-
-3
votes1
answer59
viewsHow to call function within another function in Python?
Hey, you guys. I’m new to Python and need to deliver a script of requests Apis. There are three attributes required to request the API (client_id, client_secret and text), and the two "clients" are…
-
-3
votes1
answer298
viewsPYTHON: Nameerror: name is not defined
What’s wrong with this code so I can’t call the function pontosNaBorda? def pontosNaBorda(v0, v1, v2): # v0, v1, v2 são coordenadas dos vértices de um triângulo return v0 def main(): alienigenas =…
-
-3
votes1
answer44
viewsPANDAS - PYTHON - FIND DIFFERENT VALUES
Good afternoon to you all! I’m starting some Python studies and to put into practice I’m trying to optimize some routines for my work. In the sector where we work we have the habit of crossing a lot…
-
-3
votes1
answer23
viewsForce the user to answer a valid alternative in a multiple choice Python question system
The code below works well, but I would like it to ask the specified question again if the user does not type one of the three available alternatives. perguntas = { 'Pergunta 1': { 'pergunta':…
-
-3
votes2
answers86
viewsHow can I simplify these two functions?
This code sums the columns and rows of a matrix separately. I created these two functions to do this and I need to simplify my code by transforming them into one. Note that the only thing that…
-
-3
votes1
answer44
viewsHow to move between windows?
I’m creating a simple system just to learn a little bit about the Tkinter library. However, I stopped right here. The idea is to create several pages in the same code (I know that the correct one…
-
-3
votes1
answer35
viewsI can’t get all my options working
Only 1 calculator option works, the others don’t even print anything when they are called! Someone can help me? import datetime from datetime import time from datetime import datetime from datetime…
-
-3
votes1
answer58
viewsCALCULATE PERCENTAGE OF SELLERS
THE QUESTION THAT CALLS FOR THE FOLLOWING: 1st proposal: Prepare arrangements (indexed variables) of, at most, 10 positions. Receive the name, registration and total sales, calculate the respective…
-
-3
votes0
answers19
viewsUpdating a Gsheet with Gspread and pandas
I am getting a bit to use python and am trying to update a google sheet through gspread and reading a CSV that is on my pc with pandas. my code stayed: import gspread from…
-
-3
votes0
answers37
viewsHow to create random variables in normal distribution with mean and standard deviation in Javascript?
I have a problem creating a variable with normal distribution in JS, I know the option math.random() is limited and that the chance of each value between 0 and 1 is equal (rectangular distribution),…
-
-3
votes1
answer32
viewsGrab information, open window and only release window when entering a password. Python
I will simulate an attack on my company to identify the most vulnerable users to intensify training in order to avoid ransomware and type viruses. I’m trying to create a little program. exe to take…
-
-3
votes1
answer55
viewsError using Decorator in a Setter method
I’m trying to implement a simple Python code to practice using decorators in conjunction with advisory methods (Getters and Setters), but I’m getting an error. The code is as follows:: class…
-
-3
votes0
answers36
viewsPython code by duplicating the result of an array
I have a routine, in which, I need to create a matrix, which will be used to create some graphs. The code is structured as follows:: 3 lists for x, y, y 3 lists feeding the axes 1 for client sets…
-
-3
votes0
answers61
viewsHow to make web scraping with Selenium on all pages of a website?
I’d like to do web scraping with Selenium on every Free Market offering page, but so far I’ve only been able to do it on the first one. I use Pandas to store the data in a dataframe. How do I do it…
-
-3
votes0
answers21
viewsChatbot returning "I don’t understand" when it doesn’t work
I’m wanting my Chatbot to recognize the names using JSON, but they always return "not understood" when not right. Any hint to fix this ? import json class Chatbot(): def __init__(self, nome): try:…
-
-3
votes0
answers14
viewsProgramming error
python error At UFRJ, the professor of Physics wishes to make a survey among his students to discover the highest and the lowest. For this you must make a program that asks each of the students…
-
-3
votes0
answers16
viewsI’m having a Typeerror: '_io.Textiowrapper' Object is not subscriptable
import json def abrir(): with open('estoque.txt', 'w+') as nome: nomez = str (input('Digite Nome do Produto: ')) Quant = int (input('Digite Quantidade do produto: ')) PC = float (input('Digite o…
-
-3
votes0
answers15
viewsPOO python code
Someone who knows how to make that code: A perfumery company has two products in its line: perfumes based only on essences and natural ingredients and perfumes based on artificial fragrances.…
-
-4
votes1
answer804
viewsCount amount of "holes" in the letters of a text
I need to write a program in Python that counts the amount of "holes" in a string. Imagine, for example, that the letters "A", "D", "O", "P", "R" have only one hole. Similarly, the letter "B" has…
-
-4
votes4
answers21246
viewsDoubt average with Python 3.5
I am creating a program, using Python 3.5, to calculate average, but in my school there are some subjects with two teachers, and each one gives a different test. The problem is that the code I…
-
-4
votes2
answers161
viewsI can’t convert to whole
Perform a function that reads a text file containing a list of IP addresses and generates two other files, one containing valid IP addresses and the other containing invalid addresses. The format of…
pythonasked 7 years, 7 months ago Lucas Soares 47 -
-4
votes1
answer134
viewsCheck which one is larger using a python formula
I need to use this formula and read three values and present the largest of the three values read. Formula: MaiorAB = (a+b+abs(a-b))/2 All three values are on the same receiving line. EX: MaiorAB =…
-
-4
votes2
answers824
viewsHow do I make the program show all the combinations and then the number of combinations that were formed?
What I’ve got so far: from itertools import permutations word = str(input()) for subset in permutations(word,len(word)): print(subset)
pythonasked 7 years, 3 months ago Lucas Souza 567 -
-4
votes2
answers3074
viewsHow to calculate numbers in a given range?
How could I compute the sum of the numbers in a range of 1 to 500 in which the summed numbers of that range should be odd and multiple of three? I only managed to take the break so far: for c in…
-
-4
votes1
answer81
viewsHow to improve my code?
from random import randint from time import sleep import sys def processar(): print("Processando...") sleep(3) print() def voltar(): print("1 - Voltar…
pythonasked 7 years, 5 months ago Diego Neto 5 -
-4
votes2
answers947
viewsHow to turn all items in a string list into integers?
I have a list containing "n" elements like str. However, I need to make these elements come whole. How can I do this ? For example, I have this list here: trechos = conteudo[2:len(conteudo)] Turns…
pythonasked 7 years, 2 months ago GratefullyDead 373 -
-4
votes1
answer77
viewsPython - I would like some examples of using "APLICATION/LD+JSON"
I’ve always worked with REST for integrations, now I’m using a new system where I can’t use only pure JSON, they use LD Json, and I still don’t quite understand this concept and I’m having some…
-
-4
votes1
answer172
viewsCreate functions in Python
I want to create a function that receives a vector of 10 records, in which each has name, state (SP or RJ) and age. And then a return function of how many people are from the same state. How could…
-
-4
votes3
answers1369
viewsCalculate the sum and mean of a numerical sequence
In sequence 3,5,7,9,11,13,15. Discover the pattern of the sequence and: a) Make a program to display 12 values of this sequence started by 3. b) Show the sum of 'ALL' values (12 values). c) Show the…
-
-4
votes1
answer89
viewsprogamma error
def trianguloPascal(n): lista = [[1],[1,1]] for i in range(1,n): linha = [1] for j in range(0,len(lista[i])-1): linha += [ lista[i][j] + lista[i][j+1] ] linha +=…
-
-4
votes1
answer151
viewsWhat’s the matter? I use Pycharm
def par_ou_impar(result): divided = str(result).split('.') if len(divided) < 2: if divided[0] % 2 == 0: print('O resultado é par') else: print('O resultado é ímpar') if int(divided[1]) % 2 == 0:…
pythonasked 6 years, 9 months ago Igor Munhoz 1 -
-4
votes1
answer258
viewsHow do I stop For when the range is 5?
How do I stop the For cycle when it reaches a certain condition ? For example, it would be when c equals 5. for c in range(1,10): print('a,b,c') if c % 5: break Then a function will be used, but I…
-
-4
votes2
answers63
viewsNot all arguments were converted during string formatting. What does that mean?
f=open("arquivo.txt", 'w') I’m making a code to plot a Gaussian on the random walker (Statistical Mechanic) and is giving this error when saving in the file my "Count". That is the code: for j in…
pythonasked 6 years, 5 months ago Bernardo Cecchetto 21 -
-4
votes1
answer142
viewsReverse order commands/upper/ switch
I am doing a job (Python 3) and need help to complete the codes. I need to know how I reverse the order, for example 2345 in and out of 5432. I also need to know how I leave only one uppercase…
-
-4
votes1
answer112
viewsBecause list does not accept [01,02,03,04]
I’m starting in Python, I want to create a list of numbers, I wanted to use dezenas = [[01,02,03,04],[05,06,07,08],[09,10,11,12],[13,14,15,16],[17,18,19,20],…
-
-4
votes4
answers6021
viewsHow to create a function to find the highest value in a list?
I’m not getting this algorithm into a function max_trip = 0 for val in trip_duration_list: if int(val) > max_trip: max_trip = int(val)
-
-4
votes1
answer2376
viewsSelenium.common.exceptions.Nosuchelementexception: Message: Unable to locate element: {"method":"id","selector":"//input[contains(@id,
When using the code: self.browser.find_element_by_id("//input[contains(@id,'seq')]") I get the error message: selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element:…
-
-4
votes1
answer190
viewsWhat’s the difference between Django and Flask
What is the difference between Django and flask framework benefits and which one is currently most used in the market?
-
-4
votes2
answers1757
viewsRequest whole numbers and count even and odd numbers
Question: "Make a program that asks the user 5 integer numbers and, to final, enter the amount of odd numbers and pairs read." I’m having a hard time on this issue, I really don’t know how to get it…
-
-4
votes1
answer80
viewsMake a personal assistant
Hello, I am developing a personal assistant in Python, however I would like to use a process similar to that of "OK Google", where when I speak the phrase, the program runs. That is, when I say…
-
-4
votes1
answer41
viewsHow could I reduce this code?
def hello_quantum(string): """ hello_quantum: cad. caracteres --> lógico funcao permite jogar o jogo praticamente, permite o uso das portas para manipular o tabuleiro com o objetivo de igualar o…
-
-4
votes1
answer51
viewsI can’t figure out what’s causing this mistake
I’m doing a python project of game four online and have the value function that tells me what value is placed at a certain point of the table. grelha = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0],…
-
-4
votes2
answers59
viewsHow to ensure that three conditions are met? Is there a better way to do it?
Program that asks a person’s age, weight and height and decides if they are fit to join the army. To enter, it is necessary to age, weigh more or equal 60 kg and measure more or equal 1,70 meters.…
-
-4
votes1
answer306
viewsList count without repeating print - Python
I’m solving a college list, but I can’t find a way to show the numbers count without repeating the print. For example, when the number is repeated I want to print only once and I am not able to do…
-
-4
votes1
answer120
viewsWater and carboy exercise
"Suppose you have a certain amount of empty bottles with a capacity of 5, 1.5, 0.5 and 0.25 liters. Admit that you have an unlimited number of bottles of each type. Given a certain amount of water…
pythonasked 5 years, 11 months ago Rodrigo Ferreira 9