1D & 2D Arrays, Logic & Iteration.
scores).
Efficient coding (using loops), Easier to sort/search, Easier maintenance.
(a) "Dan"
(b) "Caz"
(c) Error / Out of bounds. Row 2 does not exist.
(a) Updates Price (Col 1) instead of Quantity (Col 2).
(b) stock[0, 2] = stock[0, 2] - 1
Total: 5
(1 -> -1, 2 -> -1 total -2. 3 -> +3 total 1. 4 -> +4 total 5).
(a) Stored as Integers (Integers don't have leading zeros).
(b) Store as Strings (Add quotes).
marks 2D array.
id = int(input("Enter ID"))
total = 0
for i = 0 to 2
total = total + marks[id, i]
next i
avg = total / 3
print(avg)
marks array for 100.
found = False
for r = 0 to 3
for c = 0 to 2
if marks[r, c] == 100 then
found = True
print("Found")
endif
next c
next r
if found == False then print("Not Found")