04.08.2014 Views

o_18ufhmfmq19t513t3lgmn5l1qa8a.pdf

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

108 CHAPTER 5 ■ CONDITIONALS, LOOPS, AND SOME OTHER STATEMENTS<br />

New Functions in This Chapter<br />

Function<br />

chr(n)<br />

eval(source[, globals[, locals]])<br />

enumerate(seq)<br />

ord(c)<br />

range([start,] stop[, step])<br />

reversed(seq)<br />

sorted(seq[, cmp][, key][, reverse])<br />

xrange([start,] stop[, step])<br />

zip(seq1, seq2,...)<br />

Description<br />

Returns a one-character string with ordinal n<br />

(0 ≤ n < 256)<br />

Evaluates a string as an expression and returns<br />

the value<br />

Yields (index, value) pairs suitable for iteration<br />

Returns the integer ordinal value of a onecharacter<br />

string<br />

Creates a list of integers<br />

Yields the values of seq in reverse order, suitable<br />

for iteration<br />

Returns a list with the values of seq in sorted order<br />

Creates an xrange object, used for iteration<br />

Creates a new sequence suitable for parallel<br />

iteration<br />

What Now?<br />

Now you’ve cleared the basics. You can implement any algorithm you can dream up; you can<br />

read in parameters and print out the results. In the next couple of chapters, you learn about<br />

something that will help you write larger programs without losing the big picture. That something<br />

is called abstraction.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!