3. Computing with Numbers Flashcards

1
Q

True or False

Information that is stored and manipulated by computers is called data.

A

True

The information that is stored and manipulated by computer programs is generically referred to as data (p. 57)

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

True or False

Since floating-point numbers are extremely accurate, they should generally be used instead of ints.

A

False

Another difference between ints and floats is that the float type can only represent approximations to real numbers. Since float values are not exact, while ints always are, your general rule of thumb should be: If you don’t need fractional values, use an int. (p. 59)

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

True or False

Operations like addition and subtraction are defined in the math library.

A

False

Python supports the usual mathematical operations on numbers (p. 59)

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

True or False

The number of possible arrangements of n items is equal to n!.

A

True

The factorial of a whole number n is defined as n! = n(n -1) (n-2) … (1). (p 69)

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

True or False

The sqrt function computes the squirt of a number.

A

False

The sqrt functions computes the square roots of a number.

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

True or False

The float data type is identical to the mathematical concept of a real number.

A

False

It is an approximation.

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

True or False

Computers represent numbers using base-2 (binary) representations.

A

True

Inside the computer, ints are stored in a fixed-sized binary representation (p. 72)

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

True or False

A hardware float can represent a larger range of values than a hardware int.

A

True

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

In order to use functions in the math library, a program must include

a) a comment
b) a loop
c) an operator
d) an import statement

A

d) an import statement

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

The value of 4! is

a) 9
b) 24
c) 41
d) 120

A

b) 24

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

The most appropriate data type for storing the value of pi is

a) int
b) float
c) irrational
d) string

A

b) float

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

The number of distinct values that can be represented using 5 bits is

a) 5
b) 10
c) 32
d) 50

A

c) 32

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

In a mixed-type expression involving ints and floats, Python will convert

a) floats to ints
b) ints to strings
c) both floats and ints to strings
d) ints to floats

A

c) both floats and ints to strings

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

Which of the following is not a Python type-conversion function?

a) float
b) round
c) int
d) abs

A

b) round

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

The pattern used to compute factorials is

a) accumulator
b) input, process, output
c) counted loop
d) plaid

A

a) accumulator

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

In modern Python, an int value that grows larger than the underlying hardware int

a) causes an overflow
b) converts to float
c) breaks the computer
d) uses more memory

A

d