2025/2026 Update|Graded A+
When using IPython in interactive mode to evaluate a simple
arithmetic expression in a new session, which of the following is
false?
The text "In [1]:" is a prompt, indicating that IPython is waiting for
your input. You can type ? for help or you can begin entering snippets
After you type an expression like 45 + 72 and press Enter, IPython
reads the snippet, evaluates it and prints its result in Out[1]:.
Then IPython displays the In [2] prompt to show that it's waiting for
you to enter your second snippet
Python uses x for multiplication and the forward slash (/) for division.
- Answer-Python uses x for multiplication and the forward slash (/)
for division.
Which of the following statements is false?
-True division (/) divides a numerator by a denominator and yields a
floating-point number with a decimal point.
Floor division (//) divides a numerator by a denominator, yielding the
highest integer that's not greater than the result. Python truncates
(discards) the fractional part.
-The expression - evaluates to -3.25.
-The expression -13 // 4 evaluates to -3. - Answer-The expression -13
// 4 evaluates to -3.
Which of the following statements is false?
-Python requires you to indent the statements in suites.
-Incorrect indentation of the statements in a suite can cause errors.
-Using the assignment symbol (=) instead of the equality operator
(==) in an if statement's condition is a common logic error.
pg. 1
,-Using == in place of = in an assignment statement can lead to subtle
problems.
- Answer-Using the assignment symbol (=) instead of the equality
operator (==) in an if statement's condition is a common logic error.
Which of statements a), b) or c) is false?
-A variable name, such as x, is an identifier.
-Each identifier may consist of letters, digits and underscores (_) but
may not begin with a digit.
-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.
-All of the above statements are true. - Answer-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.
Which of the following statements is false?
-A string delimited by single quotes may include double-quote
characters:
print('Display "hi" in quotes')
-A string delimited by double quotes may include single quote
characters:
print("Display the name O'Brien")
-A string delimited by double quotes may not include double quotes.
-To avoid using \' and \" inside strings, you can enclose such strings in
triple quotes:
print(""""Display the name O'Brien"""") - Answer-A string delimited
by double quotes may not include double quotes.
Which of the following statements is false?
pg. 2
,-When you evaluate expressions in interactive mode, the text that
print displays is preceded by Out[] with a snippet number in the
square brackets.
-print does not display a string's quotes, though there is a way to
display quotes in strings.
-You also may enclose a string in double quotes ("), as in:
print("Welcome to Python!")
but Python programmers generally prefer single quotes.
-When print completes its task, it positions the screen cursor at the
beginning of the next line. - Answer-When you evaluate expressions
in interactive mode, the text that print displays is preceded by Out[]
with a snippet number in the square brackets.
Which of the following statements about libraries is false?
-Using existing libraries helps you avoid "reinventing the wheel," thus
leveraging your program-development efforts.
-Rather than developing lots of original code—a costly and time-
consuming process—you can simply create an object of a pre-existing
library class, which takes only three Python statements.
-Libraries help you perform significant tasks with modest amounts of
code.
-All of the above statements are false. - Answer-Rather than
developing lots of original code—a costly and time-consuming
process—you can simply create an object of a pre-existing library
class, which takes only three Python statements.
Assume x is 3, y is 7.1 and z is '11.5'. Which of the following
statements is incorrect? - Answer-the value of z is 11.5
Which of the following are reasons why Python is popular and
everyone should consider learning it:
pg. 3
, -It's open source, free and widely available with a massive open-
source community.
-It's easier to learn than languages like C, C++, C# and Java, enabling
novices and professional developers to get up to speed quickly.
-It's easier to read than many other popular programming languages.
-All of the above. - Answer-All of the above.
Which of the following statements is false?
-Python applies the operators in arithmetic expressions according to
the rules of operator precedence, which are generally the same as
those in algebra.
-Parentheses have the highest level of precedence, so expressions in
parentheses evaluate first—thus, parentheses may force the order of
evaluation to occur in any sequence you desire.
-In expressions with nested parentheses, such as (a / (b - c)), the
expression in the innermost parentheses (that is, b - c) evaluates first.
-If an expression contains several exponentiation operations, Python
applies them from left to right. - Answer-If an expression contains
several exponentiation operations, Python applies them from left to
right.
What is the output of the following code for Out[5]:
In [4]: x = 'dog'In [5]: type(x)Out[5]: - Answer-str
Which of the following statements about the IPython session below is
true?
In [1]: gender = 'Female'
In [2]: age = 70
In [3]: if gender == 'Female' and age >= 65:
...: print('Senior female')
...:
pg. 4