Converting python to pseudocode
The table below shows how python and pseudocode can be interchanged. There are no hard and last rules with pseudocode which means that you may sometimes see things written differently.
pseudocode |
Python |
if a > 6 then
print "a is bigger than 6"
end if
|
if a > 6:
print "a is bigger than 6"
|
for a = 0 to 10
print a
next
|
for a in range(0, 10):
print a
|
a = 0
while a < 0
print a
a = a + 1
end while
|
a = 0
while a < 0:
print a
a = a + 1
|
|
|
|
print 5/2
# note - python does DIV by default,
#to get decimal you should divide by 2.0
|
|
|
|
# need to use len(x) to in order to do right
a = x[len(x) - 4: len(x)]
|
|
|
x = 0
repeat
print x
x = x + 1
until x >10
|
|
function square(a)
square = a * a
end
' note - return sometimes is done by assigning
'to the function name
|
def square(a):
return a * a
|