Skip to main content

Posts

Showing posts from March, 2012

Break out of more than 2 loops in python

If you want to break out of a loop in Python, just use "break". How about when you need to bread out of more than 2 loops in Python? Here is a hint: Using Raise and Exception. try:    ...    if (condition) : #You want to break your loop here       raise GetOutOfLoop except GetOutOfLoop:    pass

Binomial distribution

A salesman goes to meet 100 customers. Based on his experience, the expectation of selling goods for a customer is 40%. Find the probability that a customer will buy in 45% - 50%.