Robotics & Artificial Intelligence
Write a Python program to display all the elements of a tuple using the for loop.
Python Tuples
1 Like
Answer
my_tuple = (23, 45, 67, 89, 12)
for i in my_tuple:
print(i)Output
23
45
67
89
12
Answered By
2 Likes
Related Questions
Fill in the blanks:
- Python offers a wide range of data structures often referred to as ……………. .
- In an ……………. list, the square brackets [] do not hold any value.
- The ……………. function in Python can be used when we want to know the number of elements stored in a list.
- A tuple is an ……………. sequence of items having any number of elements of different data types.
- Sorting is the process of ……………. and displaying the elements of a list in ascending or descending order.
Write a Python program to demonstrate the difference between lists and tuples.
Write a Python program to create a list of first ten natural numbers. Add the square of each element to another empty list.
Write a Python program to convert a tuple into a list and a list into a tuple.