Pages

Subscribe:

Friday, June 18, 2010

What is Pseudocode?

A few things about pseudocode.




What is It?
Pseudocode is just the simplification of a programming codes into English sentences where humans can understand without any knowledge of the programming language itself.





What is the Use?
Due to simplicity and how it could give a more general understanding of the program, programmers use pseudocode to do a draft or layout of their algorithms and lengthy logical functions before writing it in the programming language desired. As it is basically a draft, there is no specific format of writing pseudocodes and is completely up to the programmer on how he/she wants to write the pseudocode.





Example
Let's say that we would like something to happen based on a condition. Therefore, we will be using IF-ELSE statements (If the condition is true, do this... else, do that).

For this example, let's say we want to check if a girl named Nico is married or not. So if she is married (TRUE) then we show a message that says "I am married." or else (FALSE) we'll show a message that says "I'm single!"



So a simple draft is done using pseudocode:

If NicoIsMarried Equals To True
Then
Show Message "I am married."
Else
Show Message "I am single!"




But if we want to write this in Python, it would be as such:

if NicoIsMarried == True:
print("I am married.")
else:
print("I am single!")

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

Blog Archive