Question-120: When you run below program, then what would be printed on console

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

listOfNames.insert(0,'Venu')

listOfNames.insert(1, 'Nikita')

listOfNames.insert(2, 'Sunil')

listOfNames.insert(3, 'Richa')

listOfNames.insert(5, 'XXXX')

listOfNames.insert( 'YYYY')

print(listOfNames)

 

  1. ['Venu', 'Nikita', 'Sunil', 'Richa', 'Amit', 'XXXX', 'YYYY', '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

 

Answer: D

Exp:

Inserting data at particular position in existing (entity) list.

  • Insert() method would help you to add data at particular position in the list.
  • If you give index position more than the length of the list. Then it would insert element at the end of the list.

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

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

 

 

listOfNames.insert(0,'Venu')

listOfNames.insert(1, '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