CBSE Class 11 Python List

# CBSE Class 11: Python List 9

Example : Give the output

n1=[1,2,3,4,5]
n2=[6,7,8,9,10]
print(n1)
print(n2)
n1=n1+[100,200,300]
print(n1)
n2=n1+n2
print(n2)
n2=n2+[23,45,56]+n1
print(n2)

output:
[1, 2, 3, 4, 5]
[6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 100, 200, 300]
[1, 2, 3, 4, 5, 100, 200, 300, 6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 100, 200, 300, 6, 7, 8, 9, 10, 23, 45, 56, 1, 2, 3, 4, 5, 100, 200, 300]

```n1=[1,2,3,4,5]
n2=[6,7,8,9,10]
print(n1)
print(n2)
n1=n1+[100,200,300]
print(n1)
n2=n1+n2
print(n2)
n2=n2+[23,45,56]+n1
print(n2)```

Output:

[1, 2, 3, 4, 5]
[6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 100, 200, 300]
[1, 2, 3, 4, 5, 100, 200, 300, 6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 100, 200, 300, 6, 7, 8, 9, 10, 23, 45, 56, 1, 2, 3, 4, 5, 100, 200, 300]

Example : Give the output

n=[0,1,2,3,4,5,6,7,8,9,10]

n.remove(1)

print(n)

n.remove(9)

n.remove(5)

n.remove(4)

print(n)

#### [0, 2, 3, 6, 7, 8, 10]

```n=[0,1,2,3,4,5,6,7,8,9,10]
n.remove(1)
print(n)
n.remove(9)
n.remove(5)
n.remove(4)
print(n)```

Output:

[0, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[0, 2, 3, 6, 7, 8, 10]

Example : Give the output:

n=[0,1,2,3,4,5,6,7,8,9,10]

del n[1]

del n[1]

print(n)

del n[4]

del n[3]

print(n)

del n[6]

del n[2]

print(n)

#### [0, 3, 7, 8, 9]

```n=[0,1,2,3,4,5,6,7,8,9,10]
del n[1]
del n[1]
print(n)
del n[4]
del n[3]
print(n)
del n[6]
del n[2]
print(n)
```

Output:

[0, 3, 4, 5, 6, 7, 8, 9, 10]
[0, 3, 4, 7, 8, 9, 10]
[0, 3, 7, 8, 9]

Example : Give the output

n=[0,1,2,3,4,5,6,7,8,9,10]

del n[1]

del n[1]

print(n)

n=n+[10,20,30]

del n[7]

del n[9]

print(n)

n1=[5,6,7,3,4]

n=n+n1

del n[9]

del n[2]

print(n)

#### [0, 3, 5, 6, 7, 8, 10, 10, 5, 6, 7, 3, 4]

```n=[0,1,2,3,4,5,6,7,8,9,10]
del n[1]
del n[1]
print(n)
n=n+[10,20,30]
del n[7]
del n[9]
print(n)
n1=[5,6,7,3,4]
n=n+n1
del n[9]
del n[2]
print(n)
```

Output:

[0, 3, 4, 5, 6, 7, 8, 9, 10]
[0, 3, 4, 5, 6, 7, 8, 10, 10, 30]
[0, 3, 5, 6, 7, 8, 10, 10, 5, 6, 7, 3, 4]

Important Pages