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
answer164
viewsSave user typed equation in python
How could I save a math equation typed by the user and then replace values in this equation? EX: User typed: "3*x+2" then the program replaces "x" with 1, showing at the end the value 5 (3*1+2)…
pythonasked 5 years, 8 months ago Roberto Jr 3 -
0
votes1
answer79
viewsHelp me syntax my FOR repeat code
I want to return the percentages of video game genres, only this part of the code does not return all the results. porcent = pd.DataFrame(base.Genre.unique()) totalPorcGenre = len(base) for porcen…
-
0
votes0
answers67
viewshow to modify a certain value or letter within a python text
i have the following text 1050 = N X 0 1260 = N X 0 1470 = N X 0 1680 = N X 0 1890 = N X 0 2100 = N X 0 2310 = N X 0 2520 = N X 0 2730 = N X 0 2940 = N X 0 3150 = N X 0 3360 = N X 0 3570 = N X 0…
-
0
votes1
answer1579
viewsHistogram Python Opencv
Hello, I would like to define a histogram of a function I created to detect an image region. That’s the job of. def points (imagem, pontosFaciais): p68 =[[47, 35, False], [35, 12, False], [12, 13,…
-
0
votes1
answer839
viewsHow can I improve my hangman game code?
What tips would you give to improve this code of the Python hangman game? In the "course" I’m doing Python I haven’t learned to use string methods yet. It’s a very simple hangman game, with no…
-
0
votes1
answer37
viewsConvert dictionaries to class
I have a dictionary that contains the name of the activities and some characteristics of this activity. I created a class called process and I want to iterate in my dictionary creating the…
-
0
votes1
answer68
viewsIndex error as non-existent
I’m getting an error message on line 7 of the code, which says url=to_crawl[0] - Indexerror: list index out of range import requests import re to_crawl=['https://www.globo.com'] crawled=set()…
-
0
votes1
answer50
viewsoptimize python code snippet
I’m starting in the world of Python, I wrote the excerpt below and wanted your help to make it more efficient: dforigin = pd.read_csv(client_file_name.csv, sep=';') total_line_number =…
pythonasked 5 years, 7 months ago Sabrina Bergoch 1 -
0
votes1
answer1052
viewsCopy range of values from one Dataframe to another transposed
I would like to copy multi-range values in a df1 with 721 rows and multiple columns, and paste in a df2 transposed form. Something like that: I tried something like: df1.T…
-
0
votes1
answer3684
viewsHow to calculate 'end time' in Python?
qpd = int(input('Quantidade produzida: ')) # qpd = Quantidade Produzida qpg = int(input('Quantidade programada: ')) # qpg = Quantidade Programada qrs = qpg - qpd # qrs = Quantidade Restante qpc =…
-
0
votes1
answer1885
viewsTkinter how to change color of text
How do I change the color of a label to make the background black and the letters white ? I researched and what I found was the option to change the background to black however beyond the label…
-
0
votes1
answer62
viewsI can’t do the "web scraping" properly from a Python comic strip site
Well, I was making a code that would check the day of each strip/gif of the page and, if the day is the same as the current day (in the code I put 14 only because the site does not update weekend…
-
0
votes1
answer1968
viewsChatterbot installation error
I’m trying to install the chatterbot but am getting the following error: Command "python setup.py egg_info" failed with error code 1 in C: Users Mariana Appdata Local Temp Pip-install-r5apde_f Blis\…
-
0
votes1
answer91
viewsAdjust columns csv with Scrapy
I’m having a problem, python by default when it generates the csv file separates the columns by comma, but I need the created items to turn into the respective columns, but I’m not able to do the…
-
0
votes2
answers138
viewsList in Python
How do I receive 10 integers and receive them separated by spaces in the same row in the list and print them in reverse order. I remember it was something like this: variavelA, variavelB =…
pythonasked 5 years, 7 months ago user141036 -
0
votes2
answers3821
viewsPython iloc[] function (Pandas)
I saw a code that the iloc function was like this: x = dados.iloc[0:-1, d:] y = dados.iloc[d].values[0] I read that iloc Select the row and column, but what would that be d there ?…
-
0
votes1
answer1661
viewsPython list of positive and negative numbers
How do I make the user type positive and negative numbers in the same row and the list display them in order from the smallest to the largest, preferably not using loop? Exemplo de números digitados…
pythonasked 5 years, 7 months ago user141036 -
0
votes2
answers335
viewsOperations sum and multiplication of integer numbers in Python list
The list code needs to receive 5 five numbers in reverse order, my code does it only that my code needs the 2nd number entered to be multiplied by 3 and the 4th number to be added by 5 (remembering…
-
0
votes0
answers41
viewsProblem loading color detected by Arduin
I have a problem loading the information on Arduino via pyserial. I’m using a python and opencv script to do color detection via webcam. For each color detected, I want to inform the Arduino so that…
-
0
votes1
answer485
viewsHow can I use Scrapy in Anaconda
Hi, I’m having trouble creating a project with Scrapy. I’m studying data science in college and I have to use Scrapy. I’m using Anaconda. First through the Spider IDE (Anaconda Navigator), now I’m…
-
0
votes1
answer400
viewsFix Encoding Problem while exporting to csv from a scrapy file
How can I fix encoding problem while saving file in csv? this problem is happening only when saved in csv. from scrapy import * from projeto_iruan.items import * import csv class…
-
0
votes1
answer64
viewsHow to change the content of a qLabel at runtime?
Good afternoon, you guys! I need each line of qLinedit to be numbered in ascending order from 1 to 24, I created a qLabel for this, but I don’t know how to make it change the numbering according to…
-
0
votes6
answers4819
viewsFibonacci-Python
Construct a function, that is, an algorithm that receive the maximum number of the sequence of Fibonacci. Returning all numbers from zero to zero Fibonacci number less than or equal to the number…
-
0
votes1
answer425
viewsX error has 2 Features per sample; expecting 3147
I’m trying to work with predictions, Machine Learning, but I’ve been having problems with prediction from the training saved, according to the following error: predict(file_name) File…
-
0
votes0
answers37
viewsRead CSV file using as delimiter the character "?"
When I download a CSV file in Windows (Pycharm) from the school, it works, but when I download it in Macos at home (Pycharm), it comes out with characters below:…
-
0
votes1
answer97
viewsShow modal only if there is an active session
When someone registers their name and email I create a session and I rescan the page with the name of who signed up, but I’m not able to understand how I do so that the time I rescan the page…
-
0
votes0
answers22
viewsAlternatives to timesleep
Good night! Whenever I use delay or the time.Leep my code simply hangs until the end of the run, as far as I read they do not work in parallel Is there a lib that has the same hold function but…
-
0
votes1
answer135
viewsMerge a dictionary with list inside
I have to join two dictionaries with list inside, the problem is pq both have list inside. Code: valores = {'valor':[1,2,3], 'valor2':[10,20,30]} valores2 = {'valor':[4,5,6], 'valor2':[10,20,30]}…
pythonasked 5 years, 7 months ago Igor Gabriel 530 -
0
votes1
answer89
viewsDifference between versions of the uuid Python package
I need to create unique Ids and for this I will use the package uuid. However, when it came time to import I was wondering which version to use: Is there a reasonable reason to have so many…
-
0
votes2
answers1265
viewsHow to convert CSV to XLSX with python?
How I Convert a File .csv generated by python to .xlsx? I’m in two trouble: One of them is that I couldn’t figure out how to make this conversion The second is that even passing the command crawl…
-
0
votes0
answers25
viewsSmallest number typed shows zero always
numero = 0 resposta = 'ok' num_total = 0 contador = 0 maior_num = 0 menor_num = 0 tot_pares = 0 aux = 0 while (resposta == 'ok'): contador += 1 numero =…
-
0
votes1
answer42
viewsHelp Tkinter opening a Python application
I made a separate menu to find my applications and it opens normally, but if it closes I can’t open it again, just by closing the menu application. from tkinter import * def Cadcordenadores(): from…
-
0
votes1
answer167
viewsHow do I import text source files into Tkinter in Python?
I want to know how I can import the source file using Tkinter, so that no source problems occur on other systems. Because if I send it to a friend, he won’t be able to see the selected source if he…
-
0
votes1
answer60
viewsGitlab CI passes the test even with error
I’m working with python/flask in an application. I want to test the Gitlab CI, so I ran a test that generates an error, just to see how it works. But, it turns out that the IC passes the Job even…
-
0
votes1
answer97
viewspurchase script, in txt file the name of the objects of the purchases, are not below each other
print('Programa de controle: Lista de compras 1.0') numero_compras = input('Numero de itens: ') lista_compras = [] i = 1 while i <= int(numero_compras): …
pythonasked 6 years, 2 months ago Michael Oliver 3 -
0
votes1
answer347
viewsAttributeerror: 'Directores' Object has no attribute
I am trying to get a value of a very simple class, but I have a problem that I cannot solve. Follow the codes below: Main class: from directores.directores import Directores # A classe Directores…
-
0
votes1
answer165
viewsIf you put multiple web requests inside a while loop in python can you bring down a website?
Good staff I have a question totally focused on studies and not to harm anyone If I make web requests and put inside an infinite loop can take the site off the air? Example of the code below in…
-
0
votes1
answer101
viewsHow to capture multiple HTML values with Django Forms
So that the html send a field of the type select with several values selected it is necessary to put the notation [] in the name attribute of html: <select name="categories[]" multiple="multiple"…
-
0
votes1
answer668
viewsIntegrate Rdstation with Django + Python p/ lead submission
Good morning guys, I have a problem: I have an LP that has to save the lead in the Postgres database and automatically send that lead to the RD platform using their API. using the curl I do it this…
-
0
votes1
answer42
viewsShow list items filtering by date.Today()
I have a list that I order by position in my models.py, but I have the field start_date I want to use as a validator so that the item is visible or not. But it is not working: py views.: from…
-
0
votes1
answer20
viewsHow to use two API in Developer in Appweb Flask
I’m new in the world of programming and I’m wanting to delve into web application I would take a doubt. I made a resquests of a json dictionary of two different api. I want to put this data scraping…
-
0
votes1
answer270
viewsPass URL list to Scrapy function
I have a Python API that takes two arguments (URL and a user-defined word) and provides in JSON file how many times the specified word appears in the URL. However, I would like to pass a URL list. I…
-
0
votes1
answer34
viewsHow to divide lines by lines of two different df and store in a third?
I try to divide using the methods div and divide and when assigning in a new df all values are as Nan…
-
0
votes1
answer425
viewsTyping
Is it possible to use static typing in Python? For example if I declare a variable of type int and then I assign the value 'one' no error occurs, I wonder if there is any way to prevent this kind of…
-
0
votes1
answer1312
viewsHow to make a software overlay desktop and fullscreen games?
Hello, I would like to know the name of this technique where we let the software show something superimposing desktop and fullscreen programs and etc... Example: I created a program that displays…
pythonasked 5 years, 7 months ago raidveneno.py 13 -
0
votes1
answer2959
viewsSave csv files to Python after making changes?
I am making some changes to multiple csv files at once, and would like to know how to save the output to a single file. import pandas as pd dataset =…
-
0
votes1
answer173
viewswhile (Cin >> str) An equivalent code in Python
Need to read multiple items without a fixed amount, in c++ just do while (Cin >> str) what would be an equivalent python code? has an answer in English to this same question here in the stack,…
-
0
votes2
answers390
viewsOpen file with 2 clicks in a Python program
Hello. I’m creating a small Python notepad and wanted to know how I open a file. txt using it from 2 clicks in Windows Explorer?
-
0
votes1
answer942
viewsRelation Between Classes in Python
Imagine that you are developing a system for controlling a Vehicles. With this it is necessary to register the vehicles available at the dealership for sale. a) Think about the necessary data and…
-
0
votes1
answer363
viewsHow do I animate an object on canvas with a bind with an animation already "running"
I was making a copy game of Space Invaders but when I went to do the "shot" of the ship, I came across a following problem : As seen in Gif, when I press the key, everything on the canvas "freezes"…