03-001 Thinking Like A Programmer - Pseudo Code I
03-001 Thinking Like A Programmer - Pseudo Code I
The bootcamp you are starting today is structured as a series of ‘Tasks’. Tasks
include a lesson component designed to teach you the theory needed to develop
your skills, as well as a Compulsory Task component designed to give you the
platform to apply your newly-gained knowledge by completing practical exercises.
This task serves as an introduction to pseudo code and how it can be used to ease
you into the world of programming.
If you’re taking this course, you’re brand new to the Python programming language. You
may even be new to programming altogether. Either way, you’ve come to the right place!
The key to becoming a competent programmer is utilising all available resources to their
full potential. Occasionally, you may stumble upon a piece of code that you cannot wrap
your head around, so knowing which platforms to go to for help is essential.
HyperionDev knows what you need, but there are also other avenues you can explore for
help. One of the most frequently used by programmers worldwide is Stack Overflow; it
would be a good idea to bookmark this for future use.
Also, our blog is a great place to find detailed articles and tutorials on concepts into
which you may want to dig deeper. For instance, when you get more comfortable with
programming, if you want to read up about machine learning, or learn how to deploy
a machine learning model with Flask, you can find all this information and more on
our blog.
The blog is updated frequently, so be sure to check back from time to time for new
articles or subscribe to updates through our Facebook page.
INTRODUCTION TO PSEUDO CODE
What is pseudo code? And why do you need to know this? Well, being a
programmer means that you will often have to visualise a problem and know how
to implement the steps to solve a particular conundrum. This process is known as
writing pseudo code.
Pseudo code is not actual code; instead, it is a detailed yet informal description of
what a computer program or algorithm must do. It is intended for human reading
rather than machine reading. Therefore, it is easier for people to understand than
conventional programming language code. Pseudo code does not need to obey
any specific syntax rules, unlike conventional programming languages. Hence it
can be understood by any programmer, irrespective of the programming
languages they’re familiar with.
WHAT IS AN ALGORITHM?
For example, to find the product of n and 9 (when n is less than 10), you can write n
− 1 as the first digit and 10 − n as the second digit (e.g. 7 x 9 = 63). This trick is a
general solution for multiplying any single-digit number by 9. That’s an algorithm!
Similarly, the techniques you learned for addition with carrying, subtraction with
borrowing, and long division are all algorithms.
One of the characteristics of algorithms is that they do not require any intelligence
to execute. Once you have an algorithm, it’s a mechanical process in which each
step follows from the last according to a simple set of rules (like a recipe). However,
breaking down a hard problem into precise, logical algorithmic processes to reach
the desired solution is what requires intelligence or computational thinking.
Did you know that Ada Lovelace (who was an English mathematician and writer born in
1815) is regarded as the first computer programmer? Her notes on an early mechanical,
general-purpose computer (the Analytical Engine) is recognised as the first algorithm
(pseudocode) to be carried out by a machine.
Also, did you know the word ‘algorithm’ comes from the mediaeval Latin word ‘algorism’
and the Greek word ‘arithmos’ (ἀριθμός)? The word 'algorism' (and therefore, the derived
word 'algorithm') comes from Al-Khwārizmī (Persian: خوارزمی, c.780–850), a Persian
mathematician, astronomer, geographer and scholar. The English language adopted the
French term, but it wasn't until the late 19th century that ‘algorithm’ took on the
meaning that it has in modern English.
In English, it was first used in about 1230 and then by Chaucer in 1391. Another early use
of the word is from 1240 in a manual titled Carmen de Algorismo composed by
Alexandre de Villedieu.
It begins thus:
Haec algorismus ars praesens dicitur, in qua /
Talibus Indorum fruimur bis quinque figuris.
which translates as:
Algorism is the art by which at present we use
those Indian figures, which number two times
five.
The poem summarises the art of calculating with
the new style of Indian dice, or Talibus Indorum,
or Hindu numerals or al-adad al-Hindi.
Ada Lovelace
PSEUDO CODE SYNTAX
Pseudo code is easy to write and understand, even if you have no programming
experience. You simply need to write down a logical breakdown of what you want
your program to do. Therefore, it is a good tool to use to discuss, analyse, and agree
on a program's design with a team of programmers, users, and clients before
coding the solution.
Example 1
Pseudo code
get grade
print "passed"
else
print "failed"
Example 2
An algorithm that asks a user to enter their name and prints out "Hello, World" if
their name is "John".
Pseudo code
An algorithm that requests an integer from the user and prints "fizz" if the
number is even or "buzz" if it is odd.
Pseudo code
print "fizz"
print "buzz"
Example 4
An algorithm that calculates the grade average by inputting and adding up the
grades of each of the 10 students, and then prints out the class average.
Pseudo code
Calculate the class average by dividing the total grade sum by ten
Symbol Use
● Use a plain text editor like Notepad++. Create a new text file called
pseudo.txt inside the folder for this task in Dropbox.
● Inside pseudo.txt, write pseudo code for each of the following scenarios:
○ An algorithm that reads a grocery list and prints out the products
(in alphabetical order) that are still left to buy.
○ An algorithm that asks the user to enter four numbers, sorts those
numbers from smallest to largest and then prints the sorted
numbers.
1. Make sure that you have installed and set up all programs correctly. You have set
up Dropbox correctly if you are reading this.
Hyperion strives to provide internationally-excellent course content that helps you achieve
your learning outcomes.
Think that the content of this task, or this course as a whole, can be improved, or think
we’ve done a good job?