Questions tagged as 'python'

1
answer

Calculate the execution time of a program

How do I add a timer at the beginning of the program and during the execution can I read the time elapsed from the start of the program in seconds?     
asked by 02.08.2018 / 20:16
2
answers

Python: conditions for various symbols

I have a doubt, I remember already having seen the resolution somewhere, but I'm not finding it anymore. So the problem has several symbols for example simbolos = ('!','?',',','\'') here it is like tuple which is how i imagined that emplo...
asked by 29.05.2018 / 02:31
2
answers

Limiting the number of characters in a string in Python

I have a Python script that is generating string with many characters and I need each string to create a folder with its name. But do not stick to the problem, because what I really want to know is how to limit that string to a desired size and...
asked by 30.05.2018 / 23:14
2
answers

Dictionary for objects in Python

I would like to know how I can assign a dictionary to a set of objects. For example, I have a 4x4 vector of 'neuron' objects: [[<__main__.Neuronio object at 0x1035644e0>, <__main__.Neuronio object at 0x103564518>, <__main_...
asked by 01.06.2018 / 23:18
2
answers

Timeout in the Python input function

teste=input('Olá qual o seu nome?') How do I do if the user takes more than a certain time interval to take some action. Eg: write on the screen 'You took too long'.     
asked by 10.05.2018 / 02:01
1
answer

How do I intersect each position in my list?

I have tried the following ways based on the answers obtained here in the forum. First form: A = [[1,2,3,4,5,6,7,8,9,10],[1,3,5,7,8,9,10,20],[4,5,7,13,16,20,21,30]] B = [1,2,3,4,5,6,7,8,9] C = [10,11,12,13,14,15,16,17,18,19] D = [20,21,22,2...
asked by 18.08.2018 / 08:47
2
answers

Replace numbers that are within a word

I want to remove numbers in the middle of letters, but I do not want to remove all numbers from the text, for example: Vini12cius I want to transform to Vinicius , but without changing a possible CPF that will come after, I created th...
asked by 31.08.2018 / 20:49
2
answers

How to concatenate items from a list in python?

Let's say I have the result of a list: ['_', '_', '_', '_', '_', '_', '_'] How can I turn it into this?: ['_ _ _ _ _ _ _'] Or even in a variable with the value above     
asked by 26.08.2018 / 00:08
2
answers

Check the size of each file in a folder in Python with 'os'

I'm having a hard time figuring out the size of each file (in KB) in a certain folder. I initially listed all the files with 'os.listdir' and I believe it has something to do with 'os.stat' to find out the size of each file listed. import os l...
asked by 21.08.2018 / 07:19
3
answers

How not to return a None value in python

I have the following sample code lista = [100,200,1000,3000,2,3,4,5,6,7,8] def regras(x): if x < 100: if x % 2 == 0: return x if x >= 100: return (x+x) v1 = list(map(regras,lista)) print(v1) that...
asked by 11.08.2018 / 19:19