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
-
7
votes1
answer3720
viewsThe.Leep() team with if/Else statements
Hi. I’m at an impasse. My goal is that if the user presses enter or waits 2 seconds it starts "Powerbit", but in an if/Else statement and I don’t know how to do it. Example: #(...) elif machine ==…
-
7
votes2
answers7019
viewsTkinter focus a window ignoring the back?
In my code there is a frame with a button and it is called "Open", when clicking "Open" another window will appear. The problem is that if I click on the window that this "Open" button again, it…
-
7
votes2
answers269
viewsImporting Packages Pycharm
Guys, I have a problem trying to use a project in pycharm.. I use xhtml2pdf and when trying to debug this error appears : However I already have the added Packages in the project: Does anyone have…
-
7
votes2
answers5650
viewsHow to Direct Commands to the Linux Python Terminal
I need to create a script in Phyton that when executed is via mouse click or keyboard 'enter', it opens the linux terminal itself and execute any command inside it. I have already managed to get him…
-
7
votes1
answer4415
viewsRecursive function simulating a number elevated to a power
How to simulate the elevation of a number to a power using the recursion (and Python)?`
-
7
votes3
answers2508
viewsHow to work with OCR to recognize photographs
I am currently working on my Course Completion Work and the theme involves OCR. I did some research and found the Tesseract, I also found libraries in Nuget for him (I’m using C#). The problem is…
-
7
votes1
answer161
viewsIs it a good idea to map Urls that delete GET entries?
I’m studying Django and wondered if it’s really good practice to set up removals URL via GET, for example: http://meusite.com.br/usuario/deletar?id=10. Is this really good practice? Since some HTTP…
-
7
votes2
answers1844
viewsHow to declare an anonymous function in Python?
How do I declare and how an anonymous function of Python?
-
7
votes2
answers11102
viewsHow to import an xls file to Python?
I’m starting my studies in Python and would like to import a database that is on .xls for Python. Someone could help me? NOTE: Python version 3.4.3.
-
7
votes1
answer480
viewsMerge CSV with Python
I have a collection of dozens of CSV files. Most of them share the same fields, but some have unique fields. I want to merge them, using Python into a single CSV file with a global cabling that…
-
7
votes1
answer922
viewsRedeem dictionary key with maximum sum of respective value
I have the following dictionary: dic = {'bsx_8612': [23, 567, 632], 'asd_6375': [654, 12, 962], 'asd_2498': [56, 12, 574], 'bsx_9344': [96, 1022, 324]} I want to redeem the key whose value has the…
-
7
votes1
answer1514
viewsIs it possible to create graphical interfaces for Python applications?
And what about using them on a computer that doesn’t have a Python interpreter? If the answer is yes, what software is capable of doing this?
-
7
votes2
answers666
viewsCheck file extension in template - Django
I have a Django application where in the template I need to validate a file extension coming from filefield. <div class="row"> <p class="anexos"> {% trans 'Anexos' %} </p> #if .jpg…
-
7
votes2
answers5604
viewsHow do I repeat a string in Python?
The question is simple: How do I repeat a string in Python? I’m used to PHP. When I want to repeat a string in PHP, I do so: var $str = 'StackOverflow'; str_repeat($str, 5); // Imprime:…
-
7
votes1
answer492
viewsUnderstanding the pythonic way of dealing with properties
I am on time trying to understand how this issue of python properties works. But the problem is that in all the tutorials net out only find the damn example with only one attribute. I’m looking for…
python python-3.x getters-setters property decorator-patternasked 9 years, 7 months ago Devel Silva 73 -
7
votes3
answers27933
viewsPython str.replace() doubt
I have the following text:: 'box 1 is blue, box 10 is green, box 100 is empty' I want to replace 'box 1' with 'package 2', so I do: >>> texto = 'caixa 1 é azul, caixa 10 está verde, caixa…
-
7
votes3
answers13058
viewsHow to do a range with letters of the alphabet in python?
In PHP, when we want to make a array alphabet letters, we can use the function range. Example in PHP: $letras = range('a', 'z'); Upshot: Array ( [0] => a [1] => b [2] => c [3] => d [4]…
-
7
votes2
answers1186
viewsProblem connecting Mysql in Python 3.4
I just installed my virtual environment, installed Pymysql and created a project, however, when trying to start an APP python manage.py startapp nome, the following problem arose: Error loading…
-
7
votes1
answer638
viewsRecovering list values from python lists
I have tried several things and I still can not grasp what the problem of my code, is a simple code. With numpy i place txt values in the array of arrays and want to make some copies to two other…
-
7
votes1
answer6777
viewsHow to run another program by python?
I’m looking to make a calculation engine on Python. For example, I have a name program engine.py, that takes an equation and returns the roots. I wanted to write another program named interface.py,…
pythonasked 9 years, 3 months ago Guilherme Edington 73 -
7
votes1
answer2097
viewsWhat is the difference between the concept of static and dynamic typing and the concept of strongly and weakly typed?
There is some confusion about the concept of programming languages with static and dynamic typing and the concept of strongly and weakly typed programming languages. For example, in my opinion…
-
7
votes1
answer752
viewsHow to make a sum in Lambda with recursive logic using successor and predecessor?
I’m trying to assemble a Soma with recursive logic using just successor and predecessor in Lambda. But they’re not succeeding... In the case: suc = λx.x+1 ant = λx.x-1 I’ve done something like:…
-
7
votes2
answers350
viewsHow to get the set of all Python arguments?
Python has both positional and named parameters and operators * and ** which allow receiving an arbitrary number of additional arguments: def foo(a, b, c=1, *args, **kwargs): print(a, b, c, args,…
-
7
votes2
answers1833
views -
7
votes2
answers8390
viewsWhere is the constructor of the class in Python?
Definition of Wikipedia. The builder is a method which is generally responsible for allocating the necessary resources to the operation of the object beyond the initial definition of the variables…
-
7
votes3
answers4285
viewsUse of colon character ":" in Python
In Python there is the character colon :, therefore, what I understand of this character is that it is used in functions def soma(x,y):, conditional commands if soma > 100: and for classes class…
-
7
votes1
answer1093
viewsHow does dynamic typing work in Python 3.x?
I am new to Python and a question came to me when solving exercise 1001 of Uri Online (read A and B, assign sum to X and print), when writing the following code, I received the concatenation: a =…
-
7
votes2
answers447
viewsHow to make a loop that compares string with a python float?
I’m assigning the value 1.5 the variable h, but it does not accept values of the type float and does not complete the code. h = (input("Informe sua altura: ")) # aqui ele recebe um elemento qualquer…
pythonasked 8 years, 6 months ago Adriano Souza 71 -
7
votes1
answer388
viewsParamiko Error Handling (Python)
Hello, I am mounting a script where the user will authenticate on a device, if everything goes well the code continues otherwise it shows an error message. I am using the Paramiko library to do the…
pythonasked 8 years, 6 months ago Cristhian Miguel 207 -
7
votes2
answers1425
viewsNameerror: name 'ana' is not defined
I am a beginner in python and I needed to make a program that would verify if a given word is palindromo. The program then would be: #encoding: utf-8 palavra = input ('Palavra: ') if palavra ==…
-
7
votes3
answers1045
viewsFibonacci with parallel execution? Threads?
def recur_fibo(n): """Recursive function to print Fibonacci sequence""" if n <= 1: return n else: return(recur_fibo(n-1) + recur_fibo(n-2)) This code makes the recursive Fibonacci "simple"...…
-
7
votes3
answers14487
viewsDivide a list into n sublists
I have the following list: l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14] What I need is to divide this list into n sublists, in this case it is not possible to do it manually because the n…
-
7
votes2
answers1318
viewspython: compare list containing multiple lists with a different list only
I’m solving an issue where I have to do a program that corrects tests. The program receives a feedback and answers from "n" students and compares with the feedback provided. The answers of all…
pythonasked 8 years, 4 months ago Junio Calú 75 -
7
votes3
answers2556
viewsHow to join multiple lists in a matrix
How would a way to merge two lists into one matrix, where each column of the matrix represents one of these lists. Example: a = ["Laranja", "Maçã", "Uva"] b = [40, 50, 2, 45, 56] Expected result: x…
-
7
votes1
answer88
viewsHow to list the synopsis of classes?
I started to venture into python and am making program that lists class properties. I use obj well.dic, help(obj), and dir(obj). Someone knows if there is a command that lists the synopses of the…
-
7
votes1
answer827
viewsCopy a numpy.array without modifying the original
Given a numpy.array as the next: r = np.arange(36) r.resize(6, 6) Which results in: array([[ 0, 1, 2, 3, 4, 5], [ 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23], [24, 25,…
-
7
votes1
answer5427
viewsHow to configure apache2 for python 3.5.2
I have been trying to study web programming with Python, but I can’t configure the server on my computer, can anyone help me? Whether it’s telling me how to set up or providing me with an already…
-
7
votes1
answer1482
viewsWhat is the difference between __init__ and __new__?
What is the difference between the special methods __init__ and __new__ in Python?
-
7
votes1
answer1031
viewsHow do I know if a point (x, y) is within the filled percentage of a pie chart?
I arrived at this code showing whether a point (x, y) is inside or outside a circle on a Cartesian plane. def dentro_fora(p, x = 0, y = 0): r = cx = cy = 50 if (x - cx)**2 + (y - cy)**2 < r**2:…
-
7
votes1
answer17403
viewsWhat is the best way to concatenate strings in Python?
I know I can concatenate strings with +=, +, join() and append(). They all give me the same result when I concatenate two strings. What is the best way to concatenate Python strings? What is the…
-
7
votes1
answer10500
viewsWhen to use lists and when to use tuples?
What’s the difference between the types list and tuple in Python and when to use each?
-
7
votes4
answers16556
viewsGenerate random numbers in Python without repeating
I have the following situation: I have a vector with 4 indexes. In each index a random value is generated from 0 to 100. I have a code that does this perfectly, but sometimes the numbers repeat.…
-
7
votes2
answers7126
viewsHow to create an executable for a python program that installs the used libraries?
Hello, I have a code I made in python and it uses some libraries. I wonder if it is possible to make an executable for this program and q user q uses it n need to have python or these libraries…
-
7
votes3
answers69151
viewsVectors in Python
Okay, I’m coming from line C, and I’m having a hard time creating vectors in python. In C if I write vet = [5]; I would create a vector called vet with 5 indices. I wish I knew how to do this in…
-
7
votes1
answer3139
viewsPython integration with C#
Is there any way to integrate C# and Python 3? I need to create graphical application in a practical and fast way. Currently, I have the scripts in Python working 100%, now what I need is to take…
-
7
votes3
answers68693
viewsHow to create a python array
I want to create an array where the user specifies the number of rows and the number of columns. Initially an empty matrix was given: matrix = [] The codes must start from there the code below was…
-
7
votes11
answers37801
viewsCompute sum of digits of a number
Type a program that receives an integer number in the input, calculate and print the sum of the digits of this number in the output. Example: >>> Digite um número inteiro: 123 6 Tip: To…
-
7
votes1
answer3178
viewsWhat is the difference between package and module in Python?
Is there a difference between a package and a module in Python? If there is a difference, it is possible to give examples of packages and modules?
pythonasked 7 years, 8 months ago Thiago Krempser 1,878 -
7
votes1
answer1523
viewsPython. pyc file function
If the Python language is interpreted, why are there . pyc files that are compiled bytecodes?
-
7
votes2
answers4736
viewsHow to print text in the same line in Python
list = open("list.txt", "w") list = list.readlines() for i in list: print i I would like to Print the value of i in the same line, without going down. Type replacing the current word.…
pythonasked 7 years, 8 months ago Jonatan Santos 103