Topics in this sectionCreating Programs Using Notepad1 topic
- Writing and Running Programs
Writing and Running Programs in Notepad
A computer program is a set of instructions that tells the computer what to do. You can write these instructions using a simple text editor called Notepad, then save the file in a special way that lets the computer run your program.
Notepad is a basic text editor that comes free with every Windows computer. It does not have any special features for programming, which makes it a good tool for learning how programs work. When you write code in Notepad, you are writing what programmers call source code — the human-readable instructions that the computer will follow.
Step 1: Open Notepad
Click the Start button on your computer screen. In the search box that appears, type the word "Notepad." When you see the blue Notepad icon at the top of the Start window, click it to open the program.
Step 2: Choose Your Programming Language
You can write programs in many different languages using Notepad. The most common ones you will use are:
- Python — a simple language often used by beginners, saved with the extension .py
- HTML — the language used to create web pages, saved with the extension .html
- Batch — a simple language that runs commands in Windows, saved with the extension .bat
- C++ — a more advanced language used to build software applications, saved with the extension .cpp
Choose one language and use it consistently throughout your program.
Step 3: Write Your Code
Type your instructions on separate lines in Notepad. Each new line of code should start on a new Notepad line. Be careful to spell everything correctly — the computer will only understand your program if the code is exact.
Step 4: Close All Brackets and Parentheses
If your program uses brackets { or [ or parentheses (, you must close each one with its matching symbol. For example, if you open a parenthesis with (, you must close it with ) before the line is finished. Leaving brackets or parentheses open will cause errors when you try to run the program.
Step 5: Save Your Program Correctly
Saving a program is different from saving a normal document. You must follow these steps carefully:
- Click the File menu at the top of the Notepad window.
- Click Save As.
- Choose where you want to save your file — for example, your Documents folder or a USB flash drive.
- In the File name box, type a name for your program.
- Important: Add the correct file extension to your name. The extension tells the computer which programming language you used:
- For Python, type
hello.py - For HTML, type
mypage.html - For Batch, type
welcome.bat - For C++, type
myprogram.cpp
- For Python, type
- Click the dropdown menu that says "Text Documents (*.txt)" and select All Files (this ensures your file is not saved as a .txt file).
- Click Save.
Step 6: Run Your Program
Now you can run your program to see it work. The method depends on which language you used:
- For Batch (.bat) files: Double-click the file in your folder. A command window will open and show the result.
- For Python (.py) files: Right-click the file, select "Open with," and choose Python. If Python is installed, the program will run in a command window.
- For HTML (.html) files: Double-click the file to open it in your web browser.
- For C++ (.cpp) files: You will need a compiler program to change your code into an executable file before you can run it.
Here is a simple program you can write and run to see how Notepad works:
@echo off
echo Hello! Welcome to my program.
echo.
echo This program was written in Notepad.
pause
How to save and run this:
- Open Notepad.
- Type the four lines above exactly as shown.
- Click File → Save As.
- Name the file
myfirstprogram.bat - Make sure you select "All Files" in the file type dropdown.
- Click Save.
- Double-click
myfirstprogram.batin your folder. A black command window will open and display your message.
- Forgetting the file extension — always add
.py,.html,.bat, or.cppto the end of your filename. - Saving as a text file — always choose "All Files" in the Save As dialog so your file is not saved as a .txt file.
- Leaving brackets or parentheses open — always close every opening symbol with its matching closing symbol.
- Spelling errors — even a small mistake in your code will stop the program from running.
After you run your program, look carefully at what happens. Does the program do what you expected? If you see an error message, read it carefully — it will often tell you which line has the problem. Go back to Notepad, fix the error, save the file again, and run it once more.
In South Sudan, many small businesses and government offices use computers for daily tasks. A student who learns to write simple programs in Notepad could, for example, create a Batch file that automatically opens several programs needed for office work — such as a word processor and a spreadsheet — with a single click, saving time in a busy office in Juba or Wau. Similarly, learning HTML basics in Notepad can help students understand how simple webpages are built, which is useful for creating information sheets for schools or local markets.
Question
What is Notepad, as described in the lesson?
Sign in to submit your answer and have it count toward your mastery.
Sign in to practiceTutor
Stuck? Ask me anything about this topic.
Sign in to ask the Sonza AI Tutor about this question.
Sign in to askDiscussions
No questions yet