Basic computing before programming — hardware, RAM, disk, terminal and keyboard explained for FP1 (and the grade that vanished when the program closed)
In my first weeks of FP1 I wrote a program that worked out the average of my grades. It worked beautifully: it told me “7.5” and I was delighted. The next day I opened it to check the average… and there was nothing. No average, no grades, not a trace. I thought Python “remembered” variables, as if they were files. It doesn’t: they live in RAM, and RAM is wiped the moment the program ends. That afternoon I learnt more computing than in the whole previous week.
When I started GCID I thought programming was just writing code. But I soon realised there are lots of basic computing concepts that everyone takes for granted and that nobody actually explains: what each part of the computer does, where your program is stored, what the terminal is or why you can’t find the curly braces on the keyboard. In this article I tell you what you need to have clear before your first line of Python, with no unnecessary jargon and with real programs to check it.
In a nutshell: Before programming it helps to know how a computer works: the CPU runs the instructions, RAM holds what is in use and the disk keeps what stays when you switch off. It also helps to understand that everything is stored as bytes (text, with encodings like UTF-8), how file paths work and how to use the terminal.
Table of Contents
Before you start. For this article you don’t need to know how to program or have anything installed: having used a computer is enough. The Python programs that appear are there so you can see what happens when they run, not for you to understand every line yet (when it matters, I tell you what the line does). The route goes from the inside out, in three stretches: first, what hardware is and what software is; then, the three parts that explain how your programs behave (CPU, RAM and disk) and how text is stored as bytes; and finally what you’ll touch every day: files, paths, the terminal, the keyboard and the IDE. If you get lost at any point, go back to the grade that vanished: half the article can be explained with it.
Hardware vs software — the difference that always confuses
This is the first thing to get clear, because you’ll hear it constantly throughout the degree:
- Hardware is everything physical, everything you can touch: the screen, the keyboard, the processor, the RAM, the disk. If it breaks, it gets repaired or the part is replaced.
- Software is what you can’t touch: programs, the operating system, code. If it fails, it gets fixed or reinstalled.
When you program in Python you’re creating software. Your computer (hardware) runs it. But between your program and the hardware there are more layers than it seems:
Read the diagram from top to bottom. Your hello.py doesn’t talk directly to the processor: it asks the Python interpreter (an application), the interpreter asks the operating system, and the operating system shares the hardware among all the programs you have open. That’s why the same hello.py works on Windows, Linux and macOS: what changes are the layers underneath, not your code.
Check you’ve got it: you copy your hello.py to a laptop running Linux. What do you have to change in the code for it to work?
Nothing. Your program only talks to the layer right below it, the Python interpreter, and the interpreter understands the same thing on every system. What that laptop does need is a Python interpreter built for Linux, because that is the one that knows how to ask that operating system for things. The layers underneath change; yours doesn’t. The only nuance is outside the code: in the Linux terminal the command is usually python3 hello.py instead of python hello.py.
Basic computing before programming — what really matters
Before giving the parts their names, go back to my grades program and think how you would work out that average by hand. You need three things. Someone to do the sum: you. Somewhere to keep the 7, the 8 and the result in view while you work: a sheet of scrap paper on the desk. And somewhere to leave the 7.5 so you can look it up tomorrow: the notebook you keep in your backpack.
Now imagine that when you finish you clear the desk and throw the sheet away. If you hadn’t copied the 7.5 into the notebook, tomorrow you don’t have it. The sum was done correctly, but it only existed on the sheet. That is exactly what happened to my program, with one difference: on a computer the sheet throws itself away, without asking you, the moment the program ends.
Inside the computer those three things are three different parts, and now it is time to call them by their names: the one doing the sum is the CPU, the sheet is RAM and the notebook is the disk.
You don’t need to be a hardware engineer to program, but you do need to understand three parts, because each one explains a behaviour of your programs:
| Part | What it is | What you notice when programming |
|---|---|---|
| CPU (processor) | The brain: runs instructions one after another, billions per second | A program with lots of calculations takes longer |
| RAM (memory) | Fast, temporary memory holding what’s in use right now | Your variables live here and vanish when the program ends |
| Disk (SSD or HDD) | Permanent storage, slower | Your .py files and the data you save live here |
The key is the difference between RAM and disk. I checked it with two programs run one after the other in the same folder. The first one computes an average and saves it to a file:
# a_ram.py: a variable lives in RAM; a file, on disk
grade1 = 7
grade2 = 8
average = (grade1 + grade2) / 2 # (7 + 8) / 2 = 7.5, computed by the CPU and stored in RAM
print("Average computed:", average)
with open("notes.txt", "w", encoding="utf-8") as f: # "w" = write: creates the file on disk
f.write(f"average={average}\n")
print("Saved to notes.txt")
Output:
Average computed: 7.5 Saved to notes.txt
The maths: (7 + 8) / 2 = 15 / 2 = 7.5. The variable average is in RAM; on top of that, the with open(...) block creates notes.txt on disk and writes average=7.5 into it. Now another program, run afterwards, tries to use both things:
# b_after.py: another program, run afterwards. What still exists?
with open("notes.txt", encoding="utf-8") as f: # the file is still on disk
print("On disk:", f.read().strip())
print("In RAM:", average) # the variable died with the previous program
Output:
On disk: average=7.5
Traceback (most recent call last):
File "b_after.py", line 5, in <module>
print("In RAM:", average) # the variable died with the previous program
^^^^^^^
NameError: name 'average' is not defined
The file part works: notes.txt is still on disk and we read it without trouble. But the variable average no longer exists: it died with the first program, and Python answers with a NameError (read the last line of the error: “name average is not defined”). That’s exactly what happened with my grades program.
The diagram sums up both phases. While a_ram.py runs, the CPU computes, RAM holds the variables and the disk receives notes.txt. When it ends, the RAM column is empty and only what was on disk survives.
The two runs, moment by moment
Let’s go through the two programs again, slowly, looking at what is in RAM and what is on disk at each moment. First, a detail I haven’t told you until now: a program saved on disk does nothing. To run it, the operating system copies it from the disk into RAM, and that is where the CPU reads its instructions one by one.
| Moment | In RAM | In notes.txt (disk) | Why |
|---|---|---|---|
You type python a_ram.py | The program, just loaded; no variables yet | Doesn’t exist | The operating system copies the program from the disk into RAM so the CPU can run it |
grade1 = 7 and grade2 = 8 | grade1 and grade2 | Doesn’t exist | Each variable is a slot of RAM with a name |
average = (grade1 + grade2) / 2 | grade1, grade2 and average (7.5) | Doesn’t exist | The CPU does the sum and leaves the result in RAM, not on disk |
print("Average computed:", average) | The same three | Doesn’t exist | print only shows the value on the screen: it doesn’t save anything anywhere |
with open(...) and f.write(...) | The same three (and f, the open file) | average=7.5 | It is the only instruction in the program that sends something to the disk |
a_ram.py ends | Nothing | average=7.5 | The operating system takes that RAM back for other programs; the disk is not touched |
You type python b_after.py | The new program; no variables | average=7.5 | Every run starts with a clean memory: it inherits nothing from the previous one |
open(...) and f.read() | The text that has just been read | average=7.5 | The file was still on disk, and reading it copies it into RAM without deleting it |
print("In RAM:", average) | No average | average=7.5 | In this program nobody has created average: out comes the NameError |
The row that explains my slip is the fourth: seeing the 7.5 on the screen made me believe it was “saved”, but print only shows it. The one that would have prevented it is the fifth.
Check you’ve got it: you delete notes.txt and run only b_after.py. Do you get the NameError again?
No: the program doesn’t even reach that line. Python runs from top to bottom and stops at the first error, and now the first one is on line 2: open looks for notes.txt on disk, doesn’t find it and you get FileNotFoundError: [Errno 2] No such file or directory: 'notes.txt'. If you run a_ram.py first, the file exists again, line 2 works and the error becomes the one on line 5, the NameError. They are two different errors for two different reasons: the first, because something is missing on disk; the second, because something is missing in RAM.
Thinking a variable “gets saved” when you close the program. Whatever you want to keep between runs has to go into a file (you’ll see it in depth in the FP1 topic on text files).
A typical student computer today has 8 or 16 GB of RAM and an SSD of 256 to 1000 GB. RAM is about a hundred times smaller than the disk, but far faster: that’s why the program works in RAM and only uses the disk to load and save.
Bits, bytes and why “ñ” takes twice the space
Everything a computer stores is bits (zeros and ones), grouped in eights into bytes. A kilobyte (KB) is 1000 bytes; a megabyte (MB), a million; a gigabyte (GB), a billion. And text? Each character becomes one or more bytes according to an encoding; the one used by your .py files is UTF-8. This program measures it:
# c_bytes.py: how many bytes each character takes in UTF-8 (the encoding of your .py files)
for text in ["a", "ñ", "€", "🐍", "Python"]:
n = len(text.encode("utf-8")) # encode turns the text into bytes
print(f"{text!r:10} -> {len(text)} character(s), {n} byte(s)")
Output:
'a' -> 1 character(s), 1 byte(s) 'ñ' -> 1 character(s), 2 byte(s) '€' -> 1 character(s), 3 byte(s) '🐍' -> 1 character(s), 4 byte(s) 'Python' -> 6 character(s), 6 byte(s)
Notice: a takes 1 byte, but ñ takes 2, € takes 3 and the emoji takes 4, even though all four are a single character for Python (len counts characters; len(text.encode("utf-8")) counts bytes). "Python" is 6 letters without accents: 6 characters and 6 bytes.
And why don’t they all take the same space? Start with the bit: it can only tell two things apart, 0 or 1. With two bits there are already four combinations (00, 01, 10 and 11), and every bit you add doubles them. With the 8 bits of a byte you get 2 × 2 × 2 × 2 × 2 × 2 × 2 × 2 = 256 combinations, so a byte can hold a number from 0 to 255 and nothing more.
Storing text is, then, storing numbers: each character has one. The a is 97, which in bits is written 01100001. From right to left, the positions are worth 1, 2, 4, 8, 16, 32, 64 and 128; the ones switched on are the 64, the 32 and the 1, and 64 + 32 + 1 = 97.
The problem is that the world has far more than 256 characters. UTF-8 solves it like this: the letters of the English alphabet, the digits and the basic signs (the first 128 numbers, from 0 to 127) take a single byte; for everything else it uses bytes from 128 upwards, which come in groups of two, three or four. You can see the numbers of any text with list(text.encode("utf-8")):
| Character | Bytes in UTF-8 | How many | Why |
|---|---|---|---|
a | 97 | 1 | It is among the 128 basic ones: one byte is enough |
ñ | 195, 177 | 2 | It is not among the basic ones: it needs a group of two |
€ | 226, 130, 172 | 3 | It is one of those that come in a group of three |
This explains the warning in the box below. A program that reads the file with an old encoding, one byte per character, doesn’t know that 195 and 177 go together: it draws them separately, and in that encoding 195 is à and 177 is ±. That is where the famous ñ comes from.
Check you’ve got it: what do len("año") and len("año".encode("utf-8")) give?
They give 3 and 4. For Python the word (Spanish for “year”) has three characters, and that is what the first len counts. In bytes, the a takes 1, the ñ takes 2 and the o takes 1: 1 + 2 + 1 = 4, which are the bytes 97, 195, 177 and 111. If the file contained only that word, it would weigh 4 bytes, not 3.
If you open a file and see things like ñ instead of ñ, it was written in UTF-8 and is being read with another encoding. That’s why, in Python, you should always write encoding="utf-8" when opening text files, as in the programs above.
System software vs application software
Your computer has two big layers of software (the two in the middle of the first diagram):
- System software: the operating system (Windows, macOS, Linux). It’s the go-between for the hardware and your programs: it decides which program uses the CPU at each moment, how much RAM each one gets and who can read each file.
- Application software: the programs you use to do specific things. VS Code is application software. The Python interpreter too. The browser too.
As a GCID student you’ll mostly work on Windows, but in IC2 you’ll meet Linux (Fedora). If you want a head start, read Linux for students and set up a virtual machine with the guide to install Fedora on VirtualBox.
File organisation — do this now
It looks trivial but it’s one of the most practical pieces of advice I can give you: organise your code files from day one. During the degree you’ll have dozens of .py files, and if they’re all on the desktop or in Downloads, within two weeks you won’t find anything. A simple structure that works:
GCID ├── FP1 │ ├── topic_variables │ │ ├── grade_average.py │ │ └── bmi.py │ └── topic_conditionals └── IC2
Three rules that will save you trouble:
- No spaces or accents in names of code folders and files:
topic_variables, notThe variables topic. In the terminal, a space separates words and forces you to use quotes. - Turn on file extensions in Windows File Explorer (View → Show → File name extensions). That way you’ll see whether your file is
hello.pyorhello.py.txt. - A name that says what it does:
grade_average.pymakes sense a month later;test2_final_good.pydoesn’t.
Paths: each file’s address
Every file has a path, its address on the disk. On Windows, the absolute path starts with the drive letter: C:\Users\Sergio\GCID\FP1\topic_variables\grade_average.py. A relative path counts from the folder you’re in: if you’re already in C:\Users\Sergio\GCID\FP1, the same file is topic_variables\grade_average.py. And .. means “the folder above”.
| Extension | What it is | What opens it |
|---|---|---|
.py | Python program | VS Code, python file.py |
.ipynb | Jupyter notebook | VS Code with Jupyter |
.csv | Data in comma-separated columns | VS Code, Excel, pandas |
.txt | Plain text | Any editor |
.c / .java | C / Java code (IC2, FP2) | VS Code |
Windows separates folders with \ and Linux with /. Python also accepts / on Windows, so in your programs you can write "data/grades.csv" and it will work on both systems.
The terminal — your new best friend
The terminal (also called the console or command line) is a window where you give orders to the operating system by typing, without the mouse. It’s intimidating at first, but you’ll use it constantly: to run programs, install libraries, compile C and move around Linux in IC2.
On Windows you open it by searching for cmd (Command Prompt) or PowerShell in the Start menu. These are the basic commands you need from the start (they’re Windows commands, so I describe them; on Linux almost all of them change name):
| I want to… | Windows (cmd / PowerShell) | Linux (bash) |
|---|---|---|
| See which folder I’m in | cd (cmd) / pwd (PowerShell) | pwd |
| Go into a folder | cd topic_variables | cd topic_variables |
| Go up to the folder above | cd .. | cd .. |
| See the files | dir | ls |
| Create a folder | mkdir FP1 | mkdir FP1 |
| Clear the screen | cls | clear |
| Run a Python program | python grade_average.py | python3 grade_average.py |
| See the Python version | python --version | python3 --version |
If you followed the guide to install Python on Windows, you already used the terminal to check it worked. That’s exactly what it’s for.
Press Tab while typing a folder or file name and the terminal completes it for you. Type cd top + Tab and you get cd topic_variables. Less typing and zero typos.
A whole terminal session, command by command
The table of commands is easier to understand by using it. Behind all of them there is one idea: the terminal is always “inside” a folder, the current folder, and everything you type is interpreted from there. On Windows you always have it in view, written just to the left of where you type (C:\Users\Sergio>). This is a complete session with the folder structure from before:
| You type | Current folder afterwards | Why |
|---|---|---|
| (you open the terminal) | C:\Users\Sergio | When it opens, the terminal usually starts in your user folder |
cd GCID | C:\Users\Sergio\GCID | GCID is a relative path: it is looked up inside the current folder |
cd FP1\topic_variables | C:\Users\Sergio\GCID\FP1\topic_variables | You can go down two folders at once by separating them with \ |
dir | The same | dir doesn’t move you: it lists what is here, grade_average.py and bmi.py |
python grade_average.py | The same | A bare name is also a relative path, and the file is right here: it runs |
cd .. | C:\Users\Sergio\GCID\FP1 | .. is the folder above |
python grade_average.py | The same | Error: there is no grade_average.py in FP1. The file hasn’t moved; you have |
python topic_variables\grade_average.py | The same | Now the relative path does lead from where you are to the file: it runs |
The error in the second-to-last row ends in [Errno 2] No such file or directory and it is, by far, the one you’ll see most in your first weeks. It almost never means your program is wrong: it means the terminal is in another folder.
When you get that error, before touching the code look at two things: which folder you are in (it is shown to the left of where you type) and what is in it (dir). If your file isn’t in the list, the problem is the folder, not the program.
Check you’ve got it: you are in C:\Users\Sergio\GCID\FP1\topic_variables and you type cd ..\... Which folder do you end up in? And which command would take you from there, in one go, into topic_conditionals?
You end up in C:\Users\Sergio\GCID. Each .. goes up one folder: the first takes you from topic_variables to FP1 and the second, from FP1 to GCID. To go down to the other folder you type cd FP1\topic_conditionals, a relative path that starts at GCID, which is where you are. With the absolute path, cd C:\Users\Sergio\GCID\FP1\topic_conditionals, you would get there from anywhere, because an absolute path doesn’t depend on the current folder.
Special characters you’ll type constantly in code
The FP1 notes include a table of special characters that are essential for programming. These are the ones you’ll use most, and what for:
| Character | Name | In Python it’s used for | Example |
|---|---|---|---|
( ) | Parentheses | Calling functions, grouping maths | print("hello") |
[ ] | Square brackets | Lists and indexes | [1, 2, 3] |
{ } | Curly braces | Dictionaries and f-strings | {"key": "value"} |
" " and ' ' | Quotes | Text (strings) | "Sergio" |
: | Colon | After if, for, def | if x > 0: |
# | Hash | Comments | # this doesn't run |
_ | Underscore | Variable names | grade_average |
= | Equals | Assignment | x = 5 |
== | Double equals | Comparison | x == 5 |
\ | Backslash | Special characters in text | "\n" (new line) |
On a Spanish keyboard (the one most of us at ULPGC use), several of these aren’t obvious. Many websites give combinations that are wrong, so here they are drawn key by key:
The top row shows what you get with AltGr (the key to the right of the space bar): square brackets [ ] are on the two keys to the right of P (the grave/circumflex accent key and the + key) and curly braces { } on the two to the right of Ñ (the acute accent key and ç). The hash is AltGr + 3 and the backslash AltGr + º (the top-left key). The bottom row shows Shift: parentheses with 8 and 9, equals with 0 and the colon on the full stop key. On a US or UK keyboard most of these are printed on the keys themselves. Learn them by heart: you’ll type them thousands of times.
Mixing up = and ==. x = 5 stores 5 in x; x == 5 asks whether x is 5 and answers True or False. Writing if x = 5: gives a SyntaxError as soon as you run it.
The IDE — where you write your code
An IDE (Integrated Development Environment) is the program where you write and run your code. We use VS Code, which I explain step by step in configure VS Code for Python.
What does an IDE do that Notepad doesn’t? It colours the code so it’s easier to read, detects errors as you type, autocompletes names, lets you run the program without leaving the editor and debug it line by line. And it doesn’t add .txt to your files without telling you.
Exam-style quiz
Now test yourself as in the exam. The FP1 quizzes look like this: 15 questions in 20 minutes (16 in 30 in the Sequences one), almost all single choice (each wrong answer subtracts a third of what the question is worth) and many «what does this code print?», with the odd fill in the gaps, matching or true or false. Here are 13 original questions on basic computing. Answer without running anything, press Check and read the explanation for each one. These questions are also the question bank for the FP1 theory mock exam, which will mix them with those from the other topics.
You are writing an assignment and the power goes off before you save. Why do you lose the last thing you wrote?
- It was only in RAM, which is wiped when the power goes
- It was on the disk, but the disk is formatted when it switches off
- The CPU kept it in its registers and sends it to the internet on shutdown
- The operating system deletes files that are not closed properly
Solution
Answer: It was only in RAM, which is wiped when the power goes
While you work, the open document lives in RAM, which is fast but volatile. Saving copies it to the disk (or SSD), which is slower but persistent: it keeps the data without power.
Match each component with what it does:
| CPU | |
| RAM | |
| Disk or SSD | |
| Operating system |
Definitions:
- Holds the programs and data in use right now
- Shares the CPU, memory and devices among programs
- Keeps files even when the computer is off
- Turns Python code into a text document
- Runs the instructions of programs
Solution
- CPU → Runs the instructions of programs
- RAM → Holds the programs and data in use right now
- Disk or SSD → Keeps files even when the computer is off
- Operating system → Shares the CPU, memory and devices among programs
The CPU does the work; RAM is its desk (fast and volatile); the disk is the filing cabinet (slow and persistent); and the operating system organises everything so that several programs can live together.
The extra definition does not belong to any component.
Which of these are input devices?
- Keyboard
- Mouse
- Microphone
- Monitor
- Printer
Solution
Answer: Keyboard · Mouse · Microphone
Input = from the world into the computer (keyboard, mouse, microphone, scanner). Output = from the computer to you (monitor, speakers, printer). Remember that in multiple choice wrong ticks subtract: do not tick just in case.
How many bits are there in 3 bytes? Write only the number.
Solution
Answer: 24
A byte is 8 bits, so 3 × 8 = 24 bits. A bit is a single 0 or 1; with one byte (8 bits) you can represent 2⁸ = 256 different values.
Which decimal number does the binary 1011 represent?
- 11
- 13
- 1011
- 7
Solution
Answer: 11
From right to left, the positions are worth 1, 2, 4 and 8. In 1011 the 8, the 2 and the 1 are on: 8 + 2 + 1 = 11.
True or false?
- The operating system is a program, even if a very special one.
- RAM keeps its data when you switch the computer off.
- A path like
C:\Users\ana\notes.txtsays which folder a file is in. - The terminal only exists on Linux; Windows does not have one.
Solution
- T — The operating system is a program, even if a very special one.
- F — RAM keeps its data when you switch the computer off.
- T — A path like
C:\Users\ana\notes.txtsays which folder a file is in. - F — The terminal only exists on Linux; Windows does not have one.
The OS is software: it is loaded at start-up and manages everything else. RAM is volatile. A path is the chain of folders down to the file. And Windows has a terminal too (CMD and PowerShell), just like macOS and Linux.
What is an IDE, such as VS Code or PyCharm?
- A program to write, run and debug code in one place
- The language Python programs are written in
- A computer component that speeds programs up
- A special folder where Python keeps its files
Solution
Answer: A program to write, run and debug code in one place
IDE stands for Integrated Development Environment. You could program with Notepad and the terminal, but the IDE warns you about errors, colours the code and runs it with one button.
Complete the sentence:
To run a program, the operating system copies it from the ____ into ____, and the ____ runs its instructions one by one.
Words:
- printer
- RAM
- screen
- disk
- CPU
Solution
To run a program, the operating system copies it from the disk into RAM, and the CPU runs its instructions one by one.
The program is stored on the disk, but the CPU only works with what is in RAM. That is why opening a big program takes a moment: it has to be copied first.
What are square brackets [ ] mainly used for in Python?
- To write lists and access positions, as in
grades[0] - To write comments
- To group the code of an
if - To write text
Solution
Answer: To write lists and access positions, as in grades[0]
It is worth learning where [ ], { }, # and the quotes are on your keyboard: you will type them hundreds of times. On a Spanish keyboard the brackets need Alt Gr plus the two keys to the right of P.
What is the difference between a file and a folder?
- A file holds data (a text, a photo, a program); a folder groups files and other folders
- None: they are two names for the same thing
- The file is in RAM and the folder on the disk
- Folders only exist on Windows
Solution
Answer: A file holds data (a text, a photo, a program); a folder groups files and other folders
The OS file system organises the disk as a tree of folders (directories) that contain files. When, in the files topic, you write open('data.txt'), Python will look for that file in the folder you run the program from.
Put in order what happens from pressing the power button to writing your first program:
- You log in and the desktop appears
- The firmware (BIOS or UEFI) runs and checks the hardware
- The operating system is loaded from the disk into RAM
- You open the IDE
- You write the program and save it to the disk
Solution
Correct order:
- The firmware (BIOS or UEFI) runs and checks the hardware
- The operating system is loaded from the disk into RAM
- You log in and the desktop appears
- You open the IDE
- You write the program and save it to the disk
First the small firmware program starts, finds the operating system and loads it into memory. With the OS running you can open applications such as the IDE. And what you write is not safe until you save it to the disk.
What happens to the value of grade when this program ends?
grade = 7.5 print(grade)
- It disappears: variables live in RAM while the program runs
- It is saved to the disk automatically
- It stays on the screen for ever
- It is saved inside the
.pyfile itself
Solution
Answer: It disappears: variables live in RAM while the program runs
When the program runs, Python sets aside room in RAM for grade. When the program ends, that memory is freed and the value is gone. If you want it to last between runs, you have to write it to a file (the last FP1 topic).
What happens if you type python3 hello.py in the terminal?
- The Python interpreter reads
hello.pyand runs its instructions - A new empty file called
hello.pyis created - The IDE opens with the file
- The file is deleted after running it
Solution
Answer: The Python interpreter reads hello.py and runs its instructions
The terminal runs commands: python3 is the program (the interpreter) and hello.py the file you give it. If the file is not in the current folder, you will see an error like No such file or directory.
Watch it step by step in Python Tutor
pythontutor.com runs your code line by line and draws the variables in memory at each moment: it’s the most direct way to “see” RAM. Choose Python 3, paste this program and click Visualize Execution:
# Python Tutor: variables appear in RAM (Frames) while the program runs
grade1 = 7
grade2 = 8
average = (grade1 + grade2) / 2
subjects = ["FP1", "Calculus"]
subjects.append("Algebra") # the list grows: it is the same list, not a copy
def round1(x):
result = round(x, 1) # 'result' only exists while the call lasts
return result
average = round1(average)
print("Average:", average, "in", len(subjects), "subjects")
Output:
Average: 7.5 in 3 subjects
What to watch step by step:
- In the first steps, the Frames column shows
grade1,grade2andaverage(7.5): those little boxes are your variables in RAM. - When
subjectsis created, the list is drawn on the right (Objects) and the variable points to it with an arrow. - With
append, the same list grows to three items: no new list is created. - When
round1is called, a new frame appears withxandresult; as soon as the call ends, it disappears. It’s the same RAM idea, on a small scale. - At the end,
averageis 7.5 andlen(subjects)is 3, which is exactly what the output prints.
Summary — the essentials before programming
| Concept | In one sentence |
|---|---|
| Hardware / software | What you touch / programs and code |
| Layers | Your program → applications → operating system → hardware |
| CPU | Runs the instructions |
| RAM | Holds variables while the program runs; wiped when it ends |
| Disk | Keeps your .py files and data permanently |
| Byte and UTF-8 | 8 bits; ñ takes 2 bytes, a takes 1 |
| Path | A file’s address: absolute (from C:\) or relative |
| Terminal | Typed orders to the system: cd, dir, python file.py |
| IDE | Where you write, run and debug (VS Code) |
Three ideas to take away:
- RAM forgets, the disk remembers: whatever you want to keep goes into a file.
- Organise and name things well from day one: folders per subject, no spaces or accents, extensions visible.
- The terminal and the keyboard are working tools: learn five commands and where
[ ]and{ }are, and you’ll move twice as fast.
With all this clear, you have all the context you need to start. The next step is to install Python on Windows and then configure VS Code, if you haven’t done that yet.
Next step: exercisesBasic computing — exercises with a pendrive, folder paths and bytes with accents (and the grades.txt that «didn’t exist» in the lab)Did this article help you? Here is how you can support SergioLearns →



