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
votes1
answer55
viewsRepeat code for the same product group
I have a spreadsheet with thousands of products according to the example below, where the code is only in the type of service (left column), and I want it to be in all products of the same type…
-
-2
votes2
answers433
viewsrecursive function with lists
I need to write a recursive function that takes 2 lists and returns a new list by subtracting the elements from the first ones, for example: >>> subtrai([2, 3, 4, 5], [2, 3]) [4, 5] I know…
-
-2
votes2
answers344
viewsHow to make a text generator according to the possibilities I put in it
I’ve been looking for a few days on how to match a text randomly according to the possibilities I place within the parentheses. Example: (Hello, Hi, Good afternoon) how are you (your day is great?,…
pythonasked 5 years, 11 months ago Wagner Rosa 1 -
-2
votes1
answer1116
viewsWorking with time in pandas and python
I have a dataFrame in which two columns are of the type datetime.time and I need to subtract one from the other and get the value in minutes. To turn into datetime.time did so:…
-
-2
votes1
answer95
viewsHelp with Json and Python
So I’m doing a script on python to the Python-Nmap and I have a file Json where I store information such as default ip and default port and I created in the options menu and an option to change the…
-
-2
votes1
answer477
viewsKnow if client is connected to the server
I have a client and a server connected through the socket module in python3, on the server side I know when the client is connected, but on the client side I have no message when the client connects…
-
-2
votes1
answer66
viewsSame data set, two lines, two equations, on the same graph?
My data fits easily by a straight line, but even better by 2, dividing the data. I need to divide the data into 2 parts, thus: concentrations (x) up to 700 ppm and concentrations > or = 700 ppm.…
-
-2
votes1
answer214
viewsHow to change the value of a variable in the python terminal and save permanently?
Does anyone know how to change the value of a variable in the terminal and stay saved forever in the script? ex: I create a variable of type input ps: The variable name is Name; E depois crio uma…
pythonasked 5 years, 8 months ago Afonso Dolmen 27 -
-2
votes1
answer295
viewsVscode terminal
I’m having doubts in the terminal of vscode with Python: When I enter the product folder and type Python version 2 appears, but in the footer of vscode is identified as Python 3. When python type 3…
-
-2
votes1
answer735
viewsSelenium Webdriver error accentuation
I am using Selenium Webdriver to realign test with python when running this line: mov.find_elements_by_xpath("td")[3].text.encode('utf-8') I have as answer: {'descricao': 'PROTOCOLIZADA…
-
-2
votes1
answer394
viewsWeb Scraping with python
Good evening. I want to make a simple algorithm to take data from a website (http://www.riooilgas.com.br/? _page=programming&_menu=programming). I’ve done some library code: from urllib.request…
-
-2
votes3
answers127
viewsPython Max Value Lists
I have a question about the lists in python. Suppose I have one lista1, with name, store and sales value, I have to return the name of the person who sold the most. example: vendedores= [{"nome":…
-
-2
votes1
answer101
viewsI would like to know how Sqlite works
My question is this:: Whether database data is stored in a db file. on my computer. Or externally.
-
-2
votes2
answers101
viewsDoubt about mod
I know the mod is the rest of the division. 12%2 = 0 29%3 = 2 But could someone please let me know the reason for this? 12%18 = 12 52%58 = 52…
pythonasked 5 years, 7 months ago Junkes Junior 1 -
-2
votes1
answer2037
viewsCalculate sine by Taylor series expansion
Write a program that calculates an approximation for the sine according to the equation below: seno(x) = x - x^3/3! + x^5/5! - x^7/7! + ... + x^n/n! Whereas x and n are integer numbers informed by…
-
-2
votes1
answer404
viewsPython with socket communication between computers
Someone knows how to connect multiple computers with socket in Python, I’m creating a small test blockchain and I want to distribute the files among all the machines connected through the socket, I…
-
-2
votes1
answer151
viewsHow to recover text from a Tkinter widget created with the Guis PAGE generator?
I am trying to create an interface where the user can type a text and save that text in a txt document. To make the process easier, I used a Guis generator called PAGE, which uses the Tkinter…
-
-2
votes3
answers188
viewsRead two notes and display a string according to the average between them
Make a program that receives two notes, calculate and show the average and the message that is in the following table: 0,0 - 4,0 Reprovado 4,0 - 7,0 Exame 7,0 - 10,0 Aprovado print('ATIVIDADE 2…
-
-2
votes2
answers60
viewsI cannot add "variable = variable + 1" to the while loop
I have the following code: quantidade = int(input("Quantos episódios? ")) inicio = 1 numero_do_post = 379 numero_do_anime = 6 arquivo = open("script.txt", "w") while (inicio <= quantidade):…
-
-2
votes2
answers3274
viewsHow to convert monetary number to extended number in Python
How can I convert a monetary number into an extended number using Python ?
-
-2
votes2
answers10417
viewsHow do I multiply two matrices in python?
def multM(a, b): '''essa foi a função que eu tentei fazer''' if len(a) == len(b[0]): r = [] for i in range(len(a)): r.append([]) for j in range(len(b[0])): for k in range(len(a)): val = a[i][j] *…
-
-2
votes2
answers116
viewsCreating a program in Python
Hello, I’m not very good in programming, and I’m having difficulties in this exercise, this giving error already searched and I can not solve... I would like someone to help me to redo this code. I…
-
-2
votes1
answer92
views:python3 Tkinter Requests: Temporary lock in get('url') with request module!
This is the following I created a script to decrypt hash md5, but when I enter it into Entry 21232f297a57a5a743894a0e4a801fc3 that is admin and is contained in the Wordlist, it hangs every time when…
-
-2
votes2
answers90
viewsChange Directory and run command
I want to make a script that enters a directory and after entering execute a command, and then show the result on the screen. Example: cd /usr/share/nmap/scripts (DIRETÓRIO pra ele ENTRAR) ls | grep…
pythonasked 5 years, 5 months ago Richard Marcelo 25 -
-2
votes1
answer573
views'int' Object is not subscriptable, I have tested several times but whenever text I receive this message
def movinteiros(a): b=[] for i in a: if i=="c": b.append([-1,0]) elif i=="b": b.append([1,0]) elif i=="d": b.append([0,1]) else: b.append([0,1]) return b opcao=int(input("Opcao de jogo:"))…
-
-2
votes1
answer489
viewsImport matplotlib.pyplot as plt error
The import numpy as np gives well but this one gives this error and do not know how to solve it(open link): - http://prntscr.com/o2txe8…
pythonasked 5 years, 5 months ago Gonçalo Sousa 103 -
-2
votes1
answer276
viewsWrite multiple csv files in Python
Hello! My question is the following: I wrote a program that, with the information I enter, it will collect a number of links (that number varies) and will store them in a csv. Then he will open each…
-
-2
votes3
answers463
viewsHow to list files in a folder with size
Hello, I need to list all the files in a folder with several subfolders, I need the name and size of all the files in this folder, I’m trying to make a code in Python for this but I’m not getting,…
pythonasked 5 years, 5 months ago Jean Ribeiro 1 -
-2
votes3
answers2637
viewsCheck if value is string or number
10) Make an algorithm that checks whether a given value is a String. valor = str(input("Informe um valor: ")) if(type(valor) == str): print("É uma String!") In Pycharm IDLE or Python Console, type:…
-
-2
votes2
answers93
viewsChecking an element in a list of tuples using the in command, only one parameter observed in python
How to check if a tuple is contained in a list using the property in. Example: lista = [('joao', 13), ('maria', 20), ('carlos', 30)] I want to know if carlos is on the list…
-
-2
votes1
answer42
viewsCreate a function that reads a list correctly
This function should ask for a name to be used as a search term. If the search movie is in the list, all data from the movie. Otherwise, a message that is not on the list. This is the function I…
-
-2
votes3
answers3860
viewsWhat is the python float
I have the following code in Python but I don’t know what the float someone could help me? peso = float(input('Digite seu peso (kg): '))
-
-2
votes1
answer194
viewsSearch by API / JSON - Latam and Gol (Power BI)
Good Morning! Guys, I’m riding a Dashboard on Power BI, and I need to link it to the Gollog and Latam load tracking site. I already have the link to search the web service, but I do not know how to…
-
-2
votes2
answers682
viewsHow to count how many odd numbers there are between -999 and 0
I need to make an algorithm that tells me how many odd numbers there are between -999 and 0 Example: between these values a n odd numbers
-
-2
votes1
answer107
viewsPython: Access 4th level of a zipped folder
Hello! I’d like to access the fourth level of a zipped folder. I mean, I have a zip file and inside it there is a folder and inside this has another folder and so on... as graph below. I’d like to…
pythonasked 5 years, 3 months ago Wilson Junior 182 -
-2
votes2
answers480
viewsDisplay matrix in python
I have a matrix of n by n and use this part of the code to present it: for i in range(len(data)): for j in range(len(data[0])): print ((data[i][j])) Being data the matrix. But the output looks like…
-
-2
votes2
answers123
viewsERROR :My code hangs without any error
I’m starting to learn python and wanted to create a kind of login, only that the code ends without having chosen to end. from time import sleep print('=='*20) print('=='*8,'LOGIN','=='*8)…
-
-2
votes1
answer981
viewsElaborate a program to read a feedback with ten python objective questions
Elaborate a program to read a template with ten objective questions provided as a string with ten characters relative to the correct alternatives (each answer is indicated by ːA' or 'a', ?B' or 'b',…
pythonasked 5 years, 11 months ago Matheus Andrade 205 -
-2
votes2
answers143
viewsDictionary doubt
How do I count dictionary elements? datum: I need to implement a phone account function, which receives a phonebook and returns the amount of registered phone numbers. If there are repeat phones…
-
-2
votes1
answer284
viewsPackage code in python
Ooh, ooh, ooh, ooh, ooh? So I finished a project that contains only one file. py that imports the following libraries : dlib face_recognition And I want to export this code so that OTHER LINUX ,…
-
-2
votes1
answer173
viewsDifficulties with using IF
Good morning, you guys. I’m still a beginner in programming, I’m trying to write a simple program that calculates the coefficient of performance and reports the percentage of the course completed,…
-
-2
votes1
answer45
viewsUpdate on Mongodb
Is there a function that allows you to send a message when some data is added to Collection? Kind of a logs For example: data = { "_id": 12345678910 } return db.insert_one(data) Terminal: Um novo…
-
-2
votes1
answer186
viewsStatement for 2 arguments, how does it work?
I saw this statement in a code on codewars and I couldn’t understand how it works: def multiple_of_index(arr): return [val for index, val in enumerate(arr) if index and val % index == 0]…
-
-2
votes1
answer603
viewsError: "can’t Multiply Sequence by non-int of type 'float'"
I’m making this simple unit converter. I need him to do: Calculation of average speed in Km/h; Print this result. Then, in another function, I need to convert it to m/s and print the result again.…
-
-2
votes1
answer76
viewsSeparate columns from a dataset
I need to separate in a list the column types of a dataset in numerical and non-numerical. For example: def identifica_tipos(df): col_numerica = [] for col in df.columns: if col.isnumeric:…
-
-2
votes1
answer28
viewsList With Gigantic Array
The software like output a list with only one giant array: [array([0.000000e+00, 1.687500e-01, 5.062500e-01, ..., 3.616745e+03, 3.617745e+03, 3.618245e+03])] My goal was to get a list, with each…
-
-2
votes2
answers1295
viewsSelenium Select Boot
Hello, running my python code can’t select a button HTML: <div class="pushpad_deny_button" style="position: relative;top:0;right:0;display: inline-block;float: left;width: 100px;margin-right:…
-
-2
votes2
answers204
viewsIs there any way to nest one for N times?
In Python is there any way to nest one for inside the other N times? Or is there some kind of algorithm that simulates this? Basically I need to create a function, which performs combinations of…
-
-2
votes1
answer694
viewsSplitting codes into . py files
I started programming now, and I started in python, so I started researching more deeply in this language, and I went to see some videos of game programming, in these videos I saw that the game was…
pythonasked 4 years, 11 months ago Wilson Bonato 45 -
-2
votes2
answers94
viewsProgram to remove ONLY a copy of duplicate values from a list
Write a method rem() that accepts as input a list possibly containing duplicate values, and return a copy of the list where a copy of each duplicate value is removed. What I did: def rem(lista): i =…