A workshop for code
A carpenter (a person who makes things from wood) does not work with only a saw. The workshop has a bench, a light, a ruler and a tool for every job.
A developer has a workshop too. It is called an IDE. One program holds the editor, the tools to run the code, and the tools to find mistakes.
Key words
| Word | What it means |
|---|---|
| IDE | Integrated development environment. One program with an editor, a runner and a debugger. |
| Debugger | A tool that runs code one step at a time to find a bug. |
| Debug | Find and fix a mistake in code. |
| Breakpoint | A line where the debugger stops to show the values. |
| Version control | A tool that records every change to your files so you can go back. |
| Repository | A store for a project and its full history. |
| Pull request | A request to merge your changes after the team reviews them. |
| Plugin | An extra feature you add to a tool. |
| Refactoring | Changing code so it is cleaner but does the same job. |
| Issue tracker | A list of bugs and tasks that the team shares. |
| Live sharing | Editing one file together from different places. |
The cells students fill in are left blank in this preview.
What an IDE gives you
| Feature | What it does | Why it helps |
|---|---|---|
| Editor | Colours the code, finishes words, shows mistakes as you type | You find typing mistakes at once |
| Run button | Runs the program from inside the IDE | No need to switch windows |
| Debugger | Stops at breakpoints and shows the values | You see what really happens |
| Plugins | Adds languages and tools | One IDE fits many jobs |
| Version control | Git buttons inside the IDE | Commit without leaving your code |
| Refactoring | Renames a name everywhere safely | Cleaner code with fewer mistakes |
The cells students fill in are left blank in this preview.
Match the feature
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Choosing an IDE
There are many IDEs. Some are for one language, such as PyCharm for Python. Some are for many languages, such as Visual Studio Code with plugins. Some cost money and some are free.
Ask: which language? Which computer? What does the team already use? Can it share code with the team?
Technology for code teamwork
A team needs more than an IDE.
Code hosting holds the shared repository, such as Gitea, GitHub or GitLab.
Pull request review tools let people comment on lines and approve a change.
Issue trackers list bugs and tasks. Live sharing lets two people edit one file together.
Check: IDE and team tools
Have a go
Check: IDE and team tools
3 questionsPrint the values to find a bug
def last_two(items):
return items[-2] # a bug: this is only one item
data = [4, 8, 15, 16]
print("data is", data)
print("result is", last_two(data))
# The result should be [15, 16]. Fix last_two and run it again.
Make a free account to save your work and track your progress.
A way to find any bug
- Say what you expected and what you got.
- Find the first place where the values are wrong. Use print, or a breakpoint in the IDE.
- Change one thing.
- Run again.
Change only one thing at a time. If you change three things, you do not know which one helped.
Watch a loop change its total
total = 0
for price in [2, 3, 4]:
total = total + price
print("after", price, "total is", total)
# This is what a debugger shows you, line by line.
# Change the list and run again.
Make a free account to save your work and track your progress.
Find and fix four bugs
Each of the four functions has a bug. Use the steps from this lesson. Print the values, find the first wrong one, then change one thing at a time. The hidden tests check each function and its edge cases. Press Run Tests.
def running_total(prices):
# [2, 3, 4] must give back [2, 5, 9].
return prices
def count_vowels(text):
# Count a, e, i, o, u in any case. "Education" has 5.
count = 0
for letter in text:
if letter == "a":
count = count + 1
return count
def last_word(text):
# "the bus is late" must give back "late".
return text.split()[1]
def first_negative(numbers):
# Give back the position of the first number below 0, or -1 if there is none.
for position in range(1, len(numbers)):
if numbers[position] < 0:
return position
return -1
Make a free account to save your work, or press Start lab to work through the whole lesson.
Key words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Exit quiz
Have a go