Introduction
Getting started
Installing python
Installing an IDE
Creating files
The print function
Strings in python
Conclusion
Introduction
Newbie technical writers often question whether they need to understand programming for them to have successful writing careers.
As a technical writer, you’ll be working with various tech professionals. Therefore, you’ll have to document the programs/products they make, and having coding skills will make your work easier.
Perhaps you are now asking yourself which programming language you should start with. Honestly, any language is better depending on the industry you’ll be working in. However, if you plan to work with:
Data engineers
Software engineers
Machine learning developers
Artificial intelligence developers
then, learning Python will be a better choice for you.
What is Python?
This is an easy-to-learn programming language that has many paradigms. Furthermore, it supports many open-source libraries, therefore making it widely used in many professions.
Why should you learn Python?
Earlier on, I told you that as a technical writer, you’ll be working with many tech professionals. Therefore, you must understand the basics of what you’ll be working on.
Learning Python as a first language will also help you understand many programming basics, and if you plan to switch to another language, then the transition will be smooth, as most of these languages share most of the syntaxes.
As a programming novice, this article will teach you how to install Python and an IDE. Furthermore, it'll teach you how to write your first Python script. Therefore, let’s dive right in.
Getting started
Installing Python
Two versions of Python exist: python2 and python3. In this tutorial, I'll be using the Python 3 version.
Windows
Most windows pcs don’t come with Python installed. Therefore, you’ll need to install it manually. To do so, head over to Python and download the latest version of Python 3. Install it on your machine.
To check if it’s installed, open the command prompt, and run the following command:
python --version
And you should see something like this:
As you can see, I have Python 3.11.3 installed, which is the latest version as I write this.
Linux and macOS
If you are on Linux or macOS, then you need to check the version of Python that is installed.
Run the following command on the terminal:
python3 --version
This should show the version that is installed, like this on Linux:
As you can see, I have version 3.11.2, which is not the latest now. If you have a version lower than this, you'll need to update it.
Check this article upgrade python and follow the steps shown there.
Installing an IDE
An IDE refers to an integrated developer environment. It’s a special text editor, that allows you to write scripts of any programming language, and run/execute them successfully, without much hassle.
There are many IDEs out there, but the common ones for Python are:
Visual Studio Code
PyCharm
In this tutorial, I’ll be using PyCharm. Therefore, to install it, head over to PyCharm and scroll down to the part that shows the professional and community versions. Download the community version.
Then install it and leave everything as default. Once you open it, you’ll see something like this.
Select new project and it should create a new Python project.
Creating files and saving them
Since you’ll be writing a hello program, click on the menu bar as highlighted below:
and select file, new, python file, and name it hello. PyCharm automatically saves the file as hello.py, but for other editors, you’ll have to specify the file extension example hello.py or hello.txt.
Now you have the file, therefore it’s time you write your first Python script.
Write this on the hello file:
print('Hello World!')
and right-click on the file and select run hello. It should open a terminal, and output something like this:
Print function
Functions in Python provide code that is organized and easily reusable. There are various in-built functions in Python like print(), input(), and len(), but this is a topic for another day.
The print function allows you to print something on the terminal. Therefore, on your script, it allows you to print hello world.
Strings
Data types are variables that determine what values you’ll assign them, and the operations you can perform on them. In Python, there exist various data types, like strings, integers, and Boolean.
String datatypes, allow you to work with sequences of characters like letters, and punctuation marks. To declare a string data type, you use single or double quotes like this:
name = 'John Smith'
home = "Nakuru"
Both of these variables are strings datatypes, similar to the string in your script.
Therefore, the Python script will print the message on the terminal.
Conclusion
Congratulations! You have written your first Python program. We have covered installing Python in various OS, installing an IDE, and Python functions and string data types.
Remember, you'll need to learn more about Python if you want to have a successful career as a technical writer and as you learn, you'll appreciate how work becomes easier for you.