📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    What is the output of the following part of python

    program? x = ("apple", "banana", "cherry") print(x) 
    A ('apple', 'banana', 'cherry') Correct Answer Incorrect Answer
    B Cherry Correct Answer Incorrect Answer
    C Apple Correct Answer Incorrect Answer
    D Error Correct Answer Incorrect Answer

    Solution

    Correct answer:   1. ('apple', 'banana', 'cherry') Why this is correct: x  is a tuple of three strings.  print(x)  prints the Python representation of the tuple:  ('apple', 'banana', 'cherry') . Why the others are wrong: 2 & 3.  print(x)  prints the whole tuple, not a single element — to print  "cherry"  you'd need  print(x[2]) . 4. The code is valid Python and does not produce an error.

    Practice Next

    Relevant for Exams:

    ask-question