1-1 The Python IDE
What is Python? Python is a high level programming language. A programming language is a way of giving instructions to a computer. A computer can only do one thing at a time. Because of this we need to write our instruction in a sequence. With each instruction being carried out on a new line. All of these instruction together form an algorithm. Python is an interpreted language. Python can operate in two modes, namely interactive mode and script mode. We typically use the interactive mode to test and debug small amounts of code, and the script mode for running larger projects.
A sequence of instructions A computer can only perform one instruction at a time. Therefore we must write code in a sequence. The order in which we write the instructions is very important.
Algorithm An algorithm is simply a sequence of instructions to solve a specific problem. Have a go…. On your whiteboards write an algorithm that solves the following problem…. + Make a cup of tea
Low level languages When electronic computers where first used all programs has to be written in machine code (low level). To produce code programmers had to write code out using binary instructions. These binary instructions tell the CPU what to do (1000100101) This takes ages and is very prone to errors. Large teams of people had to be both write the algorithm as well as program the computer but changing the states of many switches. Mathematicians where the only people who could write computer code
Colossus (Bletchley park) Manchester Baby Imagine how complex it would be to program this computer using wires and connectors to tell the computer what to do in machine code (1001001010) [insert video] https://www.youtube.com/watch?v=i5P5faf7478 https://www.youtube.com/watch?v=cozcXiSSkwE
High level languages If we had to write all computer programs in machine code (low level) we would not use computers in the same way that we do today. If it where code would only be written by high level mathematicians at research institutions. High level languages where invented to allow us to code using human based language. As computers cannot understand anything but binary translators are used to convert high level languages into low level language that the computer will understand.
Comparison – High to low 10001011010111010110101101001000110 11010010100101010010101001010101010 10101101001101010010100101011010101 10100010000001011111010110010100101
Compilers and Translators [insert video] https://www.youtube.com/watch?v=_C5AHaS1mOA
Translator A translator will convert only one line of code at a time. After it converts each line it sends it straight to the CPU (the “brain” of the computer) – NOTE- the CPU is nothing like a brain and you should refer to it as a brain but it helps make this point - Translators run slow as the interpreter is constantly working between your code and the CPU + Translators generally working on multiply platforms (MAC/Windows/Android/IOS) as the translator will translate for the CPU that is present + Translators let us debug the code as we can watch the code run line by line and see where an error might occur
Stepping Stepping is simply the process where computer code is run line by line. Between each line the program stops and the programmer can study the output. Have a go Write the code below in Python visualizer that will display the following on the screen sName = “Mr Gildroy” iAge = 30 Print(“Your name is – “ + sName) Print(“your age is – “ + iAge)
Compiler A compiler converts all off the high level code into machine code before it is run. The CPU can run the machine (or binary) code directly and does not need any interaction with a translator. + Compiled code is much much quicker - Compiled code is specific to a platform. It generally does not work across different
Debugging Vs Programming To add