Terminates the current loop and resumes execution at the next statement, just like the traditional break found in C.
Returns the control to the beginning of the loop
used when a statement is required syntactically but you do not want any command or code to execute
If the else statement is used with a for loop, the else statement is executed when the loop has exhausted iterating the list. If the else statement is used with a while loop, the else statement is executed when the condition becomes false.
Example: searching for prime numbers from 10 to 20
for num in range(10,20): #to iterate between 10 to 20
for i in range(2,num): #to iterate on the factors of the number
if num%i == 0: #to determine the first factor
j=num/i #to calculate the second factor
print '%d equals %d * %d' % (num,i,j)
break #to move to the next number, the #first FOR
else: # else part of the loop
print num, 'is a prime number'
10 equals 2 * 5
11 is a prime number
12 equals 2 * 6
13 is a prime number
14 equals 2 * 7
...
count(10)
--> 10 11 12 13 14 ...cycle('ABCD')
--> A B C D A B C Drepeat(10, 3)
--> 10 10 10 (if no 2nd arg, repeat without stopping)
compress('ABCDEF', [1,0,1,0,1,1])
--> A C E Ftakewhile(lambda x: x<5, [1,4,6,4,1])
--> 1 4dropwhile(lambda x: x<5, [1,4,6,4,1])
--> 6 4 1groupby(iterable, keyfunc)
makes an iterator that returns consecutive keys and groups from the iterable- [Function from default module]
map(pow, (2,3,10), (5,2,3,4))
--> 32 9 1000. Make an iterator that computes the function using arguments from each of the iterables. Stops when the shortest iterable is exhausted starmap(pow, [(2,5), (3,2), (10,3)])
--> 32 9 1000 ('prezipped' args)
product('ABCD', repeat=2)
→ AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DDpermutations('ABCD', 2)
→ AB AC AD BA BC BD CA CB CD DA DB DCcombinations('ABCD', 2)
→ AB AC AD BC BD CD [sorted]combinations_with_replacement('ABCD', 2)
→ AA AB AC AD BB BC BD CC CD DD [sorted]
np.infty
or-np.infty
;np.inf
ornp.NINF
.np.isfinite(5)
→True
;np.isfinite([5, -np.infty])
→array([ True, False], dtype=bool)
- Same as above:
np.isnan
,isinf
,isneginf
`` a = '1' \
+ '2'
``