1. Home
  2. Training Library
  3. DevOps
  4. Courses
  5. Introduction to Python for Programmers

Why Choose Python?

Developed with
Trivera

The course is part of this learning path

Introduction to Python
course-steps 3 certification 1 lab-steps 3

Contents

keyboard_tab
play-arrow
Why Choose Python?
Overview
Transcript
DifficultyIntermediate
Duration55m
Students94
Ratings
4/5
star star star star star-border

Description

 In this first course we introduce the Python Language, the declaration model, and how variables and functions are used in python.

Our learning objectives for this course are to introduce the python language and to be able to recognize and explain the core concepts of the Python language.

About the Author

Students60198
Courses90
Learning paths38

Andrew is an AWS certified professional who is passionate about helping others learn how to use and gain benefit from AWS technologies. Andrew has worked for AWS and for AWS technology partners Ooyala and Adobe.  His favorite Amazon leadership principle is "Customer Obsession" as everything AWS starts with the customer. Passions around work are cycling and surfing, and having a laugh about the lessons learnt trying to launch two daughters and a few start ups. 

Covered Topics

- [Narrator] So first off, what is Python? Python is an all-purpose interpreted language. Python was created by Guido Van Rossum beginning in 1989. He was involved with the development of Amoeba, a distributed operating system. And had previously worked on ABC, a scripting language designed to be easier to learn for non-programmers. Then Rossum took ABC and improved it, added new features some of which came from other languages such as Perl and Lisp. His design goal was to serve as a second language for people who were C or C++ programmers but who had work where writing a C program was just not effective. The first public release of Python was in 1991. Python is an interpreted language. 

The Python interpreter reads a script and interprets it on the fly. And since there's no compile phase, the development cycle can be very rapid. Like Perl, Ruby and Bash, the program consists of a text file containing Python commands. To run the program, you run the interpreter, normally called Python.exe or Python et cetera, and tell it which file contains the commands. The advantages of Python are that it's clear and readable syntax. It's multi-paradigm: object-orientated programming, procedural and functional. Code can be organized into modules and packages. And has exception-based error handling. It has dynamic data structures e.g lists and dictionaries. An extensive standard library and third party modules, strong introspection capabilities and it can be extended with C and C++. The Python proramming language has rapidly become the language of choice with developers building internet based applications. 

So the first question that might be leveled at you as a developer, could be "Why is Python a good choice for our project?" You will often find Python being compared to object-orientated languages such as Java or C++, and script languages like JavaScript and Perl. All languages are unique in their use cases, benefits and suitability. But, in short, Python is more about speed to develop over speed to execute. In my opinion, it's very fast to build reasonably performing code in Python. Python programs will most likely run slower than Java programs, but they will most likely also be faster to develop. Now the difference in speed is due, in my view, to the simplicity of Python. Python's built-in high level data types and it's support for dynamic typing, make it really fast to create code blocks. A Python programmer can easily declare arguments, variables, or Python dictionary types which is a really big time saver. Dynamic typing essentially means Python is interpreting code requests as you type. To see this in action, if we define a variable A as equaling Andrew, Python automatically determines the variable type for us. So if we query this type now, we see it's returned as a string type. We then set A to equal the number 10, and repeat the same type request. See how Python has already evaluated the variable to be an integer? Now this continual behind the code preempting, means that you skip doing many of the repetitive tasks like defining variable types that is required when you are writing in Java, C, or C++. A big time saver. Run-time typing does come with a performance cost. Python's run-time must work harder than Java's. As an example, when evaluating the expression A plus B, Python must first inspect the objects A and B to find out their type which is not known at compile time. Python then invokes the appropriate addition operation which may be an overloaded, user-defined method. Java, on the other hand, can perform an efficient integer or floating point addition. But it does require variable declarations for A and B, and it does not easily allow for overloading of the plus operator with instances of user-defined classes. Now JavaScript is very fast as well, and a very popular choice for low level applications. 

So how do JavaScript and Python differ? Well, Python supports a programming style that uses simple functions and variables without engaging in class definitions like JavaScript. Python has better code reuse through a true object-orientated programming style, where classes and inheritance play an important role. So Python is a better choice when writing large or more complex programs over JavaScript. Python and Perl both emerged from UNIX scripting and so they share many features. So what's the difference, and when should I use one over the other? In short, Perl excels in support for common application-orientated tasks. It provides built-in regular expressions, file scanning, and report generating features, for example, which really helps with application builds. Python excels in support for common programming methodologies, such as data structure design, and object-oriented programming. And that encourages programmers to keep it simple, and write readable code. 

Now that's not a small consideration at all. The biggest issue you will find, as the complexity of your application grows, is avoiding uncommented hex, exceptions, and the inevitable code spaghetti that comes from trying to reuse things that weren't designed to be reused. Object-orientation with Perl can become a real bottleneck as you try to reuse components. Whereas, with Python, Python makes that simple. And this is where your love for Python tends to start. Python is well suited as a glue language. Python can work very well with other languages. Components can be developed in Java, and combined to form applications in Python. Python can also be used to prototype components until the design can be hardened into a Java implementation.