What is the difference (if any) between a * 3 and [a, a, a],is a * 3 equivalent to a + a + a?

Опубликовано: 11 Октябрь 2024
на канале: Portal Express
291
5

Q 4 || Type A || List manipulation || Class 11 || Sumita Arora || Solution ||

Website Link :-
https://www.pathwalla.com/2020/03/if-...

4 = If a is [1, 2, 3]
(a)what is the difference (if any) between a * 3 and [a, a, a]?
(b) is a * 3 equivalent to a + a + a?
(c) what is the meaning of a[1 : 1 ] = 9 ?
(d) what's the difference between a[1:2] 4 and a[1:1]

Answer =

a =
a * 3 means that it have 3 time of value a in one list, while [a, a, a] is form nested list.

b =
Yes

c =
a[1:1] = 9
first of all it give error it mean that we are trying to assign a non sequence value to the list slice, such as number.

d =
a[1:2 ] = 4 it means that value 4 put at index number 1, but in a [1:1 ] = 4 it means that there is no index number where that value can be put in the list, but both will give error because they are non sequnce value.

list manipulation class 11 notes
list manipulation in python class 11 notes
list manipulation in python class 11
list manipulation in python class 11 solutions