Skip to 0 minutes and 3 seconds There are lots of definitions of computer programming, but the one I use is programming is how you get computers to solve problems. You are important. Without you, the programmer, the computer is useless. A computer will only do what you tell it to do. Secondly, they solve problems. Computers are tools. They’re very complex tools, but they’re not mysterious or magical. They exist to make tasks easy for you. Computer programs, or software, are what make computers work. Without software, modern computers are just complicated machines which turn electricity into heat. It’s software on your computer that runs your internet browser, email, games, or just about everything. And programming is a creative task.
Skip to 0 minutes and 45 seconds There’s no right or wrong way to solve a problem, just like there’s no right or wrong way to paint a picture. You have to make choices. And while one may seem better than the other, neither is wrong. With the right skills and experience, you can program software to solve an unlimited number of problems. The only options are constrained by your imagination, and this is why I love programming. When you create a program for a computer, you give it a set of instructions which it follows to the letter. Let’s write some code for this computer. Turn and face the cliff. Walk towards the cliff.
Skip to 1 minute and 23 seconds Stop at the edge of the cliff. Jump off the cliff. And it will perform these instructions in order, one at the time, precisely as given. It doesn’t question. It doesn’t think. It will do exactly what you tell it to do. So if you told a computer to jump off a cliff, it would. To stop computers constantly falling off cliffs, you can give it a choice and tell it what to do next. So we’ll add in a line of code that says, if I won’t survive the fall, don’t jump off the cliff. Computers also never get bored, and they’re great at doing the same thing over and over again.
Skip to 1 minute and 59 seconds To get our computer to walk towards the cliff, we need to tell it to move its feet. So let’s write, walk towards the cliff, left foot forward, right foot forward, left foot forward, right foot forward. The computer will keep taking steps forward like this, looping our instructions until you tell it to stop. You can summarise the logic of computer programming with these three concepts. Sequence– running instructions in order. Selection– making choices. Repetition– doing the same thing more than once. Add to these concepts the ability to deal with inputs and outputs, to store data, and then you have the tools to solve the majority of all computing programs.
What is programming?
There are countless definitions of what computer programming is, but the one I use is:
“Programming is how you get computers to solve problems.”
There are two key phrases here which are important:
- you: without the programmer (you), the computer is useless. It does what you tell it to do.
- solve problems: computers are tools. They are complex tools, admittedly, but they are not mysterious or magical: they exist to make tasks easier.
Computer programs (or software) are what make computers work. Without software, modern computers are just complicated machines for turning electricity into heat. It’s software on your computer that runs your operating system, browser, email, games, movie player – just about everything.
Programming is a creative task: there is no right or wrong way to solve a problem, in the same way that there is no right or wrong way to paint a picture. There are choices to be made, and one way may seem better than another, but that doesn’t mean the other is wrong! With the right skills and experience, a programmer can craft software to solve an unlimited number of problems – from telling you when your next train will arrive to playing your favourite music. The possibilities are constrained only by your imagination. That’s why I love programming.
When you create a program for a computer, you give it a set of instructions, which it will run one at a time in order, precisely as given. If you told a computer to jump off a cliff, it would!
1. turn and face the cliff 2. walk towards the cliff 3. stop at the edge of the cliff 4. jump off the cliff
To stop computers constantly falling off cliffs, they can also make choices about what to do next:
If I wont survive the fall, don't jump off the cliff
Computers never get bored and are really good at doing the same thing over and over again. Instruction 2 above might look in more detail like this:
2a. left foot forward 2b. right foot forward 2c. go back to 2a
These three concepts are the basic logical structures in computer programming:
- Sequence: running instructions in order
- Selection: making choices
- Repetition: doing the same thing more than once
Add to these concepts the ability to deal with inputs and outputs and to store data, and you have the tools to solve the majority of all computing problems.
Unfortunately, computers don’t understand languages like English or Spanish, so we have to use a programming language they understand to give them instructions.
There are many different programming languages, all of which have their own merits, and certain languages are better suited to particular types of task, but there is no one language which is the ‘best’.
In this course you will be programming using a language called Python. Python is one of a group of languages called “general-purpose programming languages”, which can be used to solve a wide variety of problems. Other popular languages in this category are C, Ruby, Java and BASIC.
This is a small Python program which asks the user to enter their name and says “Hi” to them:
print("Hello and welcome.") name = input("Whats your name?") if name == "Martin": print("Thats my name too!") print("Hi " + name)
You don’t need to be a computer programmer to be able read this code. It contains English words and it is readable (if not perhaps understandable). However, by the end of this course you will understand this code, what it does, and the concepts it uses.
Programs are often referred to as code and hence programming is also known as coding.