Questions tagged as 'python'

1
answer

How can the search of an element in a set be O (1)?

According to the official Python page for the complexity of algorithms over time, the sequences list and set have the following characteristics: List Set Highlight for the in operator, which checks for...
asked by 11.06.2018 / 14:23
3
answers

Is there a more efficient way to dynamically create an array from another array by filtering the contents of the array first?

I have an array of values that can include several numpy.nan: import numpy as np a = np.array ( [1, 2, np.nan, 4] ) And I want to iterate over your items to create a new array without np.nan. The way I know to create arrays dynamically...
asked by 15.12.2013 / 17:48
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
4
answers

How to implement journaling in Python?

I need to do a series of operations involving binary files (you can not use BD), and I need to ensure that they finish successfully even in the middle of the operation. To do this, I see no way out but to implement a journaling system manuall...
asked by 14.02.2014 / 06:53
1
answer

What is the __future__ module for?

I have seen in some codes written in Python the following statement: from __future__ import print_function What is the purpose of this __future__ module? When do I need to import it into a script I'm doing? Why is it, unlike th...
asked by 03.05.2016 / 05:21
1
answer

What makes Python a multiparadigma programming language?

on this Wikipedia page lists some examples of multiparadigma language like C ++, Groovy , Oz, Ruby, Scala, Swift, Groovy and even Python . I particularly did not find the explanation so objective considering it. What makes Python a multipar...
asked by 23.02.2017 / 18:25
3
answers

What does% = mean?

I have a code that contains the situation below: id %= 1000 But I do not know the function of this operator.     
asked by 19.11.2015 / 13:48
2
answers

How does the "for" inline command work?

I did a question regarding a Python algorithm, but in resolution of the user Anderson Carlos Woss he used a type of% inline that I had never seen and that left me confused. Here is the code snippet corresponding to for : groups...
asked by 27.09.2017 / 13:54
2
answers

What is the main difference between a Tuple and a List?

What are the differences between Tuple and List in Python ? Example: >a = [1, 2, 3] # [1, 2, 3] >b = (1, 2, 3) # (1, 2, 3) The Tuple , grotesquely speaking, is a constant that accepts List ?     
asked by 03.03.2015 / 16:12