06.09.2021 Views

How to Think Like a Computer Scientist - Learning with Python, 2008a

How to Think Like a Computer Scientist - Learning with Python, 2008a

How to Think Like a Computer Scientist - Learning with Python, 2008a

SHOW MORE
SHOW LESS

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

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

34 Functions<br />

3. Can you write functions that yield results, or are you stuck <strong>with</strong> simple<br />

function like newLine and printTwice?<br />

The answer <strong>to</strong> the last question is that you can write functions that yield results,<br />

and we’ll do it in Chapter 5.<br />

As an exercise, answer the other two questions by trying them out.<br />

When you have a question about what is legal or illegal in <strong>Python</strong>, a<br />

good way <strong>to</strong> find out is <strong>to</strong> ask the interpreter.<br />

3.13 Glossary<br />

function call: A statement that executes a function. It consists of the name of<br />

the function followed by a list of arguments enclosed in parentheses.<br />

argument: A value provided <strong>to</strong> a function when the function is called.<br />

value is assigned <strong>to</strong> the corresponding parameter in the function.<br />

This<br />

return value: The result of a function. If a function call is used as an expression,<br />

the return value is the value of the expression.<br />

type conversion: An explicit statement that takes a value of one type and computes<br />

a corresponding value of another type.<br />

type coercion: A type conversion that happens au<strong>to</strong>matically according <strong>to</strong><br />

<strong>Python</strong>’s coercion rules.<br />

module: A file that contains a collection of related functions and classes.<br />

dot notation: The syntax for calling a function in another module, specifying<br />

the module name followed by a dot (period) and the function name.<br />

function: A named sequence of statements that performs some useful operation.<br />

Functions may or may not take arguments and may or may not produce a<br />

result.<br />

function definition: A statement that creates a new function, specifying its<br />

name, parameters, and the statements it executes.<br />

flow of execution: The order in which statements are executed during a program<br />

run.<br />

parameter: Anameusedinsideafunction<strong>to</strong>refer<strong>to</strong>thevaluepassedasan<br />

argument.

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

Saved successfully!

Ooh no, something went wrong!