Questions tagged as 'python'

3
answers

Handling python numbers by adding dot

I'm doing a simple code to convert meters to millimeters, what would be the best way to handle the result. Ex: 1000 in 1,000 Code: valor_m = int(input("Digite um valor em metros: ")) valor_mm = valor_m * 1000 print "Valor em milimetros: %i...
asked by 08.03.2014 / 01:23
1
answer

Python, difference between assert and raise?

I came across a question with the raise and assert structures in python. In the code below shows the implementation of structures forcing an error if the number passed is negative. def is_neg_assert(int): assert (int >=...
asked by 06.05.2016 / 02:55
1
answer

What is the purpose of virtualenv and why not install globally?

I saw that VirtualEnv provides a way to create different environments for application development in Python . And, whenever we use it, you need to install the dependencies of a specific project. For example, I realize that when i...
asked by 04.05.2016 / 22:25
1
answer

Lists of empty lists (Python)

Using Python 2.7.12 I need to create a list as follows: lista = [[],[],[],[],.........,[]] This list must have a very large number of lists within it (so the ........). I found the following way to accomplish this: lista = [[]]*n Wh...
asked by 15.05.2018 / 01:31
2
answers

How to multiply in Python without the multiplication operator?

I have a task and I am having difficulty completing it. What I did was this: m= int(input('Digite o primeiro fator:')) n= int(input('Digite o segundo fator:')) def multiplica(numero): while m > 0: print (n + multiplica (m-1) n)...
asked by 16.05.2018 / 14:59
1
answer

What is the set used for in Python?

What is and what is set in Python? test = set([1, 2, 3]);     
asked by 31.07.2015 / 21:10
2
answers

Open, edit and save a binary file in Python3

You can open a binary file and read its bits in Python3, edit and save a new binary. If so, how?     
asked by 03.01.2017 / 16:38
1
answer

What does __ * (any word) __ or _ * mean in Python?

Reading a book from time to time it puts __init__ or __init and I do not know what those "_" means, I tried to search the internet for some explanations, but I ended up making it harder, could someone help me explaining more practi...
asked by 16.12.2017 / 11:14
1
answer

"[-4:]" What is this syntax?

I have the following expression: namer = name[-4:] Where name gets a name, but what does this [-4:] mean?     
asked by 05.11.2015 / 23:01
2
answers

Convert a list of lists into a single list

I'm working on Python 2.7. I have this result: Resultado=[['A','B','C'],['D','E','F'],['G','H','I']] How can I make this a list? And get the following: Lista=['A','B','C','D','E','F','G','H','I'] Thank you!     
asked by 30.05.2016 / 16:50