Test Bank For Intro To Python For Computer Science and Data Science 1st Edition by Deitel
Test Bank For Intro To Python For Computer Science and Data Science 1st Edition by Deitel
Test Bank
CLICK HERE TO ACCESS THE COMPLETE Test Bank
Answer: c. Python is case insensitive, so number and Number are the same
identifier despite the fact that one begins with a lowercase letter and the
other begins with an uppercase letter. Actually, Python is case sensitive, so
number and Number are different identifiers because one begins with a low-
ercase letter and the other begins with an uppercase letter.
2.2 Q4: The value 10.5 is a(n) (that is, a number with a decimal point).
a. integer
b. string
c. floating-point number
d. None of the above
Answer: c. floating-point number.
2.3 Arithmetic
2.3 Q1: Which of the following statements a), b) or c) is false?
a. Python uses the asterisk (*) as the multiplication operator (e.g., 7 * 4).
b. The exponentiation (**) operator raises one value to the power of another (e.g.,
2 ** 10).
c. To square a number, you can use the exponent 1/2 (that is, 0.5), as in:
9 ** (1 / 2)
d. All of the above statements are true.
Answer: c. To square a number, you can use the exponent 1/2 (that is, 0.5).
Actually, to square a number, use the exponent 2. The exponent 1/2 takes
the square root of the number.
2.3 Q8: Which of the following statements about arithmetic operators is false?
a. Each arithmetic operator may be used with integers and floating-point num-
bers.
© Copyright 1992−2020 by Pearson Education, Inc. All Rights Reserved.
CLICK HERE TO ACCESS THE COMPLETE Test Bank
b. If both operands are integers, the result is an integer—except for the true-divi-
sion (/) operator, which always yields a floating-point number.
c. If both operands are floating-point numbers, the result is a floating-point num-
ber.
d. Expressions containing an integer and a floating-point number are mixed-type
expressions—these always produce an integer.
Answer: d. Expressions containing an integer and a floating-point number
are mixed-type expressions—these always produce an integer.
Actually, these mixed-type expressions always produce a floating-point
number.
2.6 Q2: What does the int function attempt to do in the following code?
value = input('Enter an integer: ')
value = int(value)
a. Convert an integer to a string.
b. Convert a string to an integer.
c. Convert a non-object to an object.
d. None of the above.
Answer: b. Convert a string to an integer.
Answer: c. Python ignores all white space. Actually, Python ignores most
white space—some indentation (which is created with whitespace charac-
ters) is required. [Also, white space in strings is significant.]
2.7 Q5: You may spread a lengthy statement over several lines with the ________
continuation character.
a. @
b. \
c. %
d. ^
Answer: b. \
2.7 Q8: The chained comparison 3 < y <= 11 is false for which of the following
values of y:
a. 11
b. 10
c. 4
d. 3
Answer: d. 3
2.8 Q3: Which of the following Python concepts are demonstrated directly or in-
directly by the following code:
In [1]: type(x)
Out[1]: int
In [2]: x = 4.1
In [3]: type(x)
Out[3]: float
In [4]: x = 'dog'
In [5]: type(x)
Out[5]: str
a. Python uses dynamic typing—it determines the type of the object a variable
refers to while executing your code.
b. Over its lifetime a variable can be bound to different variables, even variables
of different types.
c. Python creates objects in memory and removes them from memory as neces-
sary. This removal process—called garbage collection—helps ensure that
memory is available for new objects you create.
d. All of the above.
Answer: d. All of the above.