Problem

6/7

Concatenation and multiplication of tuples

Theory Click to read/hide

Tuple concatenation

It is possible to concatenate tuples to create a new object (concatenation, similar to strings).
1
2
3
4
x = (1,2,3,4) y = (5,6,7,8) z = x + y  print(z)  # (1, 2, 3, 4, 5, 6, 7, 8)

During the multiplication operation, the tuple is repeated several times (similar to string multiplication).
1
2
3
x = (1,2,3,4) z = x*2 print(z)  # (1, 2, 3, 4, 1, 2, 3, 4)



Removing a tuple

Tuple operations and methods are similar to list operations and methods. Except for those that change the elements of a tuple.
An element contained in a tuple cannot be added or removed due to immutability. However, the tuple itself can be deleted using the del operator.
1
2
student = (2007, 'Ivan', 'Ivanov', '9-A', False) del student

Problem

Given 2 tuples. my_tuple_1 and my_tuple_2 (you don't have to create them, but you can use them).

Enter from the keyboard two numbers n and k - integers (from 1 to 10), each number is given on a separate line.
Create a third tuple my_tuple_3 by adding the two tuples above, with the first tuple repeated n times, the second k times.
The conclusion is already written for you.