Quizzma Latest Questions

What will be the output of the code above?

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 code above?
a) King, Jr, Martin Luther
b) Luther Martin King, Jr
c) Martin, Luther King, Jr
d) King, Jr, Luther Martin




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:

    The function `citation(names)` takes a list `names`, where:

    – `names[0]` is “Martin”

    – `names[1]` is “Luther”

    – `names[2]` is “King, Jr”

    Within the function, the `name` variable is constructed as follows:

    – `name = str(names[2]) + “, ” + str(names[0]) + ” ” + str(names[1])`

    – This translates to: `”King, Jr” + “, ” + “Martin” + ” ” + “Luther”` which results in:

    
    

    "King, Jr, Martin Luther"

    Therefore, the `print(citation([“Martin”, “Luther”, “King, Jr”]))` will output `King, Jr, Martin Luther`.

Related Questions