Challenge 8 – Number Validation

Challenge 8 – Number Validation

Complete the programming challenge below and submit your answer below as a document or PDF with a copy of your code (if you are coding on Repl, add your code link to your document)

Challenge Instructions

Find the syntax error in the code below, then try adapting the Python code below so that the user is asked to re-enter the number until it is an integer. (don’t forget to “fork” the code into your own Repl account)

High & Low Level Languages

High & Low Level Languages

High Level Languages

High level programming languages are the ones that most of us recognise and is what we have used in topics 7 & 8 of the course. The syntax (words & grammar) of high level languages are closer to natural language, or the language that we speak as humans.

Once this is translated to something the computer understands (binary), it is called Machine Language.

Pseudocode Python - GCSE Computer Science

Programming languages such as Python, C#, JavaScript, and Visual Basic are considered to be High Level because the programming statements need to be translated from a structure that we understand as humans to something that the computer will understand.

Often, when we are programming we will read our statements as if they are pseudocode, or even structured English. For example, if I was reading the following Python code, I may read it in my head as “If x does not equal 3 then, add 1 to x”:

IF x != 3:

    x += 1

END IF

Even in Python, which looks quite different from our natural language, the code is not simple enough for a computer to understand. Instead, when we run our code it is translated down into machine code. Code which is close to machine code such as Assembley language is known as a Low Level Language.

To translate the code, the programmer can chose to use a variety of types of translator and we will look at these in more detail in our next lesson.

Low Level Languages

Assembly language is a form of low level language where shortened words called mnemonics are used for each instruction. Because assembly language is low level it is closer to machine language, (that is the binary bit patterns but a computer uses).

programmer

To humans, assembly language can appear complex and difficult because every statement relates to a single instruction in the processor. This means that if the same code was written in a high level language one statement may need to be decomposed into many low level statements. Ultimately, the programs are doing the same thing, but one is more logical for a computer whereas is the other is more logical for a human.

smartwatch

Whilst it might seem obvious to just program using a high level language, often embedded systems are written using assembly language as this allows the program to be smaller in terms of memory, and because embedded systems are rarely updated (if at all) then issues around changing the program aren’t there.

When writing in low level language it’s important to remember that the opcodes (the binary version of the instructions) are specific to the processor being written for. This is not the case in high level languages which are more portable across systems – the reason for this is that they are translated into the low level language that the processor uses as needed.

The simulator below comes from Peter Higginson’s website and is an implementation showing how the LMC instructions can be used to run a low level language.

The Little Man Computer or LMC is not specifically used at GCSE, but you may find it useful to try out some basic programs using the example code on this page:

Alternatively, click here to open the program in a new window.

Revision Activity

Download & print the scribbl.it notes below. Use the information above to create your own notes about high & low level languages.