18.09.2017 19:47

Getting Started With Python

Author: Elliot Forbes | @Elliot_F

This tutorial uses Python version 3.6

Introduction

In this course we’ll be taking a look at the absolute basics of the Python programming language and cover everything you need to get up and running creating your own basic Python programs.

The full text version of this course can be found by clicking on the Python Programming Course card on the homepage of my site.

Installing Python

Let’s dive in. So before we can get started working with the Python programming language you’ll first need to install the latest version of Python onto your local development machine. For the purpose of this video series we shall be using version 3.6.2.

Navigate to the downloads page of www.python.org and download the appropriate version now.

Once you’ve successfully installed Python you should then be able to call ‘python’ from a terminal on your development machine. As I have multiple versions of Python installed on my local machine I’ve installed it as python3.6 but if this is your first time using the language then you may only have to call python.

Execute the python command now. This should open up Python’s interactive shell which allows you to quickly get up and running writing very small Python programs.

Our First Program

To get us started and give us a feel for the language we are going to create a customary Hello World program that simply prints out hello world to the console. With python we can do this in one line of code. Type print(‘Hello World’) and then press enter.

Your console should look something like this:

 $ python3.6
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print('Hello World')
Hello World

When we press enter after writing this line of code python’s interactive shell will then read this and try to execute it to the best of its abilities. If everything has gone to plan then you should see Hello World successfully printed out below.

Conclusion

Congratulations, you have embarked on your first step towards becoming a Python programmer and have successfully written and executed your first Python program.

In the next tutorial we’ll be looking at how you can define functions and work with variables in Python and start to craft more complex and larger programs.

Next Tutorial in Series - Functions and Variables in Python

See A Problem?

See something wrong with this page? Feel free to submit a pull request and help improve the development community!

Github