Question-119: When you run below program, what would be printed

listOfNames=['Amit' , 'John' , 'Venkat' , 'Simon' ]

listOfNames.append('Venu')

listOfNames.append('Nikita')

listOfNames.append('Sunil')

listOfNames.append('Richa')

print(listOfNames)

 

  1. ['Amit' , 'John' , 'Venkat' , 'Simon' ]
  2. Get all Questions and Answer from here
  3. You need to have paid subscription to access all questions
  4. Thanks for considering Python Certification Material

 

Abswer: B

Exp:

Appending elements in an existing (entity) list.

  • We are having method called append, which is owned by List.
  • Hence, to call/invoke this method, you can use list(entity) itself.
  • When you call method, it changes the state of the list itself.
  • In below example append() is a method and len() is a function.
  • append method, will always append element at the end of the list.

listOfNames=['Amit' , 'John' , 'Venkat' , 'Simon' ]

print("List Length ", len(listOfNames))

 

#listOfNames=listOfNames+['Venu']

listOfNames.append('Venu')

#listOfNames=listOfNames+['Nikita']

You can access to full explanation to question and answer from this page.

Why Dont you prepare for Python Certifications and Interview Questions with 250+ Questions and Answer : Check Here

Real Exam Number of Questions: 70 Questions
Real Exam Pass Score: 70%
Time Allotted: 90 minutes to complete exam