Chapter 5, Part 2 Flashcards

1
Q

void function

A

Group of statements within a program for performing a specific task. Does not return a value to the statement that called it. When you need to perform the task, you call the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

value-returning function

A

Similar to void function (group of statements within a program for performing a specific task), but also returns a value. The value is returned to part of the program that called the function when function finishes executing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Standard library

A

Library of pre-written functions that comes with Python. Library functions perform tasks that programmers commonly need. print(), range() and input() are a few examples.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Modules

A

Files that stores functions of the standard library. To call a function stored in a module, you need to write an import statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Random module

A

Includes library functions for working with random numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Dot notation

A

Notation for calling a function that belongs to a module.

ex: module_name.function_name()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

randint function

A

Generates a random integer in the range provided by the arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

randrange function

A

Similar to range function, but returns randomly selected integer from the resulting sequence. You pass the same arguments as you do to the range function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

random function

A

Returns a random float in the range of 0.1 to 1.0. Does not receive arguments.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

uniform function

A

Returns a random float, but allows user to specify range.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Seed value

A

Initializes the formula that generates random numbers. Need to use different seeds in order to get different series of random numbers. By default, system time is used for seed. Can use random.seed() to specify desired seed value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The random numbers created by functions in the random module are actually….

A

….pseudo-random numbers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you write a value-returning function?

A

To write a value-returning function, you write a simple function and add one or more return statements at the end of the function definition.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Name 3 reasons why value-returning functions can be useful in specific situations.

A
  1. You can have the function prompt the user for input and return the user’s input.
  2. Simplify mathematical expressions.
  3. Complex calculations that need to be repeated throughout the program.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

IPO chart

A

Describes the input, processing and output of the function. An IPO chart is a tool for designing and documenting functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Boolean function

A

Returns either True or False. Used to test a condition such as for repetition or decision structures.

17
Q

How do you return multiple values?

A

In Python, a function can return multiple values.

Ex: return expression 1, expression 2, expression 3, etc.

When you call such a function in an assignment statement, you need to have an equal number of variable names on the left side of the assignment operator to receive the returned values.

18
Q

math module

A

part of standard library that contains functions that are useful for performing mathematical calculations.

19
Q

Modularization

A

Grouping related functions in modules. Makes program easier to understand, test, and maintain.

In large, complex programs, it is important to keep code organized.

20
Q

Menu-driven program

A

Displays a list of operations on the screen, allowing the user to select the desired operation.