Questions tagged as 'python-3.x'

3
answers

Why static methods can be called through the "instance" class in Python 3?

Let's say I have the following class: class Person: @staticmethod def hello(): print('Hello!) When performing the Person().hello() operation, the method executes normally. But the hello method belongs to the Pe...
asked by 09.10.2017 / 19:08
3
answers

How can I distribute the .py program without having to install all the libraries?

I'm learning Python and need to distribute a program, read about cx_Freeze and py2exe to generate an .exe. However, I do not mind distributing the program code together, so I do not see a need to generate an .exe. How can I distribute the .py...
asked by 13.06.2015 / 02:47
2
answers

What is the function of the semicolon in Python?

I found some codes that had variables inside classes, ending in semicolons. I did not understand why, and also did not find anything on the internet about it. class exemplo(): self.variavel_teste = 0;     
asked by 13.09.2018 / 16:13
1
answer

What are Python 3.8 Assignment Expressions?

Assignment expressions are defined in the PEP 572 that was approved to be implemented in version 3.8 of Python. But what are the assignment expressions and when should they be used? What kind of problem does your implementation seek t...
asked by 25.08.2018 / 00:41
3
answers

Using lower () in a list of lists in Python

If I have a list like this: Lista = [['DE','DO','OU'],['AE','YHH','OO'],['OW','LA','FOR']] And I want to leave it like this: Lista = [['de','do','ou'],['ae','yhh','oo'],['ow','la','for']] How do I? I thought if I did it, I would do it:...
asked by 09.10.2017 / 03:56
3
answers

In Python, what are the consequences of using 'is' instead of '=='

The two forms below return True , but what are the consequences of this in a more complex code? >>> a = '2' >>> a is '2' >>> True >>> a == '2' >>> True     
asked by 24.10.2014 / 23:44
1
answer

Name conventions for variables and functions in Python?

In R , there is a lot of freedom and variety in function names between packages. Names with dot ( get.this ), names with camelCase ( getThis ), names with underline ( get_this ). This has its pros and cons: but the fact i...
asked by 09.03.2014 / 02:54
2
answers

Program to simulate Birthday Paradox

In probability theory, the birthday paradox says that given a group of 23 (or more) randomly chosen people, the chance that two people will have the same birthday is over 50%. For 57 or more people, the probability is greater than 99%, however, i...
asked by 04.04.2018 / 19:15
1
answer

Differences between Python versions 3.x and 2.7

I'm going to start a project in the faculty related to search engines and I want to take the opportunity to also learn Python. I do not know much about language, and my biggest question is which version, between 3.x and 2.7, has better suppor...
asked by 19.02.2016 / 03:08
4
answers

How to extract digits from a string in Python and add them together?

I need to decompose a string into Python, separating letter and numbers, and perform the sum of these numbers. For example: string ="96h11k" From this string I need to extract the numbers 9, 6, 1, 1 and add them: 9 + 6 + 1 + 1 = 17. Act...
asked by 28.11.2014 / 18:19