Professional Documents
Culture Documents
Week 5 Lecture Slides
Week 5 Lecture Slides
Week 5 Lecture Slides
Hrishav Tandukar
hrishav.tandukar@islingtoncollege.edu.np
0 1 2 3 4
-5 -4 -3 -2 -1
indices 0 1 2 3 4
elements 2 43 21 5 46
for i in range(len(L)):
print(L[i]) # print the element at index i
• range(len(L)) -> range(5) -> 0 to 4 which are the indices of the list
max = b
else
max = c
end if
output max
end greatest_of_two
CS4051 Fundamentals of Computing 48
Pseudocode example
algorithm factorial
input n python arithmetic operators
can be used to show arithmetic
fact = 1
operations
while n > 1
fact = fact * n
n = n - 1
end while
output fact
end of while loop must be
end factorial
specified as well