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
-
-4
votes1
answer100
viewsExcept is not capturing the exception
mensagem_de_modalidade = int (input (''' Como você quer jogar ? 1)Solo 2)Em dupla 3)Em trio''')) try : if mensagem_de_modalidade == 1 : print ("oi") if…
-
-4
votes2
answers71
viewsPython rounding list
a = [1.2,2.3,3.4] b = [4.1,5.2,6.3] x = 3.4 y = a.index(x) print (y) y1 = b[y] print (y1) As I would in the code if x were 3. and I wanted to show the nearest value. in the case if x = 3, y would…
-
-4
votes2
answers129
viewsHow to delete a json object with python?
data = ler_repositorio() print (data) excluir_funcionrio = input('quem você quer excluir: ') print('Tem certeza?') print('1 - continuar') print('2 - voltar') opção_adquirida = int(input('Escolha:…
-
-4
votes1
answer258
viewsI need a recursive Python algorithm that multiplies two numbers through successive sums
Multiplication must be done by successive sums, 6x4= 4+4+4+4+4+4+4+4 Program entry: 6 4 Output from the program: 24
pythonasked 4 years, 6 months ago Oliveira Mello 1 -
-4
votes1
answer58
viewsHow to create a website with the server pc using only Python?
summary explanation think of the site as an app. I need to create a mobile app that accesses functions on the pc via commands. when it comes to handling the commands and the function call I even…
-
-4
votes1
answer57
viewsHow to use a Python keyword as a parameter?
How can I pass a parameter named from? The object ET.Element allows me to pass various parameters that will be attributes of my element in XML, but how to use a name that is a language keyword, such…
-
-4
votes2
answers454
viewsPercentage with if in Python
Hello, I’m a beginner in Python and I came across a great question in a lesson I’m doing. I’m doing a program that takes user information such as: name, date of birth, position and salary. After…
-
-4
votes2
answers140
viewsHow to verify if a poetic composition is a tautograma?
The user enters a sentence and I have to check that all the initial letters of each word are equal. So far my code is like this: frase = str(input()).split if frase == frase[0]: print("tautograma")…
pythonasked 4 years, 2 months ago Ysabeli Gabriela 3 -
-4
votes1
answer136
viewsGo inside another For
Guys I’m needing to run a for inside another for but I’m not getting it. I need to store the result value within a variable. I’m not familiar with python, I believe this is the biggest problem.…
-
-4
votes2
answers961
viewsHelp with error '>' not supported between instances of 'Nonetype' and 'int'
nome_usuario = input('Informe o seu nome: ') idade_usuario = int(input('Informe sua idade: ')) peso_usuario = float(input('Informe seu peso: ')) peso_desejado = float(input('Qual o peso…
pythonasked 4 years, 2 months ago Naissinger 1 -
-4
votes1
answer57
viewsTry no for - PYTHON
Guys, how do I use Try no for? When it falls in except and the person type a string, it gives another error and terminates the program, in while I can use normally. I tried using a for loop with…
-
-4
votes1
answer41
viewsHow to get Polygon coordinates from a python city?
Good, to get the coordinates(lat,long) of a city with you using geolocator.geocode, but need to get the coordinates Polygon(the whole area of the city), someone knows of another library that return…
pythonasked 4 years, 1 month ago Eduardo Rioja 3 -
-4
votes1
answer37
viewsDoubt about Python List Code
Can anyone help me? I’m trying to print the 1st, 2nd and 3rd place message on the screen, but I’m not getting it. Someone has an idea? lista = [] flag = False for x in range(3): tamanho = len(lista)…
pythonasked 4 years ago wtf-diamond 3 -
-4
votes1
answer95
viewsWhy are you making a mistake in calling a method?
I’m trying this code: class Car: def beep(): print('Beep') car = Car() car.beep() Typeerror: method() takes 0 positional Arguments but 1 was Given 'Cause there’s a mistake?…
-
-4
votes3
answers40
viewsPYTHON BEGINNER Why are you giving the error 'is not defined' , how do I fix it?
Hello, I’m a beginner, I need help. I defined the populations of the regions: popula_Nordeste = 27.09 popula_Sul = 14.26 populaca_Sudeste = 42.04 population = 8.82 population = 7.79 And I used an…
pythonasked 4 years ago Anthony Knight 11 -
-4
votes1
answer19
viewsInitial Setup Problems
Guys, new in programming and I’m having trouble installing Python. Command does not recognize the python that is installed.…
pythonasked 3 years, 11 months ago user148941 -
-4
votes1
answer84
viewsHow to use While in Python 3?
My doubt is about the bow while, I can’t understand how it works. Write a Python function that takes, by argument, two integers and returns the sum of all integers between the two (including the…
-
-4
votes3
answers418
viewsHow to write a function that takes 2 integers as a parameter and returns the largest of them?
Write the maximum function that takes 2 integers as parameter and returns the largest of them. example: >>> maximo(3, 4) 4 >>> maximo(0, -1) 0…
pythonasked 3 years, 10 months ago milena baiao 1 -
-4
votes2
answers145
viewshow to avoid EOL in python
I have this code: número = 4 chute = input('quanto é 2+2?:\') if chute == número: print('parabéns, vc acertou :)') else: print('ops, parece que você errou, tente novamente que você vai conseguir…
pythonasked 3 years, 8 months ago King Trollex 11 -
-4
votes1
answer258
viewsNot all Arguments converted During bytes formatting Insert Python
I was trying to add python integer values to a mysql database with the following code: import MySQLdb valor1 = input("Digite o primeiro valor: ") valor2 = input("Digite o segundo valor: ")…
-
-4
votes1
answer27
viewsHow can I check if there are equal numbers in the same column or row in a numpy matrix?
from random import sample import numpy as np a = sample(range(1, 5), 4) b = sample(range(1, 5), 4) c = sample(range(1, 5), 4) d = sample(range(1, 5), 4) jogo = np.array([[a[0], a[1], b[1], b[2]],…
-
-4
votes1
answer56
viewsProblem with exponent operator in function
destaquei o problema e descrevi na equação: M = 1000/(10 - Vinc(10)**2/299792458**2)**(1/2) //////////////////////////////////////////////////////////////////////////////// import matplotlib.pyplot…
-
-4
votes1
answer178
viewsWith creating a program that reads 10 numbers and writes the lowest and highest read value (Python)?
I’m having a little trouble with this exercise. Here is my code: python num = float(input('Digite o 1 numero: ')) guarda_maior = num guarda_menor = num for n in range(1, 10): num =…
-
-4
votes1
answer52
viewsRemove duplicates in tuple stems
The following code gives error when running def sensas(lst): lst_unica = [i for n, i in enumerate(lst_com_unicos) if i not in lst_com_unicos[n + 1:]] for lst_resulta_unica in lst_unica: return…
-
-4
votes2
answers49
views(python) as I put the go inside def
numero_sorte = 3 n_tentativas = 4 for rodada in range(1,n_tentativas): tentativa_2 = input ('qual o numero secreto? ') tentativa_2= int (tentativa_2) def jogo_adivinha(chute): if numero_sorte ==…
-
-4
votes2
answers54
viewsCan someone help me subtract one list from another?
I know it’s simple but I’m beating myself here to do this, I’d like to do a list subtraction in the following way lista_inicio = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "J", "Q", "K", "A"]…
-
-4
votes1
answer64
viewsWhy doesn’t the program recognize the "N"?
class primao: from random import randrange def __init__(self, N=randrange(2,100), divisor=0, pontos=0, laco=True, prova_cabal= N%divisor): self.N= N self.divisor=…
-
-4
votes1
answer35
viewsHow do I make a series of numbers (3-in-3). Using for x in range?
How I make a series of numbers (3-in-3). Using for x in range ?
-
-4
votes1
answer39
viewsAdd a number to another
I was wondering if anyone knows how to add a number to another in Python, for example in the code I’m doing: Write a python script that does the following: 1 * 8 + 1 = 9 12 * 8 + 2 = 98 123 * 8 + 3…
-
-4
votes2
answers64
viewsPython - How to calculate the predecessor of a number?
Create a function called predecessor that takes as a single parameter an integer a and prints its predecessor. Entree The input consists of a single row containing the integer number of the input a…
-
-4
votes3
answers101
viewsRules in python list creation
Good afternoon, I need to follow some rules when generating my list. Are these: 1.Have at least one repeated value 2.Have at least 6 unique values 3.All the numbers cannot be repeated How can I do…
-
-4
votes2
answers159
viewsHow do I repeat an algorithm in Python?
I’m starting to study programming and I’m making a simple Python calculator in Pycharm, and I wanted to know how to repeat an algorithm when the user decides to continue using the calculator. I…
-
-4
votes1
answer102
viewsPython. I cannot return an if statement within a function
def func(x=1, y=3): if x == y: return "Igualdade." else: return "Desigualdade." if x > y or x < y: return True if True == x > y: return x else: return y if x < y: return (y - x) == c if…
pythonasked 4 years, 4 months ago Brunno Silva 1 -
-4
votes1
answer53
viewsI’m having trouble with the code
people I am making a school system with python using the modules Tkinter and Sqlite but when I insert the variables of the text boxes in the database information it gives this problem take a look at…
-
-4
votes1
answer76
viewsProblems in PYTHON end result
I am a beginner in Python and I am developing a calculator, creating a class, within it there are 4 functions, being the 4 operations. And in the main only the basic input. My goal in this program…
-
-4
votes2
answers47
viewsLogin function does not access the register, which has already been entered
Function: Log in and Register() def Logar(pessoas): from Funções_pt.cores import vermelho usuário = str(input('Nome de usuário: ')).strip() senha = str(input('Digite sua senha: ')).strip() if…
-
-4
votes2
answers154
viewsRepeat Structures in Python
recently started my studies in programming and was doing a URI exercise in which I have to read an undetermined set of values M and N, where for each pair read, show the sequence of the smallest to…
-
-4
votes1
answer54
viewsCustomer Propensity Analysis - Scheduling Service - Variavel_target
I’m starting to take the first steps in machine-learning and would like to apply a prospecting analysis to each client according to their scheduling service. I have a client portfolio that has one…
-
-4
votes1
answer141
viewsPython replace values with others in combination
Opa my beasts, I am with a difficulty, I made a combination list of 0 and 1, where 1 will be replaced by positive values of a list, and 0 will be replaced by negative values of another list and…
-
-4
votes2
answers60
viewsWhere are the syntax errors?
I’m new to Python and the teacher is going through his classes too fast. Although it is ridiculous, I am in doubt what is wrong in the code below. I believe that the (basic) logic is not very wrong,…
-
-4
votes1
answer51
viewsConcatenation in Python
I’m having trouble concatenating the result of a string with a string. velas[0] = '\033[0;32;42m g ' if velas[0]['open'] < velas[0]['close'] else '\033[0;31;41m r ' if velas[0]['open'] >…
-
-4
votes2
answers80
viewsFilter column value and extract from these rows in another column the value and write to a new column
I need some help, I’m getting laid. I have the title as shown in the table on the left and need to transform with Pandas in the format of the table in yellow, will the account Pandas? I am with 3…
-
-4
votes1
answer43
viewsHow to repeat all the code at the end of the execution when "While" repeats only one part?
I’m doing a program that calculates a person’s pay based on the number of hours and overtime worked. The idea is that at the end of the execution the user decides whether to recalculate or terminate…
-
-4
votes2
answers403
viewsCompare matrix values and add them to another (python)
I am not able to make the structure to compare whether the value at the[l][c] position of one matrix is greater than at the same position of another, and if so, this value goes to that same position…
-
-4
votes2
answers50
viewsCopy Files using shutil library
Hello, I’m learning the programming in Python and a question has arisen regarding the shutil library. Theoretically, I can make the copy of the file using this library, however, I wonder if there is…
-
-4
votes1
answer62
viewsJupyter notebook has stopped working
I had been using the jupyer notebook for hours and out of nowhere it started to go wrong in all the cells. When I went to run everything from the beginning it made a mistake on EVERYTHING. What…
pythonasked 3 years, 7 months ago Anderson Costa 15 -
-4
votes1
answer86
viewsHow could I resolve this issue using Python dictionaries?
Make a program that reads two keyboard strings and tells: • The characters of the first text that are not in the second; • The characters of the second text that are not in the first; • The…
pythonasked 3 years, 7 months ago Mirandir dos Santos 1 -
-4
votes1
answer71
viewsproblem with Try and except in a simple python program
def questao3(): while True: try: nome_produto = input('Digite o nome do produto: ') preco = float(input('Digite o preco desse produto: ')) while preco <=0 or preco > 100: raise ValueError…
pythonasked 3 years, 5 months ago matheus santos 1 -
-4
votes2
answers65
viewsDelete a variable the program receives in input.split(" ") in Python
I am working on a calculator that needs to receive an operation (such as SUM, DIV, LOG10 etc.) and operators on the same line, eg: SUM 2 4 But when I get LOG10 or ROOT the user will only type an…
pythonasked 3 years, 5 months ago Isabela Pereira dos Santos 1 -
-4
votes2
answers50
viewsPython - Doubt-transform into Dataframe
good morning! People connected using python in Sql database using pymssql import pymssql conn = pymssql.connect(server='nomeservidor', user='usuario', password='senha', database='banco') cursor =…