An Introduction to Python and Computer Programming

 

Computer Programming and Python


Python is called Python because the creator of the language, wanted to have a memorable, simple name and also enjoyed the show Monty Pythons Flying Circus. I thought it was named after the snake and thus my journey into computer programming began with the realisation I knew very little. This humbled me and also make me hungry to learn more.

Luckily I am taking Cisco's Python Essentials course vis FutureSteps and the Open University. Which is quite a collaboration. Let's dive in and explain the key concepts that I have learned on the course so far.

Preamble on Cisco, Certification, and the Edube Sandbox

Why Cisco?

Cisco is an American networking company. One of the world biggest technology companies it is world-beating in its marketplace of network solutions. Like many technology companies, it is always struggling to find great tech talent. With this in mind, it created it NetAcademy to help upskill the global workforce.

It has created a number of courses over the years to help ensure that the skills the industry needs are out there. Over the year these network skills have come to encompass cybersecurity as well as many others.

NetAcad is the platform that Cisco uses to run these courses.NetAcad includes a diverse and large amount of information that is not needed for the course currently studying that covers everything from computer networking to Cybersecurity.

NetAcad also comes with the Edube Sandbox.

Exploring the Edube Sandbox

The course is taught on Edube, which contains all the written information and instruction for practising and learning about Python.

The sandbox allows you to write code in an environment before putting it to use.

There is a toolbar along the top that allows you to use and do functions with the code in a normal development environment.

The course is the first step toward certification. 

Why does certification matter?

Employers are now constantly looking for new software engineering and computer programming talent. Academic study is important, however, many employers are now looking for certification as well to help ensure that candidates reach a certain level of ability when it comes to programming.

The Python Institute certification does just that and helps prove your ability to code to employers.

This is vital if you are going to become a programmer in the long run.

Python Essentials 1: Introduction in computer programming

Learning outcomes Module 1

This module aims to teach the following:
  • The fundamentals of computer programming, i.e., how the computer works, how the program is executed, how the programming language is defined and constructed;
  • The difference between compilation and interpretation
  • What Python is, how it is positioned among other programming languages, and what distinguishes the different versions of Python.

How does a computer program work?

All computers need computer programs to work. Otherwise, they cannot do anything. However, powerful they might be, without the right code they will not work. A computer without code is like a car without petrol.

A computer program can be complicated or simple. However, at the heart of a computer program is maths repeated numerous times. At the very functional level of computing, a computer is essentially (normally) a machine that does maths in binary code (1 & 0).

A simple computer program

Imagine that you want to know the average speed you've reached during a long journey. You know the distance, you know the time, you need the speed.

Naturally, the computer will be able to compute this, but the computer is not aware of such things as distance, speed or time. Therefore, it is necessary to instruct the computer to:

  • Accept a number representing the distance;
  • Accept a number representing the travel time;
  • Divide the former value by the latter and store the result in the memory;
  • Display the result (representing the average speed) in a readable format.

These four simple actions form a program. Of course, these examples are not formalized, and they are very far from what the computer can understand, but they are good enough to be translated into a language the computer can accept.

LANGUAGE IS THE KEYWORD. YOU NEED LANGUAGE THAT A COMPUTER CAN UNDERSTAND.


Natural V Programming Language

A language is a tool for expressing a thought or emotion. Human languages can be spoken, written or body language. It is a tool for expression, to communicate with another human.

When computers have a language it is called machine language or ML. 

This language will allow a computer to understand a range of simple commands.

These simple commands are known as the INSTRUCTION LIST or IL.

All machine languages are created by humans. However, they are not always designed to use in communication with other humans.

Different computers will have different instruction lists, depending upon their use, need and technology.

Natural Languages have new words appear and disappear over time because the interaction between words, emotions and concepts is dynamic. 

Programming Language generally stays very fixed.

What makes a Language

Every language has a consistent range of parts that make it a language these include:

  • an alphabet: a set of symbols used to build words of a certain language
  • lexis: (aka a dictionary) a set of words the language offers its users
  • syntax: a set of rules (formal or informal, written or felt intuitive) used to determine if a certain string of words forms a valid sentence
  • semantics: a set of rules determining if a certain phrase makes sense

Computers and Langugae

The IL is the Alphabet of computing language. This is the simple set of commands that the computer can understand.

Essentially this is the mother tongue of the computer. It understands this language through a set of predefined symbols.

There needs to be a way for the mother tongue of the computer to be able to understand.
Humans need a medium to write commands and computers need to understand this writing so they can activate the commands.

The medium to do this is a "high-level source code". Source codes are kept in the Source File.

This coding is how the computer and the human can communicate.

Compilation vs. interpretation

Computer programming is the creative placement of computer languages elements to create the desired effect.

The desired effect is down to their goals, immigration and ability.

Every computer programmer needs to work with a computer language in the following ways.

  • alphabetically - a program needs to be written in a recognizable script, such as Roman, Cyrillic, etc.
  • lexically - each programming language has its dictionary and you need to master it; thankfully, it's much simpler and smaller than the dictionary of any natural language;
  • syntactically - each language has its rules and they must be obeyed;
  • semantically - the program has to make sense.

Mistakes in any of the above can render the computer program useless.

Once this language has been finished it needs to be rendered into "Machine Language".

There are two ways to do this compilation vs interpretation.

COMPILATION - the source program is translated once (however, this act must be repeated each time you modify the source code) by getting a file (e.g., a .exe file if the code is intended to be run under MS Windows) containing the machine code; now you can distribute the file worldwide; the program that performs this translation is called a compiler or translator;

INTERPRETATION - you (or any user of the code) can translate the source program each time it has to be run; the program performing this kind of transformation is called an interpreter, as it interprets the code every time it is intended to be executed; it also means that you cannot just distribute the source code as-is, because the end-user also needs the interpreter to execute it.

High-Level Programming Language will fall into one of these two camps.

What is an interpreter? 

What does it actually do? An interpreter will turn a source code in a text file a search for errors in the code line by line. When an error in the processing of the source code is found it will respond with an error message. Although the appearance of an error message and its location within the code are not always linked.

Advantages Compilation

  • The execution of the translated code is usually faster;
  • Only the user has to have the compiler - the end-user may use the code without it;
  • The translated code is stored using machine language - as it is very hard to understand it, your own inventions and programming tricks are likely to remain your secret.

Disadvantages of Compilation

  • The compilation itself may be a very time-consuming process - you may not be able to run your code immediately after any amendment;
  • You have to have as many compilers as the hardware platforms you want your code to be run on.

Advantages of Interpretation

  • You can run the code as soon as you complete it - there are no additional phases of translation;
  • The code is stored using programming language, not machine one - this means that it can be run on computers using different machine languages; you don't compile your code separately for each different architecture.

Disadvantages of Interpretation

  • Don't expect that interpretation will ramp your code to high speed - your code will share the computer's power with the interpreter, so it can't be really fast;
  • Both you and the end-user have to have the interpreter to run your code.

What does this mean for Python?

Python is an interpreted language which means the code can be run without any translation phases.

Python is also a free language but you will need a Python Interpreter.

What is Python?

Named after the TV series Monty Python's Flying Circus, Python is a high-level programming language that is object orientated.

Who created Python?

Guido Von Rossum created Python and named it after the TV Series. This is rare in computer program languages that a single person created the language.

Essentially Python began as a programming home project and then developed from a week over Christmas.

Python Goals

In 1999 the goals for Python were set out by Guido Von Russo

  • an easy and intuitive language just as powerful as those of the major competitors;
  • code that is as understandable as plain English;
  • suitable for everyday tasks, allowing for short development times.

Today Python is a mature and well trusted coding language.

What makes Python Special

It's easy to learn - the time needed to learn Python is shorter than for many other languages; this means that it's possible to start the actual programming faster;

it's easy to teach - the teaching workload is smaller than that needed by other languages; this means that the teacher can put more emphasis on general (language-independent) programming techniques, not wasting energy on exotic tricks, strange exceptions and incomprehensible rules;

it's easy to use for writing new software - it's often possible to write code faster when using Python;

it's easy to understand - it's also often easier to understand someone else's code faster if it is written in Python;

it's easy to obtain, install and deploy - Python is free, open and multiplatform; not all languages can boast that.

Python is found all over the internet and computing world except in programming that is mobile and programming that requires are high graphical content.

There is more than one Python Language

Currently, there is Python 2 and Python 3.

Both are separate but very similar languages.

However, Python 2 code will not work with Python 3. So code does need to be changed manually to ensure that it would work on the other version of Python.

Other versions of Python

There are two other versions of Python

C Python: Is the Canonical or pure version of Python that is maintained by a team of open-source coders in the Python Source Foundation.

This is the version that is in the C language so allows it to be ported it almost any device or system.

C Python is sometimes referred to as the Reference Python.

Cython: Python is easy to code maths but is not very efficient.

Cython allows the maths to be coded in Python and reverted back to the C Language making the maths much quicker and efficient.

There are a range of other specialist Python languages that are used for specific tasks or interactions e.g. with Javascript.


How to get Python & Starting your Work with Python

If you already have Linux, then Python is likely to already be installed.

If you are using any other system - follow this link - https://www.python.org/downloads/

Once you have Python 3 installed, you need to have three other tools to help you. These tools are an Editor, Console and Debugger.

An Editor to write out your script.

A Console to test and run your code and to stop your code when and if it gets out of hand.

A Debugger that will go through the code line-by-line so that you can spot and changes mistakes.

Python 3 comes with IDLE

IDLE is Integrated Development and Learning Environment

**

Thank you for taking the time to read this article. If you would like to keep up to date with me Home Working Henry and my quest to make homeworking better for all then join the newsletter.



Previous Post Next Post

Contact Form