Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

tuple with mixed data types

#Creating a Tuple
#with Mixed Datatype
Tuple1 = (5, 'Softhunt', 7, 'Tutorials')
print("
Tuple with Mixed Datatypes: ")
print(Tuple1)
 
#Creating a Tuple
#with nested tuples
Tuple1 = (0, 1, 2, 3)
Tuple2 = ('python', 'Softhunt')
Tuple3 = (Tuple1, Tuple2)
print("
Tuple with nested tuples: ")
print(Tuple3)
 
#Creating a Tuple
#with repetition
Tuple1 = ('Softhunt',) * 3
print("
Tuple with repetition: ")
print(Tuple1)
 
#Creating a Tuple
#with the use of loop
Tuple1 = ('Softhunt')
n = 5
print("
Tuple with a loop")
for i in range(int(n)):
    Tuple1 = (Tuple1,)
    print(Tuple1)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #tuple #mixed #data #types
ADD COMMENT
Topic
Name
8+6 =