Tuple Repetition :-
Python में Tuple Repetition का अर्थ है किसी Tuple के elements को एक से अधिक बार दोहराना (repeat करना)। Tuple Repetition के लिए * multiplication operator का उपयोग किया जाता है।
English
Tuple Repetition means repeating the elements of a tuple multiple times. The * multiplication operator is used for tuple repetition.
Syntax:-
result = tuple * number
यहाँ number बताता है कि Tuple को कितनी बार repeat करना है।
Example:-
numbers = (10, 20, 30)
result = numbers * 3
print(result)
Output:-
(10, 20, 30, 10, 20, 30, 10, 20, 30)
Because:-
यहाँ:
numbers → (10, 20, 30)
numbers * 3 का अर्थ है Tuple को 3 बार repeat करना।
इसलिए:
(10, 20, 30) + (10, 20, 30) + (10, 20, 30)
→ (10, 20, 30, 10, 20, 30, 10, 20, 30)
English
Here, numbers * 3 repeats the entire tuple three times.
Example with String Tuple :-
colors = ("Red", "Blue")
print(colors * 3)
Output:-
('Red', 'Blue', 'Red', 'Blue', 'Red', 'Blue')
यहाँ ("Red", "Blue") को तीन बार repeat किया गया है।
Repetition with Zero :-
यदि Tuple को 0 से multiply किया जाए, तो Empty Tuple प्राप्त होता है।
numbers = (10, 20, 30)
print(numbers * 0)
Output:-
()
English
Multiplying a tuple by 0 returns an empty tuple.
Repetition with One :-
यदि Tuple को 1 से multiply किया जाए, तो Tuple केवल एक बार ही रहता है।
numbers = (10, 20, 30)
print(numbers * 1)
Output:-
(10, 20, 30)
Tuple Repetition with Negative Number :-
यदि Tuple को negative number से multiply किया जाए, तो भी Empty Tuple प्राप्त होता है।
numbers = (10, 20, 30)
print(numbers * -2)
Output:-
()
Important Point :-
Tuple Repetition में:
* operator → Tuple के elements को specified number of times repeat करता है।
Example:-
(1, 2) * 4
Output:-
(1, 2, 1, 2, 1, 2, 1, 2)
Tuple Immutable होने के कारण repetition original Tuple को modify नहीं करता, बल्कि एक नया Tuple return करता है।
In Short :-
Tuple Repetition → * operator की सहायता से Tuple को multiple times repeat करना।
* 3 → Tuple को 3 बार repeat करता है।
* 0 → Empty Tuple () देता है।
Negative number → Empty Tuple () देता है।