Class 12 : Review Of Python Basics

#### Class 12 : Python

Python Basics
Data Types
String
List
Tuple
Dictionary
Flow of Execution
Mutable and Immutable Types
Type Casting

#### Class 12 : Python Revision MCQs

Revision Tour MCQs

# Class 12 | Revision Tour 7

### By: Archana Shukla and Rajesh Shukla

Lists Contd…

Loop through list

l1=[10,20,30,40,50]
for i in l1:
print (i)

check if the item is in the list

l1=[10,20,30,40,50]
if 10 in l1:
print(“yes it is in the list”)

### Built-in list functions

List Methods

Joining two lists

We can use + operator to combine two lists. This is also called concatenation

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

Output

list n
[1, 2, 3, 4, 5]
list n1
[6, 7, 8, 9, 10]
n+n1
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
[1, 2, 3, 4, 5, 10, 20, 30]

Nested list

list within a list

```n=["computer",[10,20,30,40]]
print(n[0][0])
print(n[0][1])
print(n[0][2])
print(n[0][3])
print(n[0][4])

print(n[1][0])
print(n[1][1])
print(n[1][2])
print(n[1][3])
```

Output

c
o
m
p
u
10
20
30
40

Important Pages