Robotics & Artificial Intelligence
Write a Python program that performs the following operations on a list of integers:
- Create a list of integers: [5, 15, 25, 35, 45].
- Append the integer 55 to the list.
- Insert the integer 20 at index 1.
- Remove the integer 35 from the list.
- Find the index of the integer 25 and print it.
- Print the final list.
Python List Manipulation
3 Likes
Answer
numbers = [5, 15, 25, 35, 45]
numbers.append(55)
numbers.insert(1, 20)
numbers.remove(35)
index_25 = numbers.index(25)
print("Index of 25:", index_25)
print("Final list:", numbers)Output
Index of 25: 3
Final list: [5, 20, 15, 25, 45, 55]
Answered By
1 Like
Related Questions
Write a Python program that creates a tuple with elements from a list. Your program should do the following:
- Create a list with multiple elements.
- Convert the list to a tuple.
- Print the tuple and demonstrate accessing an element of the tuple.
Briefly explain training data and testing data.
How does the decision making by humans differ from that of the machines?
Artificial Intelligence is making lives easier. Give any two reasons.