Quizzma Latest Questions

What will be the output of the above code?

def citation(names):
author_name = ((names))
name = str(names[2]) + “, ” + str(names[0]) + ” ” + str(names[1])
return name
print(citation([“Martin”, “Luther”, “King, Jr”]))

What will be the output of the above code?

A) King, Jr, Martin Luther
B) Martin, Luther King, Jr
C) King, Jr, Luther Martin
D) Luther, Martin King, Jr




Leave an answer

Leave an answer

What is the capital of Egypt? ( Cairo )

1 Answer

  1. The correct answer is A) King, Jr, Martin Luther.

    ### Explanation:

    In the function `citation`, the input `names` is a list containing `[“Martin”, “Luther”, “King, Jr”]`. The function constructs a string using the elements of this list:

    – `str(names[2])` gives “King, Jr”

    – `str(names[0])` gives “Martin”

    – `str(names[1])` gives “Luther”

    These parts are combined in the format `name = str(names[2]) + “, ” + str(names[0]) + ” ” + str(names[1])`, resulting in the string: “King, Jr, Martin Luther”.

    Thus, the output when calling `print(citation([“Martin”, “Luther”, “King, Jr”]))` will indeed be “King, Jr, Martin Luther”.

Related Questions