Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 1 Evaluating the following expression in Python causes an error: (9 * 7) / ((6 + 2) - 8) Which of the following statements

QUESTION 1

  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

  1. 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

  1. 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

  1. 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.

    image text in transcribed
    image text in transcribed

1 points

QUESTION 5

  1. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

CL I P COL Astro- L(1-cas0) Lsing *A=2 L sin(0/2)

Answered: 1 week ago

Question

LO2 Discuss the constraints faced in a typical recruitment process.

Answered: 1 week ago