Robotics & Artificial Intelligence
Write a Python program that performs the following operations on a list of integers:
- Create a list of integers: [10, 20, 30, 40, 50].
- Append the integer 60 to the list.
- Insert the integer 25 at index 2.
- Sort the list in ascending order.
- Search for the integer 30 in the list and print its index.
- Print the final list.
Python List Manipulation
2 Likes
Answer
numbers = [10, 20, 30, 40, 50]
numbers.append(60)
numbers.insert(2, 25)
numbers.sort()
index_30 = numbers.index(30)
print("Index of 30:", index_30)
print("Final list:", numbers)Output
Index of 30: 3
Final list: [10, 20, 25, 30, 40, 50, 60]
Answered By
3 Likes
Related Questions
Explain the use of Tinkercad in designing robotic components. What are the advantages of visualising motion using Tinkercad?
Explain how the phenomenon of hacking can lead to data theft and what measures can be implemented to prevent it.
Explain the importance of integrating sensors, actuators, and controllers in a robotic system.
Explain the importance of defining the problem statement in an AI project. How does it impact the project's success?