3. Computing with Numbers Flashcards
True or False
Information that is stored and manipulated by computers is called data.
True
The information that is stored and manipulated by computer programs is generically referred to as data (p. 57)
True or False
Since floating-point numbers are extremely accurate, they should generally be used instead of ints.
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)
True or False
Operations like addition and subtraction are defined in the math library.
False
Python supports the usual mathematical operations on numbers (p. 59)
True or False
The number of possible arrangements of n items is equal to n!.
True
The factorial of a whole number n is defined as n! = n(n -1) (n-2) … (1). (p 69)
True or False
The sqrt function computes the squirt of a number.
False
The sqrt functions computes the square roots of a number.
True or False
The float data type is identical to the mathematical concept of a real number.
False
It is an approximation.
True or False
Computers represent numbers using base-2 (binary) representations.
True
Inside the computer, ints are stored in a fixed-sized binary representation (p. 72)
True or False
A hardware float can represent a larger range of values than a hardware int.
True
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
d) an import statement
The value of 4! is
a) 9
b) 24
c) 41
d) 120
b) 24
The most appropriate data type for storing the value of pi is
a) int
b) float
c) irrational
d) string
b) float
The number of distinct values that can be represented using 5 bits is
a) 5
b) 10
c) 32
d) 50
c) 32
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
c) both floats and ints to strings
Which of the following is not a Python type-conversion function?
a) float
b) round
c) int
d) abs
b) round
The pattern used to compute factorials is
a) accumulator
b) input, process, output
c) counted loop
d) plaid
a) accumulator