# Matrix & Array

unknown
php
2 months ago
1.3 kB
4
Indexable
Never
```for character in 'Python':
print(character)

for item in ['Egg','Milk','Rice','Oil']:
print(item)

for number in [1,2,3,4,5]:
print(number)

#class work
"""
Take a list  of bills, for example
bills = [10,20,30]
Now, using a for loop, calculate the total bill.
"""

bills = [10,20,30]
total = 0
for bill in bills:
total = total + bill
print(f"Total bill is {total}")

grocery_list[0] = 'Oil'
#replace with egg
print(grocery_list[0:2])

price = [5,10,15,1,3,7]
max = price[0]

for value in price:
if value > max:
max = value
print(max)
#Find the maximum value
price = [5,10, 15,1, 3,7]

matrix = [
[1,2,3],
[4,5,6],
[7,8,9]
]
print (matrix[2][2])
for row in matrix:
for item in row:
print(item)
#nested for loop

number_list = [1,2,5,1,10,14]

number_list.append(20)
number_list.insert(1,7)
number_list.remove(10)
number_list.remove(14)
print(number_list)
print( 21 in number_list)

#Class_Work
#find out and print the unique value only
number_list = [1,2,1,5,6,5,10]

unique = []
for number in number_list:
if number not in unique:
unique.append(number)
print(unique)

```