functions chapter 4 Flashcards

1
Q

what is a function?

A

a function is a named sequence of statements that performs a computation. When you define a function, you specify the name and the sequence of statements. Later, you can “call” the function by name.

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

Built In Functions

A

The creators of Python wrote a set of functions to solve common problems and included them in Python for us to use.

The max and min functions give us the largest and smallest values in a list, respectively:

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

Types of Conversions

A

The int function takes any value and converts it to an integer, if it can, or complains otherwise:

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

what are random numbers? or the random module?

A

The random module provides functions that generate pseudorandom numbers (which I will simply call “random” from here on).

The random function is only one of many functions that handle random numbers. The function randint takes the parameters low and high, and returns an integer between low and high (including both).

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

Math functions

A

Python has a math module that provides most of the familiar mathematical functions. Before we can use the module, we have to import it:

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