Computer Science, asked by Anonymous, 8 months ago

write a program to demonstrate tuple in python!!

.
.
don't copy paste.....✌️​

Answers

Answered by Anonymous
16

Answer:

Ok...Just wait..

what is vaishnavi saying?

Explanation:

# Python program to demonstrate

# Addition of elements in a Set

# Creating an empty tuple

Tuple1 = ()

print("Initial empty Tuple: ")

print (Tuple1)

# Creating a Tuple with

# the use of Strings

Tuple1 = ('Geeks', 'For')

print("\nTuple with the use of String: ")

print(Tuple1)

# Creating a Tuple with

# the use of list

list1 = [1, 2, 4, 5, 6]

print("\nTuple using List: ")

print(tuple(list1))

# Creating a Tuple

# with the use of loop

Tuple1 = ('Geeks')

n = 5

print("\nTuple with a loop")

for i in range(int(n)):

Tuple1 = (Tuple1,)

print(Tuple1)

# Creating a Tuple with the

# use of built-in function

Tuple1 = tuple('Geeks')

print("\nTuple with the use of function: ")

print(Tuple1)

# Creating a Tuple with

# Mixed Datatypes

Tuple1 = (5, 'Welcome', 7, 'Geeks')

print("\nTuple with Mixed Datatypes: ")

print(Tuple1)

# Creating a Tuple

# with nested tuples

Tuple1 = (0, 1, 2, 3)

Tuple2 = ('python', 'geek')

Tuple3 = (Tuple1, Tuple2)

print("\nTuple with nested tuples: ")

print(Tuple3)

# Creating a Tuple

# with repetition

Tuple1 = ('Geeks',) * 3

print("\nTuple with repetition: ")

print(Tuple1)

Output:

Initial empty Tuple:

()

Tuple with the use of String:

('Geeks', 'For')

Tuple using List:

(1, 2, 4, 5, 6)

Tuple with a loop

('Geeks',)

(('Geeks',),)

((('Geeks',),),)

(((('Geeks',),),),)

((((('Geeks',),),),),)

Tuple with the use of function:

('G', 'e', 'e', 'k', 's')

Tuple with Mixed Datatypes:

(5, 'Welcome', 7, 'Geeks')

Tuple with nested tuples:

((0, 1, 2, 3), ('python', 'geek'))

Tuple with repetition:

('Geeks', 'Geeks', 'Geeks')

Answered by manmohantiwari61
0

Answer:

hiiii thnx for following me .Here is your answer.

see the pics.

Attachments:
Similar questions