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
answer449
viewsmatplotlib - Cut saved plot
When saving my chart it gets a left cutout on top of the names because it is wide. How do I fix it? cmap = cc.cm['kbc'] norm = matplotlib.colors.Normalize(vmin = ranking_members.rating.min(), vmax =…
-
1
votes2
answers361
viewsHow to create an array with value one?
Hello I would like to know if there is a way and which would be the most correct way to create a list (or an array) with the ones filled with the value 1 given the length of another list. Exactly…
-
1
votes2
answers2094
viewsOpen Python file only works with Windows folders in English
I have a Python program that asks the user for a file path and shows the contents of the file on the screen. The problem is that the code only works when I put the names of Windows folders in…
-
1
votes2
answers334
viewsReturn the index of a row with the min function in Python
I am trying to find the index of a numpy matrix (cut of a face detected in opencv) and draw a line where the sum of the pixels is the minimum value. I can’t return the index. Follow the code below…
-
1
votes2
answers100
viewsRecursive program that accepts a non-negative integer as input and displays its vertically stacked digits
I developed the recursive function vertical(), which accepts a non-negative integer as input and displays its vertically stacked digits. For example: >>> vertical(3124) 3 1 2 4 Solution:…
-
1
votes3
answers131
viewsBreak string every 4 positions - Python
Whereas we have the following string. codigo = '7777. 5698 897897. 236' After removal of spaces and . codigo_formatado = ''.join(codigo_de_barras.split()).replace(".", "") codigo_formatado Exit…
-
1
votes2
answers75
viewsCounting the number of executed operations over the same input for a recursive call
idea: Compare a recursive version of the exponentiation implementation with a non-recursive version. Recursive version: def power(base,expoente): global cont if base == 1: return 1 elif expoente ==…
-
1
votes1
answer112
viewsHow to imitate "until... you do" command with python?
How can I make a counter regressing with python? I tried so: count = int(10) while True: print("Eu conto", count) count = int(count -1) if count = 0: break but it seems that it does not accept the…
-
1
votes4
answers3686
viewsSumming value by value in an array with Python
I need to sum up all the possible values within one array to find out where an error is in a database. Code until then: valores =…
-
1
votes1
answer119
viewsCreating a CSV from 3 CSV tables
I have two CSV tables and need to merge with the unusual columns in the two tables creating a single table. However, when I write the code, it is a very long time of processing and not complete. How…
-
1
votes3
answers1073
viewsHow to change CSV in Python and Pandas?
I am a beginner in Python and need a help. I have a csv file that has only one column with age data. I need to transform the integers into ranges, like "ate_21_anos", "ate_24_anos", etc. The problem…
-
1
votes0
answers110
viewsDoubt with API in Django and Python
I am developing an application with customer registrations, and my class View to register a client was like this: class AdicionarClienteView(CustomCreateView): form_class = OportunidadeForm…
-
1
votes3
answers2843
viewsHow does train_test_split work in Scikit Learn?
I am learning machine Learning and in most examples is used the method train_test_split() and there is not a very precise explanation about it (at least not in the articles I’ve read). I know your…
-
1
votes3
answers212
viewsProblem with number guessing game
This number guessing game script doesn’t work, in part if z = "s" Python says the syntax is invalid. Someone could tell me why it doesn’t work, and what would be the right one? import random def…
-
1
votes1
answer85
viewsError running Python test 3.6.7
This gives error when running def test() to test def questao(). Why would be giving error in the return of the test function? def questao(): lista_nomes = [] nome = '' x = 0 reader =…
-
1
votes2
answers82
viewsReturning Added Data in a Dictionary
In my code I am asking the user to enter the note, n° of registration and frequency of 2 people. But I want to do this using dictionaries, so I declared the keys 'Nota', 'Matricula' and 'Freqüência'…
-
1
votes1
answer1022
viewsHow to calculate the similarity between two texts using word embedding in Python?
I’m using word embedding of polyglot to calculate the similarity between two texts, but I’m having difficulty getting to the final similarity calculation. The method…
pythonasked 5 years, 9 months ago Thiago de Paula 11 -
1
votes1
answer562
viewsError in subprocess.run( ) in Python 3.7.2
I’m using: Windows 10 Python 3.7.2 Shell (default IDLE) x64 I’m trying to follow the tutorial Learnopencv tutorial, I already downloaded the file class-descriptions-boxable.csv and…
-
1
votes2
answers616
viewsProblem showing image in imshow
I have a function that opens an image and sums with a random matrix but the function cv2.addWeighted generates the following error even though the types of the two matrices are equal : Traceback…
-
1
votes1
answer272
viewsConnect Sql Server 2014 to Django 2.2
I am trying to connect the Sql Server database to Django but am getting the following error(The connector I am using is Django-pyodbc-Azure): Django.db.utils.Interfaceerror: ('IM002', '[IM002]…
-
1
votes0
answers37
viewsError creating Virtualenv on Windows
I am trying to create a virtualenv in windows but am getting the following error: line = line.decode(fs_encoding) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 283: invalid…
-
1
votes1
answer90
viewsHow to read the contents of a "Generator Object" from the load_all method for yaml file?
I need to maintain a function that returns me a Generator Object from a yaml file. In another function I want to access the yaml file data. import ruamel.yaml def load(): yaml =…
-
1
votes1
answer123
viewsText.strip() Python
I am trying to make a code that extracts some information from a page. The file has the following format: <tr class="impar"> <td class="id"> <a…
-
1
votes1
answer1875
viewsWeb scraping on page with login and password
I am trying to extract source code from an html file with the following style: <div class="both"></div> <div class="st-box" id="source-code"> <h3>SOURCE CODE</h3>…
-
1
votes1
answer74
viewsDoubt in the book Python on a Crash Course
I’m studying the book Python on a Crash Course And everything was going great until now. After testing the codes on pages 324 and 325 (which are a module and a program that uses it), I was surprised…
-
1
votes1
answer561
viewsHow to program in java and python together
I see various programs and systems that are programmed in various languages, such as android. I’m trying to program in java along with python, but I can’t find anything about it. I’ve tried to…
-
1
votes0
answers25
viewsInventory of Archives
I am learning to program and I would like to know if you have any way to create in python a list of network file inventory, contento as follows situations: Network Path: rg2srv0164…
-
1
votes1
answer225
viewsPython - Button depending on box
I started with designing a program to learn how to program, however I’m having a hard time doing the following: The person places the information in the text box The Button fetches this information…
-
1
votes1
answer243
viewsWhat’s the "@" in python for?
Several times I came across snippets of python code that used "@" as in flask: import flask App = flask.Flask(__name__) @App.route("/") Why not just App.route?…
-
1
votes1
answer523
viewsReturn to a page with completed form
I’m using Django and I have to implement the following flow: The user fills in the information of a new exam, clicks on attach an old exam, goes to the exam search screen, selects the desired exam…
-
1
votes1
answer79
views -
1
votes2
answers1656
viewsI am unable to perform the following exercise in python
I am unable to perform the following exercise in python: João Papo-de-Pescador, a good man, bought a microcomputer to control the daily income of his work. Every time he brings a weight of fish…
-
1
votes1
answer154
viewsExtracting email addresses from a web page using regular expressions in python
What I did: from urllib.request import urlopen from re import findall def emails(url): content = urlopen(url).read().decode() #print(content) padrao =…
-
1
votes1
answer355
viewsgenerate a pdf only with arguments passed by a Django form
Hello, I’m having a problem generating a pdf, I need to create filters for a more detailed report, my code consists of a simple view of Template where I set up the form with the "GET" method, and a…
-
1
votes2
answers548
viewsHow to convert the hash() value of a string back to the original string?
I’m learning now about Hashing and discovered that Python has a function called hash() that returns the hash value of an object. The problem is, how can I convert this value to my original object,…
-
1
votes2
answers91
viewsWhen changing the value of a variable, all objects in the same class are changing
I have a code that creates a class, with a location attribute, one (x, y). I ask the program to create 2 objects of this class with the random location attribute around a circle. However, they both…
-
1
votes1
answer347
viewsHow to remove the edge of a Pyqt5 window on Raspberry Pi?
I’m developing an application that will run on a Raspberry Pi interfaced in Pyqt5. This application will occupy the entire screen, making it impossible for the user to click outside the application.…
-
1
votes1
answer150
viewsLoop Problem and Time Calculation
I want to do a program, where he reads an activity, and the time spent on it. Example: Lavando o Portão, 10:30 as 12:00, tempo gasto 01:30 I am currently with 3 problems: The way my code is…
-
1
votes1
answer123
viewsThe program is not recognizing whole number as such
a = int (input ("insira um número :")) if a != int : print ("isto não é um numero inteiro") else : print ("seu número foi :"+ str(a)) I’m trying to make a program where the user puts a value and the…
-
1
votes1
answer675
viewsMulti-line comments and Python identation error
I was writing my code and I needed to block some lines of code. As there are several, I decided to use the 3 quotes to block a part of the code. However, when I run the code it presents an…
-
1
votes3
answers1988
viewsEmail validation function
I need help with this code 'cause I’m racking my brain and I can’t fix it. You first enter the number of emails you want to enter with input. Then you type the emails according to the number you…
-
1
votes1
answer70
viewsError: Exception has occurred: Typeerror (Python)
I have the following error when compiling: Exception has occurred: TypeError __init__() missing 2 required positional arguments: 'usuario' and 'senha' What I’m doing wrong? class Login: usuario =…
-
1
votes1
answer1442
viewsPick a select value in Django
The HTML code: <!doctype html> <html lang="pt-br"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0,…
-
1
votes1
answer166
viewsSorted for Bhaskara formula
I have an exercise to solve and I have a problem, it is not to be done in list or dictionary. If you have 2 real roots they should be printed in ascending order, the problem is that you should print…
-
1
votes1
answer275
viewsSort class list in Python
I have a class defined as follows:: class Cromossomo(): def __init__(self, cromossomo, comprimento): #Construtor self.cromossomo = cromossomo self.comprimento = comprimento From it I have a list of…
-
1
votes0
answers1189
viewsError "Valueerror: operands could not be broadcast Together with shapes"
I’m getting this mistake: Traceback (Most recent call last): File "geraEstatistica.py", line 148, in cnplot = map.Contour(x,y,result,clevs,Cmap=plt.cm.jet) File…
-
1
votes3
answers2879
viewsRun script with Python: command "python3" is not recognized
Good afternoon, I’m learning to create programs in python language and run them.. I am using Windows, but when opening the Prompt comado and type python3 somador.py the message it generates is:…
-
1
votes1
answer1923
viewsHow to connect to Firebird database in Python?
I’m making an application myself Python that should connect to a bank Firebird. The application is running on a Linux and the bank in a Windows. My test file worked properly on the server Windows,…
-
1
votes2
answers379
viewsHow to search for partial text in a string list?
I have a list with several text elements, and I would like to know how I can find one of these elements by searching for a part of the text and not by the exact text. Example: Lista = ['Jorge…
-
1
votes1
answer62
viewsPython3: Module csv has no Dictwriter Member
Hello. I am following the reading of the book Data Visualization with Python and Javascript from Scratch by Kyran Dale (O'Reilly). In the following code, it is understood that a . csv file should be…
pythonasked 5 years, 8 months ago Isaias Velasquez 151