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
votes1
answer116
viewsSelect python - Pandas
I am developing a python program where I import two xlsx files directly with the Pandas library, I can import them easily, but I need to create a report between these two files. How can I do?…
-
-1
votes2
answers128
viewsPut a variable inside a spin?
import spintax nome1 = input("Nome: ") nome2 = input("Nome: ") nome3 = input("Nome: ") for z in range(0,10): c = (spintax.spin("{noite|dia|tarde}") print("Boa {}".format(c)) I wanted to put the…
-
-1
votes2
answers835
viewsPython Spent Fuel Exercise
I’m starting in Python and I’m doing some exercises, I did this spent fuel, but it does not show me the end of the program, ie the result, what is the error? nome = input("Qual é o seu nome?") gasto…
-
-1
votes2
answers260
viewsAlgorithm that creates a Python queue
Hello, I would like to create an algorithm but I don’t know much how to start it... It would be to write a program to create a queue, represented by a list, and present to the user the options to…
-
-1
votes2
answers434
viewsSecond highest value of a python list
I want to find the second highest value of a list without deleting any elements in it; I tried using the min and max command, but this only works with higher and lower. In case I want you to return…
-
-1
votes1
answer35
viewsHow to change image name with python?
I want to change/change the name of a set of images. I have the python code that does this, the problem is that it generates as follows "123image.jpg" and that wanted "image123.jpg". How to adjust…
pythonasked 3 years, 12 months ago GustavoSevero 2,567 -
-1
votes2
answers625
viewsHow to manipulate Date attribute from a Python Json result
I have a Json output that I am using in a Google Sheets spreadsheet, and with this information I need to sort them by Date, so I need to get this date into the separate Date and Time spreadsheet…
-
-1
votes1
answer51
viewsPython bar graph
Hey, guys, all right? This is my first post here, sorry if I make any mistakes... I’m just starting to learn how to code in Python, and I need a little help... The Axes in my chart are overlapping.…
-
-1
votes1
answer69
viewsFile execution error in pycharm
Good morning, everyone, I’m experiencing a boring situation that I’m having trouble solving. When running the game I’m developing the following image appears: Everything was fine before, the program…
-
-1
votes1
answer350
viewsHow can I create a loop per seconds in python without Sleep or delay
I’m developing a programming for EV3, with python, and what I wanted to know is: How can I create a loop per seconds, IE, I want that in a certain time in seconds, the robot does the actions…
-
-1
votes3
answers164
viewsRead more than one line with input
I’m trying to read several numbers in this format and save them in a list: 2030706155721618 3230170874838235 4782877637240802 2406118837772520 4886405615781541 1520748465125584 1766850807841275…
-
-1
votes1
answer88
viewserror: EOF when Reading a line
I need to round the notes to the next multiple of 5, if it is greater than 38 and the difference is less than 3. However, when I am going to submit the code to me d[and the error: EOF when Reading a…
-
-1
votes1
answer18
viewsHow to separate in x and y being all but the last x and the last y?
I am doing a function to generalize a train_test_split, and for that desire separates within the function the X and the y. Currently my code is like this: python def split(dados): SEED = 42367 X =…
-
-1
votes1
answer90
viewsIndexerror: list index out of range with csv data?
I tried two codes, but both generates the error: IndexError: list index out of range I want to score points on the world map, of drift buoys. This data is in a csv file, with the lat and Lon column…
-
-1
votes1
answer28
viewsDisplay only after typing negative number
How can I display the conversion results only after the negative number is typed? Currently, it reads and already displays. I wish he could read and only after typing a negative number, he would…
-
-1
votes1
answer850
viewsCollect image link with python , Selenium and webdriver
I need to run a python script to get the url of an image that is only shown after running the page’s javascript. I am using python3 with Selenium and webdriver. However when trying to locate the…
-
-1
votes1
answer101
viewsEmpty Dictionary Print - Webscrapping/python/xpath
Guys, I can’t understand why the result of this scrapp comes out an empty dictionary. Could help me understand what my mistake is? import requests from lxml import html quimicos = [] resp =…
-
-1
votes2
answers45
viewsProblem with data entry
Good night, I’m a novice programmer who was testing what I learned in a course, I was trying to make a simple site registration, but at the time of reporting age, I wanted it to be only for those…
pythonasked 3 years, 11 months ago Davi Rafacho 1 -
-1
votes1
answer151
viewsHow to save a CSV in memory using Python?
Hello! I need to read a big CSV, break it into 1000-line Csvs, store them in memory and then reset a zip with these smaller files. This is the code so far: import pandas as pd from io import…
-
-1
votes1
answer36
viewsI would like someone to help me with an excerpt of this SQL and Python code
I’m trying to capture a flag of the site Hacker101 CFT and I came across a code snippet. IN THAT SPECIFIC PART: if cur.execute('SELECT password FROM admins WHERE username=\'%s\'' %…
-
-1
votes1
answer52
viewsBreak a list and create lists
hello! I have the following list in python of numbers: ['1','2','1','2','3','4','1','2','3','4','5','6','7','1','2','3','4','5','6','7'] And I want to break that list and create other lists in such…
-
-1
votes1
answer95
viewsHow to receive only letters and spaces in the input?
def registro(name="", idade=0, local=""): while name.isalpha() == False: name = input("Digite seu nome: ") if name.isalpha(): name.isalpha() == True else: print("Por favor digite um nome válido.(Não…
pythonasked 3 years, 10 months ago Italo Almeida 11 -
-1
votes3
answers64
viewsPython checking if the number is Float
I am very beginner in python programming, my doubt is the following, I need the user to type only float number, how do I do this check and report the error if it is not? I could only do if the…
-
-1
votes1
answer138
viewsPandas: Acceptance and rejection percentage
I have a dataset that contains some columns that inform me: user, situacao_requisicao, city. I would like to generate a csv that informs me the amount of requisicoes of each city, how many were…
-
-1
votes1
answer121
viewswrong structure in my code! does not fall in any condition
I need to make a python script using WHILE and IF to find out if a typed number is prime or not. Below follows my code. I can not find where this my mistake, because if I type any value above 2 does…
-
-1
votes2
answers29
viewsWhat is the difference at the time of the return of these two forms?
def seja_educado(funcao): def sendo(): print('Foi um prazer!') funcao() print('Tenha um ótimo dia!') return sendo def seja_educado(funcao): def sendo(): print('Foi um prazer!') funcao() print('Tenha…
-
-1
votes1
answer233
viewsCRUD in Python - Search() function?
Hello, I am doing a CRUD in Python using files and while doing the function "search" I found myself in a problem. The code is as follows:: def buscar(): n = input('Digite o nome do contato a ser…
-
-1
votes1
answer49
viewsMerge two files in python
I have two lists in python and I want to leave these two files in one. That is, I have two files that contain a column with 360 lines and I want to leave in a single file (because I need to make a…
pythonasked 3 years, 9 months ago user219748 -
-1
votes3
answers129
viewsCatch internal IP via Python (Router)
I’m a long time doing research on this, and I wanted to know how to get the local ip (obviously) of my router in python in a Linux environment, I searched it in Google several times and always came…
-
-1
votes1
answer137
viewsSeparate print from two Python structures
I made a small program in Python that asks the user to type any integer number, right after it shows the Fibonacci sequence (number of times) and then shows the number of even numbers until that…
-
-1
votes1
answer162
viewsPython Film Box Office display occupied seating position
I’m doing a show using matrices that works like a movie box office. I am working to finish option 1 (which in my opinion is the most laborious). I was able to change the values in the matrix so that…
pythonasked 5 years, 2 months ago Fernando Antonio 1 -
-1
votes1
answer326
viewsHow to average values in a list using python?
Hello, I have a list of python values that alternate between positive and negative values, and I want to work with the average of those values, However, I need that when the number has been…
pythonasked 5 years, 2 months ago Nathan Streisky 33 -
-1
votes1
answer49
viewsI can’t access an index from an array
Well, I am having trouble accessing the 3° index of my list. When I try to access, returns me an error of: List index out of range. vertices = [[-1,-1,1], [-1,1,1], [1,1,1], [1,-1,1]] for v in…
-
-1
votes1
answer98
viewsHow do I use pipe when running python programs in the terminal, and what is it for?
example : python3 example.py | example2.py I wanted to know what this is for, I realized that somehow they communicate , but I did not understand the usefulness of this property.
-
-1
votes1
answer2482
viewsHow to export data from a database to a CSV file?
Hello, I would like to know how data could be exported from a database to an Excel spreadsheet, not necessarily need a code that does this, but I would like to know which languages can be used,…
-
-1
votes1
answer39
viewsError making python formatting using . find command
I’m trying to find how many times the letter "A" repeats in a variable, but I can’t find the error when giving the format command. p = str(input('Digite uma frase: ')).strip().upper() print(f'…
-
-1
votes1
answer25
viewsHow to open an app with Speech Recognition?
I would like to create a mini application that opens a file or even another application through Speech recognition, ie I would open it and when I gave the example command: if 'open' in command:…
-
-1
votes1
answer73
viewsEliminate radar chart caption created with the openpyxl module in Python
would like to be able to delete the chart caption generated in excel by the Pyhton program using the openpyxl module below: from openpyxl import workbook from openpyxl import load_workbook from…
-
-1
votes3
answers174
viewsPython - Sine cycle in degrees
Good in order to calculate the sine cycle (sin) in degrees between 0 and 390 with an interval of 10. print('Ciclo seno em graus entre 0 e 390 com intervalo de 10') a=0 while True: if…
-
-1
votes3
answers144
viewsCalculate the value of a multiplication using only summation and subtraction operators
I tried to write a program in which I must calculate the result of a multiplication through sum and subtraction operators only. I can’t write anything that works, follow the code as close as I got:…
-
-1
votes1
answer157
viewsDjango: "Import: cannot import name on_commit"
I’m trying to run an application in Django, however, when using the command python2 manage.py runserver I have the following return: Traceback (most recent call last): File "manage.py", line 10, in…
-
-1
votes1
answer30
viewsDataframe input
Good morning guys, I’m creating a expense control to be used as a data science study. However, I would like to make the user able to enter the values and feed this dataframe. The expression I have…
-
-1
votes1
answer136
viewsWhen running two Django projects at the same time, one of the two users is dropped
I am working on two projects that share the same database, and so the same users, but they are two different projects on different servers. The point is that when accessing both at the same time…
-
-1
votes1
answer37
viewsNumber of elements in ndarray vector
I have the following function to count how many "player" appear in the array estado[i], which is a line of a matrix: for i in range (0, len(estado)): if (estado[i].count(jogador) == len(estado)):…
-
-1
votes1
answer58
viewsHow to not write the header to a CSV every time you update the file
When I create a CSV file with header, every time I try to insert new items the header repeats. # Escrevendo o arquivo with open('Gerador.csv', 'a', newline='', encoding='utf-8') as gravar:…
-
-1
votes4
answers276
viewsPrime numbers with Python
Trying a thousand ways to get this result. Always returns the same thing. number = int(input('Numero: ')) if number >= 1: for i in range(1, number): if number % i != 0: print(number, 'é primo')…
-
-1
votes3
answers123
viewsProblem when denying receipt of a certain value
I need to create a code that receives 2 notes and me average them and I have to necessarily make my program only receive values from 0.0 to 10.0 what is not happening: n1 = float(input('Dígite sua…
-
-1
votes1
answer46
viewsUse a class method from a concatenated string
Hello, I’m new to Pyhon... I have a class called Car, and in it I have a method called name that returns the name of my object. Ex.: carro_1.name() = returns the name of the car. I have the objects,…
-
-1
votes1
answer28
viewsUsing . get() in your window with Tkinter
when I try to use the code: import tkinter as tk window = tk.Tk() texto = tk.Text(window).pack() tk.mainloop() print(texto.get()) to return the value of what I wrote in the variable text the program…
-
-1
votes1
answer67
viewsWhat does an expression between parentheses mean followed by an expression between brackets?
I found this code: nums = [1,2,3,4,5,6,7,8] round(sum(a ** (2, 0.5)[a % 2] for a in nums), 2) My doubt is in this passage (2, 0.5)[a % 2], what name? How it works?…