Thought4Code: HelloWorld

Code is a powerful tool. It powers the modern world. If you have a computer, you have access to code. Code can change the world!

Getting Started

I wondered what it would be like to run my first program after reading the lines of code from a paper book. It is a rite of passage to create a program which produces the following text. The language this ritual is performed in changes with the times. Today we will use Python.

Running Commands

Install a Python interpreter directly onto your machine

Once the Python interpreter is installed open a terminal (Mac) or cmd prompt (Windows). Type python and hit Enter . You are now in a Python interpreter!

You should then see a prompt similar to

Python 3.8.2 (default, Jun  8 2021, 11:59:35)
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

It is possible to then run commands at the prompt!

Try to print some text by running

>>>print("Hello World")

Congrats you can run code!

Note: You should be using Python3 by now :)

Writing Code

Note: the following commands are for terminal on Mac (sorry Windows)

Create a project directory from the terminal with

mkdir python_hello

Enter into the new directory with cd python_hello .

Create a new file called hello.py by running

touch hello.py

Add the following contents to the file using a text editor of choice

print("Hello World")

You can then run this code with python hello.py .

The text "Hello World" should be printed to the screen. It takes many transistors to make this work! The electrical engineer knows this, the programmer takes it for granted nowadays. This is always how society progresses.

But it is nice that it is as simple as that to get started.

Congrats on writing your first line of code!

Remeber it is never a bad idea to ask for

>>>help()

The only way to learn to code is by reading and writing it!