Question
QUESTION 1 Evaluating the following expression in Python causes an error: (9 * 7) / ((6 + 2) - 8) Which of the following statements
QUESTION 1
-
Evaluating the following expression in Python causes an error:
(9 * 7) / ((6 + 2) - 8)
Which of the following statements best explains the reason for the error?
A run-time error occurs because the result of dividing by zero is undefined (i.e. it has no meaning)
A syntactic error occurs because the parentheses are not nested correctly
A run-time error occurs because Python does not recognise integer division
A semantic error occurs because the parentheses contradict the rules of operator precedence
A semantic error occurs because the result of the expression is not saved
A syntactic error occurs because Python doesn't recognise '(('
1 points
QUESTION 2
-
Assume that the Python variables dog, cat and rabbit have all been assigned integer values. Which of the following would best describe the outcome of the following piece of code?
rabbit = dog cat = rabbit dog = cat
Each variable would store the same value (the initial value of cat).
The values in variables cat and dog would be swapped.
The values in variables rabbit and cat would be swapped.
Each variable would store the same value (the initial value of rabbit).
Each variable would store the same value (the initial value of dog).
The values in variables rabbit and dog would be swapped.
1 points
QUESTION 3
-
Complete the blanks so that the following code prints 'hello world':
message = 'hello' recipient = 'world' print( helloworld'message''recipient'recipientmessage + ' ' + helloworld'message''recipient'recipientmessage)
1 points
QUESTION 4
-
Below are screen shots of two different types of IDLE windows. Your task is to identify in which of the IDLE windows you would find the printed output of an executed Python code file.
1 points
QUESTION 5
-
Which option below best describes the purpose of the following lines of Python code, for any set of possible initial integer values stored in these variables?
first = second second = third third = first
Swaps the values in first and second using third as a temporary variable.
Swaps the values in second and third using first as a temporary variable.
Gives the same value to first, second and third.
Gives first's value to second and third.
Arbitrarily shuffles the values of first, second and third.
The code's purpose is different depending on the initial values of the variables.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started