You press Run and it breaks
You write 10 lines of code. You press Run. A red error appears and you do not know why.
A builder has a hammer, a tape measure and a plan. A developer has tools too. Some tools help you write code. Some help you find mistakes. Some turn your code into a program the computer can run.
Other programs, such as email and spreadsheets, help everybody at work.
Key words
| Word | What it means | Example |
|---|---|---|
| IDE | Integrated development environment: one program that holds the tools for writing code. | The tool a student uses to write code |
| Source code | The code a person writes. | print("hi") |
| Machine code | The 1s and 0s a processor can run. | The file a compiler makes |
| Compiler | A tool that translates all the source code into machine code before it runs. | A tool that makes a program file |
| Interpreter | A tool that translates and runs source code one line at a time. | The Python interpreter |
| Debug | To find and fix mistakes in a program. | Run one line, then stop |
| Breakpoint | A place where the debugger pauses the program. | Pause at line 12 |
| Syntax | The spelling and grammar rules of a programming language. | A missing closing bracket ) |
| Variable | A name that holds a value. | total = 0 |
| Database | An organised store of data you can search. | A list of customers |
The cells students fill in are left blank in this preview.
Match the tool to the job
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
What is inside an IDE?
| Part | What it does | How it helps you |
|---|---|---|
| Code editing tools | Colour the code, suggest words, find and replace, check the syntax as you type | Fewer typing mistakes and faster work |
| Debugging tools | Pause the program, run one line at a time, show the value of each variable | You find where the mistake is |
| Screen design tools | Drag buttons, boxes and text onto a window and see a preview | You build a screen without writing every line |
The cells students fill in are left blank in this preview.
Quick check: the IDE
Have a go
Quick check: the IDE
3 questionsTry it: find the bug
# This program has a mistake. Run it and read the error message.
prices = [2.5, 3.0, 1.5]
total = 0
for price in prices:
total = total + price
print("The total is " + total)
# Fix it: change the last line to print("The total is", total)
Make a free account to save your work and track your progress.
Compiler or interpreter?
Your source code is words. A processor only runs machine code. Something must translate.
A compiler translates the whole program first. Then you run the result. An interpreter translates one line, runs it, then moves to the next line.
Two ways to translate
flowchart LR
src1["Source code"] --> comp["Compiler: translate everything"]
comp --> mc["Machine code file"]
mc --> run1(["Run the program"])
src2["Source code"] --> interp["Interpreter: translate one line, run it, repeat"]
interp --> run2(["Program runs line by line"])
Compiler and interpreter compared
| Compiler | Interpreter | |
|---|---|---|
| Translates | All the code first | One line at a time |
| Speed of the finished program | Usually faster | Usually slower |
| Errors | Reported for the whole program before it runs | Found when that line is reached |
| Good for | Large programs that must run fast | Learning, testing and quick changes |
The cells students fill in are left blank in this preview.
Words from the tools
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Extra: Real tools and languages
Visual Studio Code and PyCharm are two IDEs many developers use.
C and C++ usually use a compiler. Python and JavaScript usually use an interpreter.
Real languages often mix the two. For Java, a compiler makes a middle form called bytecode, which then runs. Python makes bytecode too. In the exam, keep to the simple split in the table.
Everyday application software
Application software helps people do their work. Five kinds appear in most offices.
A word processor writes letters and reports. A spreadsheet does sums in a grid. A database stores lots of data. Email sends messages. Project management software tracks who does which job and when.
Extra: Try it: ask a database
SELECT job FROM jobs WHERE owner = 'Sam';
-- Change Sam to Aisha and run it again.
Make a free account to save your work and track your progress.
Five kinds of application
| Application | What it is for | Example at work |
|---|---|---|
| Word processor | Writing and formatting text | A letter to a customer |
| Spreadsheet | Numbers, sums and charts in a grid | A monthly budget |
| Database | Storing and searching large amounts of data | A list of all customers |
| Sending messages and files | Sending an invoice | |
| Project management software | Planning tasks, deadlines and who does what | A board of tasks for a team |
The cells students fill in are left blank in this preview.
Your turn: debug two functions
Two functions have a bug. Find each bug and fix it. The first function should give the average of two numbers. The second should give the total of a list of prices. Read the code one line at a time. Remember: the computer does the part in brackets first. Press Run Tests to check.
def average(a, b):
# Give back the average of two numbers.
return a + b / 2
def total(prices):
# Give back the total of a list of prices.
total = 0
for price in prices:
total = price
return total
Make a free account to save your work, or press Start lab to work through the whole lesson.
True or false?
Have a go
True or false?
5 questionsFinal check
Have a go