Exam 350-401 All QuestionsBrowse all questions from this exam
Question 757

Refer to the exhibit. What is the result of running this code?

    Correct Answer: B

    The code provided initializes a list 'vlans_list' with values [10, 20, 30] and then calls the function 'add_vlans' with this list. The 'add_vlans' function iterates over each element in the list and adds 100 to it. After the function is executed, the list is modified to [110, 120, 130]. Therefore, the result of running this code is a list of new VLANs is created.

Discussion
DavideDLOption: B

vlans_list is a python list contaning the numbers: 10 , 20 and 30 (as integers) The function "add_vlans" scan the list and 100 to every item. The result should be: [110, 120, 130] So in my opinion the answer should be: [B] - A list of new VLANs is created.

HarwinderSekhonOption: A

Tested vlans_list = [10, 20, 30] def add_vlans(vlans): for i in range(len(vlans)): vlans[i]+=100 add_vlans(vlans_list) print(vlans_list) [110, 120, 130]

MJaneOption: B

tried it online. the thing is that the vars are referenced and not sent by value. def main(): vlans_list = [10, 20, 30] add_vlans(vlans_list) print(vlans_list) def add_vlans(vlans): for i in range(len(vlans)): vlans[i]+=100 if _name_ == '_main_': main()

JackDRipperOption: B

def main(): vlans_list = [10,20,30] add_vlans(vlans_list) print(vlans_list) def add_vlans(vlans): for i in range(len(vlans)): vlans[i]+=100 if __name__=='__main__': main() ===============OUTPUT=============== [110, 120, 130]

SeMo0o0oOption: B

B is correct

SeMo0o0oOption: B

i trust the comments, going with B

HungarianDishOption: C

Run in Visual Studio. In this for it always throws an error. "NameError: name '_name_' is not defined" Could someone double check this please?

MJane

you are missing an _. there should be 2x_