Deck 2: Data and Expressions
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/71
Play
Full screen (f)
Deck 2: Data and Expressions
1
In Python, a comma can be used in numerical literal values greater than 999. That is, one thousand can be represented as either 1,000 or 1000 within a Python program.
False
2
In Python, a positive sign may be placed in front of positive numeric values.
True
3
Floating-point values have both a limited range and a limited precision.
True
4
Since any floating-point representation contains only a finite number of digits, what is stored for many floating-point values is only an approximation of the true value.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
5
Arithmetic overflow can result from the division of two floating-point values.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
6
The format function is only for use with numeric values.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
7
There is no practical limit to the size of an integer in Python.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
8
You cannot rely on the result of floating-point calculations to be mathematically precise.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
9
In Python, string literals may contain quotes as part of its value.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
10
The character encoding of the character '2' in Python is 00000010.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
11
An escape sequence in Python is a sequence of characters beginning with '\n'.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
12
In Python, an empty string may be represented with a pair of matching quotes containing only a single space character.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
13
Program lines may be joined by use of the backslash character.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
14
In Python, the resulting value from a numeric calculation resulting in arithmetic overflow is
A) 0.0
B) inf
C) 9999999999999999
D) -1
A) 0.0
B) inf
C) 9999999999999999
D) -1
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
15
In Python, the resulting value from a numeric calculation resulting in arithmetic underflow is
A) 0.0
B) inf
C) 9999999999999999
D) -1
A) 0.0
B) inf
C) 9999999999999999
D) -1
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
16
In Python, string literals may contain
A) letters
B) digits
C) blanks
D) special Characters
E) all of the above
A) letters
B) digits
C) blanks
D) special Characters
E) all of the above
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
17
In Python, an empty string is denoted by
A) a pair of single quotes containing one blank space
B) a pair of double quotes containing one blank space
C) a pair of matching single or double quotes with no space between them
D) all of the Above
A) a pair of single quotes containing one blank space
B) a pair of double quotes containing one blank space
C) a pair of matching single or double quotes with no space between them
D) all of the Above
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
18
In Python, a string literal can contain
A) single quotes, when the string value is delimited by matching double quotes
B) double quotes, when the string value is delimited by matching single quotes
C) no quotes other than the quotes delimiting the string value
D) both (a) and (b)
A) single quotes, when the string value is delimited by matching double quotes
B) double quotes, when the string value is delimited by matching single quotes
C) no quotes other than the quotes delimiting the string value
D) both (a) and (b)
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
19
The number of characters that can be defined in the Unicode character encoding scheme is
A) over 4 billion characters
B) over 4 million characters
C) about 100,000 characters
D) about 1,000 characters
A) over 4 billion characters
B) over 4 million characters
C) about 100,000 characters
D) about 1,000 characters
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
20
What is displayed by the following?
Print(format( '-', '->8 '), 'Hello ')
A) Hello ---
B) --- Hello
C) -------- Hello
Print(format( '-', '->8 '), 'Hello ')
A) Hello ---
B) --- Hello
C) -------- Hello
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
21
A backslash (\) at the end of a line of a Python program is used to
A) cause the line and the following line to be considered one program line
B) cause Python to indent the following line appropriately
C) allow for an open quoted string to be continued on the next line
A) cause the line and the following line to be considered one program line
B) cause Python to indent the following line appropriately
C) allow for an open quoted string to be continued on the next line
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
22
Indicate what is displayed by the following print statement, for n = 8.096.
Print('n = ', format(n,'.1f'))
A) 8.0
B) 8.09
C) 8.1
D) 8.096
Print('n = ', format(n,'.1f'))
A) 8.0
B) 8.09
C) 8.1
D) 8.096
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
23
Match the respective data types with their value:
-String
A) 12
B) 12.45
C) 'Hello'
-String
A) 12
B) 12.45
C) 'Hello'
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
24
Match the respective data types with their value:
-Integer
A) 13
B) 12.46
C) 'Hello'
-Integer
A) 13
B) 12.46
C) 'Hello'
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
25
Match the respective data types with their value:
-Float
A) 14
B) 12.47
C) 'Hello'
-Float
A) 14
B) 12.47
C) 'Hello'
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
26
The _____ and _____ characters are used in format specifiers in Python to left or right justify a string in a specified field width.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
27
Indicate what is displayed by the following.
tax = .08
print('Your cost: $', format((1 + tax) * 12.99, '.2f''))
tax = .08
print('Your cost: $', format((1 + tax) * 12.99, '.2f''))
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
28
Indicate the purpose of the backslash character (\) in the following.
numsecs_1900_dob 5 ((year_birth 2 1900) * avg_numsecs_year) 1 \
((month_birth 2 1) * avg_numsecs_month) 1 \
(day_birth * numsecs_day)
numsecs_1900_dob 5 ((year_birth 2 1900) * avg_numsecs_year) 1 \
((month_birth 2 1) * avg_numsecs_month) 1 \
(day_birth * numsecs_day)
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
29
A variable in Python is an identifier that is assigned a value.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
30
When assigning a variable a value, the variable name is placed on the right side of the assignment operator.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
31
The following is a valid assignment statement for variable n.
n = n + 1
n = n + 1
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
32
An identifier in Python is a sequence of one or more characters which must begin with a letter or a digit.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
33
Identifiers in Python may not contain blank characters.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
34
The id function produces a unique number identifying a specific value (object) in memory.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
35
All input is returned by the input function as a string type.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
36
Python is case sensitive, so a variable Line is different from a variable named line.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
37
What is value of variable number after the code has been executed?
Number = 10
Number = number + 1
A) 1
B) 11
C) 10
D) number1
Number = 10
Number = number + 1
A) 1
B) 11
C) 10
D) number1
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
38
What value is assigned to variable n by the following input statement
N = int(input('Enter your age: '))
A) a numeric integer value
B) a string value
N = int(input('Enter your age: '))
A) a numeric integer value
B) a string value
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
39
For the following input statement in which the user enters as input 35, what is displayed by the following
Age = input('Enter your age: ')
Print("You are", age//10, "decades old")
A) You are 3 decades old
B) You are 3.5 decades old
C) TypeError: unsupported operand type(s) for //: 'str' and 'int'
Age = input('Enter your age: ')
Print("You are", age//10, "decades old")
A) You are 3 decades old
B) You are 3.5 decades old
C) TypeError: unsupported operand type(s) for //: 'str' and 'int'
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
40
Assume that variables k and num have both been initialized to 10, which of the following is true?
A) id(k), id(num) and id(10) will each give a different result
B) id(k), id(num) and id(10) will all give the same result
C) id(k) and id(num) will be the same because they are variables, but not id(10) because it is an immutable value
D) It depends on the order k and num were initialized
A) id(k), id(num) and id(10) will each give a different result
B) id(k), id(num) and id(10) will all give the same result
C) id(k) and id(num) will be the same because they are variables, but not id(10) because it is an immutable value
D) It depends on the order k and num were initialized
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
41
Which of the following is not a valid variable identifier?
A) 88Keys
B) num_credits
C) HeSaidSheSaid
D) Y2K
A) 88Keys
B) num_credits
C) HeSaidSheSaid
D) Y2K
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
42
An ______________ is a sequence of one or more characters that must not begin with a digit.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
43
An identifier that already has a predefined meaning in Python, and therefore cannot be used as a variable, is known as a _________.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
44
Give a Python statement that assigns variable num to the integer value one thousand, two hundred and twenty-four.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
45
Assuming the integer variable num has already been assigned a value, give a Python statement incrementing num by 5.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
46
An operator is a symbol that represents a particular operation that may be performed on its operands.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
47
The - symbol is used as both a unary and a binary operator in Python.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
48
A keyword is a predefined identifier in Python.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
49
Unary operators are applied to a single operand.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
50
The / symbol is an example of a binary operator.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
51
Truncated division, denoted by //, truncates the result of a division operation as either an integer or floating-point value, based on the types of operands it is applied to.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
52
Which of the following contain the correct arithmetic operators in Python?
A) +, -, *, /, //, **
B) +, -, *, /, div, %
C) +, -, *, /, //, %, **
A) +, -, *, /, //, **
B) +, -, *, /, div, %
C) +, -, *, /, //, %, **
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
53
A numeric literal may be an __________ or _________________ value.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
54
Numeric literals consist of only the digits 0-9, and optional ________ and _____________.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
55
A calculated result too small to be represented is referred to as ______________________.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
56
The built-in _________________ function of Python can be used to control the display of both numeric and string values.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
57
The default character encoding scheme of Python is _________.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
58
Truncating division performed on integer operands is referred to as ___________________.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
59
Give the character endoding of the letter 'D' in Python.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
60
Subexpressions may not contain subexpressions of their own.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
61
The operator precedence of a given programming language does not have to necessarily be the same as in mathematics.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
62
Like most programming languages, Python uses static typing when determining a variable's data type.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
63
Which one of the following is not an expression?
A) 4 + (3 * k)
B) 4
C) 3 * k
D) *
A) 4 + (3 * k)
B) 4
C) 3 * k
D) *
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
64
The expression 4 + 3 is in
A) prefix Notation
B) infix Notation
C) postfix Notation
A) prefix Notation
B) infix Notation
C) postfix Notation
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
65
Based on its rules of operator precedence, Python would evaluate the expression below to
4 + 2 * 5 + 3**2
A) 23
B) 39
C) 29
4 + 2 * 5 + 3**2
A) 23
B) 39
C) 29
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
66
Values can be converted from one data type to another by
A) coercion
B) type conversion
C) type titration
D) both A and B
A) coercion
B) type conversion
C) type titration
D) both A and B
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
67
The following expression is an example of
(float) 2 + 4.5
A) type Coercion
B) type Titration
C) type Conversion
D) type Concentration
(float) 2 + 4.5
A) type Coercion
B) type Titration
C) type Conversion
D) type Concentration
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
68
Python built-in functions _____ and _____ can be used to convert a string type to a numeric type.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
69
Give two expressions in Python, one using the minus symbol (-) as a unary operator, and one using it as a binary operator.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
70
Evaluate the following mathematical expressions as Python would evaluate them.
23
5
24
3
7 // 5
7 / 5
2 ** 3
23

24

7 // 5
7 / 5
2 ** 3
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck
71
Give a Python statement using type conversion to convert the floating value of variable x = 1.24 to an integer value.
Unlock Deck
Unlock for access to all 71 flashcards in this deck.
Unlock Deck
k this deck