Python: Introducing Python

This is part of my Python & Django Series which can be found here including information on how to download all the source code.

What Is Python?

Python is a high level, dynamically typed and interpreted language. It was created by Guido van Rossum between 1985 and 1990. It is available under the GNU General Public License (GPL)

It is Multi-paradigm:

It has a very large and extensive library, called the standard library, and it also ships with an interactive command line which allows developers to run, poke and test code!

Python has grown in popularity over the years and is today highly regarded as a general purpose programming language. It is used for application development, install/maintenance scripts, OpenStack, REST web services and web development.

You can read more about Python on Wikipedia or at Python.org

The Environment

Python comes pre-installed on Linux, BSD and BSD Copies dig. If you are running Windows or perhaps would like to upgrade to a later version you can download installers here..

Python can be coded in any text editor or a dedicated IDE. There are many choices available though I personally use and recommend PyCharm. There is a free community edition which will provide enough functionality for learning the basics of the language.

Features include:

  • Running code directly from the IDE
  • Interactive Python command line
  • Terminal
  • Terminal output
  • Code completion
  • Code highlighting
  • Refactoring
  • Code navigation

API reference and more information on Python can be found at Python.Org Docs.

Hello World

Python is a lot of fun and very simple to start coding in; unlike C#, C++ or Java a Hello World Program can be written in one line!

Code:

print("Really? Surely you can think of something better than a Hello World program?")

Variables

Python is dynamic, you don’t need to define the data type when creating a variable. Simply the name of the variable along with the assignment of the data. Python will work out the best data type for the data before creating it in memory . Upon changing the data, if a new data type is required, Python will automatically change the type for you!

Code:

value = "No I cannot, that is why I am a programmer"
print(type(value))

value = 1
print(type(value))

value = True
print(type(value))

Output:

<class 'str'>
<class 'int'>
<class 'bool'>

Data Types

Python aims to be a language which is easy and quick to learn and use. This becomes apparent when looking at the basic data types, which are kept at a minimum.

Basic Type Description Example
str Textual data aString = “Hello”
bool True or False aBool = True
int Integrals anInt = 1
float Floating point numbers aFloat = 1.0
decimal Deciamal numbers aDecimal = Decimal(1.0)
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s