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)
- ['Venu', 'Nikita', 'Sunil', 'Richa', 'Amit', 'XXXX', 'YYYY', 'John', 'Venkat', 'Simon']
- Get all Questions and Answer from here
- You need to have paid subscription to access all questions
- 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. |