New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Write your algorithm in pseudocode, make sure it has the makings of an effective algorithm (unambiguous, ordered, computable, produces a result and halts in a finite number of time) then translate into python for example say I have an algorithm for multiplication, I would write:
set value of a to factor1
set value of b to factor2
set value of product to 0
set value of count to 0
while count is less than b:
set product to product + a
add 1 to count
#END LOOP
print the value of product
then in translation:
a = 5
b = 2
product = 0
count = 0
while count < b:
product = product + a
count += 1
print(product)
the beauty of python is the simplicity, it reads a lot like pseudocode