Most voted "python-3.x" questions
Python 3 is the latest version of the Python programming language and was formally released on December 3, 2008.
Learn more…3,274 questions
Sort by count of
-
1
votes1
answer715
viewsDoubt about the __dict__ method in Python
Well, I’m a beginner in Python programming and started studying object orientation. I came across the following code, which is very simple. class Pessoa: def __init__(self, nome, idade, altura):…
-
1
votes1
answer218
viewsError passing numpy.core. _exceptions.Ufunctypeerror: ufunc 'subtract' Did not contain a loop Signature matching types (dtype('<U21')
Basically I have the following code: import numpy as np def localize(aux1, aux2, aux3, aux4, aux5, aux6): search = np.array([(aux1,aux2,aux3,aux4,aux5,aux6)]) B1A =…
-
1
votes1
answer31
viewsImport a file that starts with numbers in Python
I have the following problem: I am trying to import a module into Python. I have the following code: # -*- coding: utf-8 -*- import 01_Jogo print("----------------------------------------")…
-
1
votes2
answers5692
viewsHow to print all the contents of a list in Python
How do I print contents from a list? I want the output to look like this: Indice: 0 1 2 ... likes: 0 0 0 ... A post is represented as an element of a list. The list index indicates the post number.…
-
1
votes1
answer235
viewsHow to sort a python dictionary in descending order?
How can I order this dictionary so that it is in descending order: dict= {'1': array([44, 32, 56, 57, 43, 21, 36, 35, 39, 27, 23, 24, 25, 26, 31, 28, 29, 30, 20, 22, 18, 19, 8, 1, 33, 2, 3, 4, 0, 6,…
-
1
votes1
answer66
viewsI cannot change the verbose_name of a field
I am programming an agenda, and for that, I created the model "Commitment", which has the following code: class Compromisso(models.Model): nome = models.CharField(max_length=100,…
-
1
votes1
answer173
viewsBucket Sort in Python: The array is only partially ordered!
I’m trying to implement the algorithm Bucket Sort. The code below implemented only "1 round" (considering the numbers from right to left) of the algorithm, in which the array [97,3,100] turned into…
-
1
votes0
answers68
viewsHow to calculate the values of a function in an entire range when only the values in the integers are known?
someone can help me, please? I’m trying to write a function in Python (I use 3) that implements the following code that is in Mathematica:…
-
1
votes0
answers226
viewsHandle POST elements in Django Rest Framework
Good night, I own a model with: camid = models.AutoField(primary_key=True) A serializer: class CameraSerializer(serializers.ModelSerializer): class Meta: model = Camera fields = ["camid", "nome",…
-
1
votes1
answer280
viewsPlace numbering on graph curves (matplotlib)
I have a code in Python for the simulation of a mathematical model that I am studying. To generate the graphics, I am using only the function plot() of the matplotlib, inside a for (are several…
-
1
votes3
answers124
viewsif and Else in Python
Hello, I have a question about the command order. My script went like this: if salario <= 1250: aumento = (salario * 15 / 100) + salario print('Seu salário com reajuste é…
-
1
votes1
answer285
viewsHot color detection in Python image
I have a problem and I need your help. I have a series of thermographic images, which I need to detect the hot spot (shown in the bar to the right of the image) in the area where the analysis is…
-
1
votes1
answer101
viewsHow to stop reading from sys.stdin in Python 3 after reaching a bounded number of lines?
I am trying to receive command from sys.stdin until it reaches a limit n lines, and then finish the execution automatically. My code is as follows: import sys A = [] n = int(input("number of nodes:…
-
1
votes1
answer27
viewsWhy should this repeating structure that should turn a word upside down not come back at all?
phrase = str(input("Type your phrase: ")).upper().strip() words_phrase = phrase.split() words_together = ''.join(words_phrase) phrase_inverse = "" for letra in range(len(words_together) - 1, -1,…
-
1
votes1
answer513
viewsCount number of occurrences of a number
Program that has only one function, besides the main program, that will receive as parameters an integer number x, a sequence of integers L and a natural n, representing an item x that must have…
-
1
votes1
answer442
viewsPython - Typeerror: int object is not iterable
This is my code: import csv def gravar(nome,idade, sexo): with open('cadastros.csv', 'w') as arquivo_csv: colunas = ['Nome', 'Idade', "Sexo"] escrever = csv.DictWriter(arquivo_csv,…
-
1
votes0
answers30
viewscreate a new dataframe with another
I have a dataframe with (1242 Rows 325 Columns) of it I make a correlation ". Corr()" which results in (325 Rows 325 Columns) this code shows me the 15 smallest correlations of the lowest value for…
-
1
votes1
answer308
viewsOrganizing code within __init__.py
I’m having trouble organizing my code. Ex: I would like to put generic functions, as pro example those that deal with reading a configuration file in only one place (read that the __init__.py is…
-
1
votes0
answers228
viewsPrint shows no result displays "Typeerror: 'float' Object is not iterable"
I am making the code of a video lesson of Tensorflow but my code for more q is equal does not give the same result Everything that appears in the terminal: Windows PowerShell Copyright (C) Microsoft…
-
1
votes1
answer56
viewsProblem with dictionaries
Good afternoon! I am training my Skills solving some problems, I am a beginner in the Python language. I’ve been trying to solve the problem below for 2 weeks and can’t find a solution. Can someone…
-
1
votes2
answers69
viewsMake sure the entry doesn’t happen again, numerically and within a range?
I am programming a game of old. When the user chooses the house where he will mark his symbol (X or O), I need to ensure that: The input value refers to an empty box (which has not previously been…
-
1
votes2
answers619
viewsModifying a Python file without losing the current content
That doubt is a continuation of this here. I have a very large TXT file (about 6GB), each line being 1,300 characters, and I am manipulating these lines, as an example, I will use these three lines…
-
1
votes2
answers326
viewsRegex to capture links from sites specific to an HTML page
My goal was to make a Rawler web that found links (in many ways, but starting with http/s) in the HTML page of a site, I used requests and regular expressions, a part of the code went like this:…
-
1
votes2
answers66
viewsobject1 += object2 is different object1= object1 + object2 in python(3.8)?
objeto1 += objeto2 and objeto1= objeto1 + objeto2 give different results even though the two forms seem equivalent. Could someone explain to me what I’m not realizing? class f(): def…
-
1
votes1
answer24
viewsHow to use 2 lists to change Mysql via Python 3.x, in this case
Good guys, all right? I am creating a script in Py by COLAB itself because I need to change the weight of various products in Woocommerce, I capture the ID of a product group based on size 300ml,…
-
1
votes1
answer399
viewsSet the colors of a point on a matplotlib scatter chart
I am handling data received from an Arduine from a .txt. In the code, I Gero 4 arrays (X,Y,Z and F), where X,Y and Z are coordinates and F is the signal strength. I would like to plot the 3D graph…
-
1
votes1
answer128
viewsFix badly formatted JSON
I receive a totally non-standard JSON from a customer. And as always, the customer is always right :-( JSON arrives as follows: { dominio:casadasloucas.com.br,…
-
1
votes2
answers297
viewsPython calculator does not return function
I started using Python recently and am creating a calculator to train factors like function, input and function return within another function. However, my calculator is not working, it simply does…
-
1
votes1
answer149
viewsSelect data according to a specific time
I am doing a program in which, given the day of the week, the hours and the current minutes, he responds with all the "Doctors" available at that time. Each doctor has a period of care. For example:…
-
1
votes1
answer72
viewsHow can I write a loop to calculate each value of a list that is not predefined
Hello, I’m beginner in programming and in this forum tb " I am having difficulty calculating the standard deviation of a list of values ( not a predefined list, it is done through an input) How can…
-
1
votes1
answer586
viewsHow to press the Instagram follow button? with python
I’m trying to create a robot to follow people on Instagram, but I saved on the most important part, to click to follow the person. I’m using the python language and the Selenium, gnt I’ve put from…
-
1
votes1
answer161
viewsHow to use a Python function in Django
I’m currently having a problem where I haven’t found any solution that I’ve been able to understand and execute. I will be summarizing here the scope of what I need, otherwise it would be very…
python-3.x django django-templates django-rest-framework django-querysetasked 4 years, 1 month ago Bruno Marques 21 -
1
votes1
answer1220
viewsI need to select the last Dataframe value to calculate the value of the next row in the same column
I need to select the last value of the column "Season Minimum" to calculate the value of "Mint", name I gave the variable of the same column, currently my line of codes is like this: import numpy as…
-
1
votes1
answer47
viewsWhat is the difference between split(" ") and split()
I’m manipulating strings and I came across this question. I thought the semantics of the ways to use was the same, but I saw that not and it left me confused. In the case I thought with the use of…
python-3.xasked 4 years ago Shinforinpola 430 -
1
votes0
answers115
viewsAttributeerror: 'Nonetype' Object has no attribute 'append'
A relationship Many to Many between the table Patient and Illnesses, and Patient and Allergies I am with the following problem. pacientes_alergias = db.Table('pacientes_alergias',…
-
1
votes0
answers45
viewsListening to stdout from the Linux console with python3
I’m trying to make a script in python that I need to hear the stdout linux console. The script is to test serial transmission error rate for image recording of an OS on an iMX collibri card, as…
-
1
votes2
answers189
viewsfilter dataframe by python line
Hello, I own this Dataframe with hundreds of thousands of lines, I want to filter so that selection is only the desired lines, in case more current lines, follow an example of what I want: the…
-
1
votes3
answers464
viewsIdentify amount of upper and lower case letters in a string
I need to check if a word has more upper case letters and replace the whole word for lower case only, also check if it has more lower case letters and replace the whole word for upper case. For…
-
1
votes0
answers95
viewsScript for creating tables in mysql using Python
I intend to create a script to create tables in mysql using Python 3 to register users, each table will have the name of the person’s CPF, however there is an error syntax (1064) I couldn’t…
-
1
votes1
answer75
viewsReturn name instead of foreign key ID
I’m developing a Python system and wanted to return data from the specific database, only instead of the foreign key id I wanted to return the name of that person. The creation of tables:…
-
1
votes0
answers70
viewsProgram not responding PYQT5, when I need it to stand still for a few seconds (WIFI,UART,ESP32)
I am facing the following problem, my program sends when the object, modemlist which is a Qcombobox is in the WIFI option I send a request to the esp show me the available networks and it takes a…
-
1
votes0
answers58
viewsExpansion in Taylor using functions
I wrote a function that calculates the sine of an angle using the Taylor expansion given by the expression sen(x) = x - x 3/3! + x 5/5! - x 7/7! + ... AD INFINITUM. I created a function that…
python-3.xasked 3 years, 11 months ago Gabriel Barreiros 11 -
1
votes0
answers73
viewskivy : The term 'kivy' is not recognized as cmdlet name, function, script file or operable program
When trying to run script from kivy.app import App from kivy.uix.gridlayout import GridLayout from kivy.uix.label import Label from kivy.uix.textinput import TextInput class TelaLogin(GridLayout):…
-
1
votes1
answer100
viewsHow I can prevent the user from pressing the button several times in a row in PYQT5
[Solved]I’m pretty beginner in pyqt, mainly in python, I’m with a problem I looked at several foruns, how can I prevent the user from pressing the button multiple times in a row? I already tried…
-
1
votes2
answers231
viewsdownload with requests and open python
The following code is part of a loop that will download multiple files and save to their respective directories. I’m trying to download the file from the "url" and want to save in a directory of…
-
1
votes1
answer44
viewsHow can I check if an element of a list that corresponds to the value of a dictionary is related to the key?
Code: entrada = '' dici_presentes = {} listavalores = [] while entrada != 'FIM': casos = int(input()) for i in range(casos): nome_presente = input().split() c = nome_presente[0] v =…
-
1
votes2
answers126
viewsHow to create nested and counting dictionaries from lists/tuples?
I have lists of sublists and tuples inside. I need to create a dictionary whose key is the car name and the value is a dictionary nested with the car model count. My lists are like this (it’s just a…
-
1
votes1
answer58
viewsProblems tried to change function next()
I need to do this class-related activity, I don’t know much about it yet and I’m a little confused. Write a Python class with a custom iterator, when the next() function is called, it should return…
-
1
votes1
answer388
viewsOpen a url right after opening a new tab in the browser (Selenium)
I’m making a code to access a template page of my institution. Objective: In the first guide, I open the digital book; In the second guide, I open the template. However, I have to do the feedback in…
-
1
votes1
answer38
viewsHow to use for comparing a specific index?
In function bonAppetit, i want to pick up only the content k (in the case k=1 and the value is 10), and see if that number is less than or equal to b. Only my program is running the whole list. def…