PCAP 31 03 PCAP Certified Associate Python Programmer · Free Practice Question Easy

Question 2

Q137 - Data Types


What is the expected output of the following code?



  • A

    111*

  • B

    x y z

  • C

    1 1 1

  • D

    The code is erroneous.

  • E

    1*1*1

  • F

    x*y*z

Reveal correct answer

Correct answer: E

Explanation

Topic: multiple assignment print() with sep parameter

Try it yourself:

Explanation:

The print() function has a sep parameter which stands for separator.

The default value of the sep parameter is a space character.

You can change it to anything you want.


Q137 (Please refer to this number, if you want to write me about this question.)

A. This choice does not consider the actual values assigned to the variables and the use of the sep parameter. The output will not have the values concatenated, so '111*' is not the correct output.

B. This choice does not account for the actual values assigned to the variables x, y, and z. The output will not be the variable names but their assigned values, so 'x y z' is not the correct output.

C. This choice does not consider the use of the sep parameter in the print function. The expected output will not have spaces between the values, so '1 1 1' is not the correct output.

D. The code provided is not erroneous; it correctly assigns the value 1 to variables x, y, and z and prints them with the specified separator. Therefore, the code is not erroneous.

E. The code assigns the value 1 to variables x, y, and z simultaneously. When printing these variables with the separator '*', the output will be '1*1*1'.

F. This choice implies that the multiplication operation will be performed between the variables when printing, which is not the case. The output will be the values of x, y, and z separated by '*', not the result of the multiplication.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need