Robotics & Artificial Intelligence
Write a Python program that performs the following operations on a tuple:
- Create a tuple with the elements: (5, 10, 15, 20, 25).
- Access and print the element at index 2.
- Convert the tuple into a list.
- Append the integer 30 to the list.
- Convert the list back into a tuple.
- Print the final tuple.
Answer
numbers_tuple = (5, 10, 15, 20, 25)
element = numbers_tuple[2]
print("Element at index 2:", element)
numbers_list = list(numbers_tuple)
numbers_list.append(30)
final_tuple = tuple(numbers_list)
print("Final tuple:", final_tuple)Output
Element at index 2: 15
Final tuple: (5, 10, 15, 20, 25, 30)
Related Questions
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?
Describe the process of building a simple wheeled mobile robot and mention the key components involved.
List and briefly describe three different ways of representing data visually.