- list comprehension
- iterators and generators
- decorators
- GIL
- immutables
- old vs. new style classes
- / vs. // division
- unicode vs. str type
- PEP8
- NoSQL databases
- SQL database query optimization
- git branching
- __new__ vs. __init__
- map, filter, reduce
def extendList(val, list=[]):
list.append(val)
return list
def multipliers():
return [lambda x : i * x for i in range(4)]
test = [[]]*5
test[0].append(1)
for i in range(10000):
print "test"
a = ["test"] * 100
result_string = ""
for item in a:
result_string += item + ' '
test = {
0: 'falsy zero',
1: 'truthy one',
False: 'falsy False',
True: 'truthy True'
}
A is a list of integers of length N where for any A[n] where 0<=n<N A[n] < A[n+1]. Write a binary search function to locate an index of given number in A or -1 if number is not existing in list.
For example:
>>> A = [1, 2, 5, 7, 9, 12, 15]
>>> print binary_search(5)
... 2
>>> print binary_search(6)
... -1