In [1]:
a_l = [0, 1, 2]
b_l = [10, 20, 30]
a_t = (0, 1, 2)
b_t = (10, 20, 30)
a_s = 'abc'
b_s = 'xyz'
In [2]:
print(a_l + b_l)
In [3]:
print(a_t + b_t)
In [4]:
print(a_s + b_s)
In [5]:
# print(a_l + 3)
# TypeError: can only concatenate list (not "int") to list
In [6]:
print(a_l + [3])
In [7]:
# print(a_t + (3))
# TypeError: can only concatenate tuple (not "int") to tuple
In [8]:
print(a_t + (3, ))
In [9]:
a_l += b_l
print(a_l)
In [10]:
a_t += b_t
print(a_t)
In [11]:
a_s += b_s
print(a_s)
In [12]:
print(b_l * 3)
In [13]:
print(3 * b_l)
In [14]:
print(b_t * 3)
In [15]:
print(3 * b_t)
In [16]:
print(b_s * 3)
In [17]:
print(3 * b_s)
In [18]:
# print(b_l * 0.5)
# TypeError: can't multiply sequence by non-int of type 'float'
In [19]:
print(b_l * -1)
In [20]:
b_l *= 3
print(b_l)
In [21]:
b_t *= 3
print(b_t)
In [22]:
b_s *= 3
print(b_s)
In [23]:
a_l = [0, 1, 2]
b_l = [10, 20, 30]
In [24]:
c_l = a_l + b_l * 3
print(c_l)