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
votes2
answers39
viewsProblem using Return (Python 3)
I’m starting now and I tried to do it according to my teacher’s explanation, but I’m not getting the job done. I want you to go back to the beginning if the user answers wrong instead of just…
-
-4
votes1
answer49
viewsHow to break line after a specific line? PYTHON
My first question here, guys, I need to add a line break before he writes for1 again, as I do in this code? And I would also like for7 to be the last to be printed, as in the original file it comes…
-
-4
votes2
answers69
viewsMenu Cafeteria
Greetings, I am beginner in python and I need to make a code in which it starts with a table, stating the product, its value and a code for it. The program has to request the code of a product, the…
-
-4
votes1
answer35
viewsWhy transfer the variable of entry into another?
In one of the examples, on page 92 of the book "Introduction to Programming with Python: Algorithms and Programming Logic for Beginners - Nilo Ney Coutinho" he gives us the code below, but I am…
-
-4
votes1
answer69
viewsIs there a way back to a particular line of code?
I would like to know if there is any module, function, etc. that would allow me to go back to a certain line of code. I have this doubt because, whenever I want to ask a question repeatedly, I have…
-
-4
votes1
answer22
viewsGuys Is this python exercise right?
class Bola: def __init__(self,cor,circunferencia,material): self.cor = cor self.circunferencia = circunferencia self.material = material # MOSTRAR COR def mostrar_cor(self): return print("A cor e :…
-
-4
votes0
answers22
viewsIdeal Height Of One Person
Here is the code: Create a program that reads the ideal weight of a person of both sexes For men: (72.7*Height) -58 For women: (62.1*Height) - 44.7 print('PESO IDEAL DE UMA PESSOA')…
-
-5
votes1
answer3993
viewsConvert dollars to real with Python
Create a program that asks for the amount of US$ and the fee and displays the amount of R$. dolar = float(input("Informe a quantidade de dólar para conversão: US$ ")) contaçao = float(input…
pythonasked 7 years, 2 months ago William Martins 21 -
-5
votes1
answer2136
viewsINVALID SYNTAX ERROR
The code below is giving error of invalid syntax. Follows: while(escolha!=0 and confirmar!=0): print("Menu") print("1- Inserir um item") print("2- Remover item") print("3- Listar todos os itens")…
-
-5
votes1
answer3175
viewsNumber of rows and columns of a python matrix
How do I know the number of rows and columns of an array in the Python language?
-
-5
votes2
answers3255
viewsUsing Append - Python
What is the need to use the "Append" function in my code? They say it can be used to add another element to my Python list, but wouldn’t it be simpler to add this other element in a traditional way?…
-
-5
votes1
answer197
viewsDeath Note in Python: Problems with two Elif’s in the code
In my Death Note code in Python there is two conditions (elifs) that do not work: 1st condition (penultimate): Must show the condition that the victim is unknown and needs to enter her name. 2nd…
pythonasked 5 years, 6 months ago user141036 -
-5
votes2
answers352
viewsHow to delete negative elements from one list and add them to another in python?
tried with this code but does not work accurately from random import randint lista=10 X=list(range(lista)) R=[] def gravarLista(X): for i in range(lista): X[i]=randint(-5, 5) print(X) for i in X: if…
-
-5
votes3
answers169
viewsDoubt about Python data output
I’m solving the following exercise: Make a program that prints on the screen the numbers from 1 to 20, one below the other. Then modify the program to show the numbers next to each other. The first…
-
-5
votes2
answers37
viewsWhat is the syntax error in my function?
def Grow_population_rate(year_1, year_2, City_name, pop_1, pop_2): pop_diff = pop_2 - pop_1 year_diff = year_2 - year_1 for pop_rate = pop_diff/year_diff * 100: return("The…
-
-5
votes1
answer43
viewsPrint list of numbers in a range
I’m having trouble creating a program that asks the user for two values and prints all primes in that sequence (including the numbers typed) Here comes the code: number_range1=int(input('Digite o…
pythonasked 3 years, 8 months ago Nicolas Amad 9 -
-5
votes3
answers248
viewsRegex - take only the first occurrence of a word in Python?
In a string, there are several occurrences of a word, but I want to take only the first occurrence of this, how to do? Below comes 'first' twice, but I wish only the first. re.findall(r'primeiro','…
-
-5
votes2
answers50
viewsIn if, when the user puts another state that is not specified, instead of entering Else, he enters if and continues the code normally
The code is like this: est = input('Qual estado reside atualmente? ') if est == 'São Paulo' or 'SP' or 'sao paulo' or 'São paulo': email = input('Digite o seu e-mail: ') tel = input('Digite o seu…
-
-5
votes1
answer75
viewsERROR STARTING . EXE PYTHON
Hello, I’m creating a chatbot in Python using the Chatterbot library, so I tried to turn my simple Python code into a file. exe so other people can test, I’m using pyinstaller. I installed it by…
-
-5
votes1
answer84
viewsCritography in Python
I just entered the programming area and my college ended up applying a work that we will have to create a program in Python that can perform encryption/ decryption of any message, encrypted or not.…
-
-5
votes1
answer38
viewsCompare two lists element by element:
Hi I’m trying to develop a code, the code is: lista1 = ['5','5','1','4'] lista2 = ['5','5','0','1'] I was trying to get him to compare every element of Lista2 to list 1 and then identify element by…
-
-5
votes1
answer62
viewsHow do I find the names on the list?
Complete the function buscar(lista, animal) below, which receives two values: A list of animal names. The name of an animal you want to find on the list. The function must return True if the animal…
-
-5
votes1
answer50
viewsIs there something wrong with my code?
I made a Python code that appears to be working properly. But for reasons of code improvements I want to know if there’s a way to increase his performance or if something I’m doing is wrong. Follows…
-
-5
votes2
answers80
viewsHow do I check which items in List2 are in List1, then their count and order
I am a beginner in Python and I would like to count on your help for the problems below. I have worked on two lists as the following objectives: 1.Check which items in List2 are in List1 2.Count…
-
-5
votes1
answer72
viewsHow to add values from within a Python list?
I made a code that stores data in a dictionary, and the dictionary is stored in a list, but when I try to add and divide the values, the first average is the one that ends up being valid for all…
pythonasked 3 years, 8 months ago Victor Eduardo 3 -
-5
votes1
answer95
viewsReturn of a function in Pyton
How do I return only the list of this function without executing the print and input commands who are inside ? def entrada_soma(): parcela1 = list() parcela2 = list() print("Digite a opção desejada…
-
-5
votes1
answer22
viewsTypeerror: not all Arguments converted During string formatting (what should I do?)
I’m solving a simple question of calculating tax on a salary: sal=float(input('digite o valor:')) if sal>3000: percent=0.25 elif sal>2000: percent=0.20 elif sal>1000: percent=0.10 else :…
-
-5
votes3
answers157
viewsHow to add digits from a number to "1" digit?
I need to sum all the digits of a number until the result of this sum is a number of only "1" digit, that is to say, where the digit number of a given number is greater than 1, I must add their…
-
-5
votes1
answer190
viewsValueerror: invalid literal for int() with base 10: 'eight'
I need to make treatments if the user type something that is different from numerical values, when I type numerical values the program runs cool, but when I type strings it shows errors. Traceback…
pythonasked 3 years, 4 months ago Lilian Kalinka Carvalho 1 -
-5
votes1
answer37
viewsRunning dependent threads in parallel in python
I’m trying to run 2 threads simultaneously in my Python program: from threading import Thread import manipulateData import stream processo1 = Thread(stream.main()) print(processo1) processo2 =…
-
-5
votes1
answer63
viewsHelp with this terrible riddle for a beginner!
I want to identify odd numbers, but leave with a print formatting with no whitespace EX:"These are the odd ones: (1, (), 3, '')" I want you to show it like this: "These are the odd ones: 1, 3,"…
-
-5
votes0
answers36
viewsPython E-mail Win32com.client - "ppppppppppppp"
I’m having some difficulty with an attempt to send email via Win32. When sending the email, at the end of the body, it always appears "ppppppppppppp" [![exemplo_email_sent][1]][1] I already sent in…
pythonasked 3 years, 2 months ago Michael Guimaraes 1 -
-6
votes1
answer79
viewsline 17, in <module> print(f'{a[str(x)]}: {str(n)[r-c]}')
# variaveis a = {'0': 'Milhar', '1': 'Centena', '2': 'Dezena', '3': 'Unidade'} x = int(0) # Variaveis while True: n = str(input('Digit a number: ')) if n.isnumeric(): n = int(n) break else:…
-
-6
votes2
answers84
viewsSyntaxerror: invalid syntax, somebody help me!
I can’t identify the error someone could tell me where it is!…
pythonasked 5 years, 7 months ago user144307 1 -
-6
votes2
answers51
viewsPython- I need to make an application that receives float values and organize them without using . Sort
So far I’ve managed to do the following: lista = [] a = 1 b = 0 while a > 0: a = float(input("Colque os valores: ")) b = b + 1 for i in range (b): lista.append(a) n = len(lista) for i in…
-
-6
votes2
answers75
viewsHelp to find the square root of a positive Python number
I am a beginner in Python and I am doing some exercises to learn more about this language. In one question, you were asked to create a program that asked for a number and returned the square root of…
-
-6
votes2
answers114
viewsDoes anyone know how to create this program?
Write a Python script to create an array turmaA with N real values and a vector turmaB with K real values, containing the grades of the students of the two classes, whose grades should be generated…
-
-6
votes2
answers45
viewsI need to count a number of specific numbers per column in a matrix
I’m doing a program that reads the number "1" per row in the matrix and I need to find the number "1" per column. It turns out that I am not able to assemble a code that reads only the columns and…
-
-7
votes1
answer22
viewsDatabase in CSV
If everyone while creating applications on the WEB ,Desktop or Mobile needs to export or import data type csv because they have not created a DATABASE MANAGER SYSTEM in csv ? Answer: Is there…
-
-7
votes1
answer80
viewsI’m a beginner and I’d like to know what’s wrong with my code
from random import randint computador = randint(1, 5) print('\033[31m=\033[m'*30) print(' \033[30mMENU DE JOGO\033[m') print('\033[31m=\033[m'*30) print('PEDRA, PAPEL, TESOURA, LAGARTO, SPOCK')…
-
-7
votes1
answer42
viewsPYTHON LOGIC/FRACTION ERROR(HOW TO SOLVE)
In this market box code, if you type 0 in the variable Pv there will be an error in the last print in the variable Vp/Pv, because there is no way to caucular a number x divided by zero, how do I…
-
-8
votes1
answer223
viewsScript that counts amount of Notes and Coins in box in Python does not work
Help me make this script work.…
pythonasked 4 years, 3 months ago Tassio Limar 1