Python is more than just a programming language. It includes additional components which all work together as a holistic system. This course provides an introduction to some of these different components. Including the programming language itself. With the goal of introducing you to the Python programming language as a means of creating and controlling objects.
Learning Objectives
Upon completing this course you’ll be familiar with the basic concepts of language syntax, the python interpreter, and code blocks.
Intended Audience
This course was designed for first-time developers wanting to learn Python. Existing developers may want to skip.
Prerequisites
This is an introductory course and doesn’t require any prior programming knowledge. However, conceptual knowledge of Python objects is recommended.
In this lesson, we’ll summarize the key takeaways from this course. So that you know what’s important to know before moving forward.
Objects are used to model real world and abstract concepts. Modeling concepts with objects allows us to perform a wide variety of actions.
Objects are the building blocks of the Python runtime. Everything in Python is an object. In fact, Python provides a lot of commonly required types built into the runtime.
Common types such strings, integers, floats, and booleans are built directly into Python’s language syntax.
And the way that we as developers use these objects is through the Python programming language.
The purpose of the Python programming language is to create and control objects.
The structure of the language is referred to as syntax. Python’s syntax rules determine what is and is not valid Python code.
Python’s syntax consists of roughly 30 - 40 keywords which have special meaning. These keywords are used in conjunction with different symbols and names.
The Python language is able to create and control objects in different ways.
For example we can use the language to:
- Making decisions based on certain conditions.
- Creating objects
- Performing operations on objects
- Repeating operations
- Creating new object types
The component of the Python runtime responsible for reading Python code and interpreting the instructions is called the interpreter.
The interpreter reads through code from top to bottom and runs the instructions for each line of code. Each instruction is completed before the next one begins.
When writing code some instructions need to be grouped together. Python provides a means of grouping lines of code by using code blocks.
The purpose of a code block is to represent multiple related lines of code.
While many languages use curly brackets to define a code block, Python uses whitespace defined indentation.
The interpreter allows us to specify the whitespace character and number of them to use to represent a single level of indentation.
As the interpreter reads through code, it’s looking for the first line of code that includes whitespace. It uses the first whitespace character it encounters as the required indentation character. Then it counts how many whitespace characters exist before any non-whitespace characters. The number of characters becomes the required width for a single level of indentation.
The interpreter is very particular about indentation. Mixing whitespace characters, or adding one too many can cause syntax errors. Knowing how the interpreter determines the indentation for the code file can help to solve indentation related syntax errors.
Python’s standard indentation specifies that we use 4 spaces for each level of indentation. This isn’t a language requirement. However, I highly recommend that you follow this standard when you start writing code.
As you begin to learn the syntax of the Python language you’ll start to see how the different keywords, symbols, names, and whitespace all work together.
It’s common for first time developers to feel the need to memorize the syntax for everything as they learn. I’m going to recommend that you don’t bother. Once you know that a concept exists, you can always look up the syntax or example code.
Learning the syntax happens through hands-on use. The more code you read and write, the more the syntax will solidify.
Okay, this seems like a natural stopping point. Your key takeaways for this course should be that:
- The purpose of the Python programming language is to create and control objects
- Some of the things that the language is capable of doing include:
- Making decisions based on certain conditions.
- Creating objects
- Performing operations on objects
- Repeating operations
- Creating new object types
- The interpreter is the component in the Python runtime responsible for reading code and interpreting the instructions.
- Code blocks are related lines of code which should be run together.
- Don’t place too much focus on memorizing the syntax for everything.
- It will happen naturally over time.
That’s going to wrap up this course. Thanks so much for watching and I’ll see you in another course!
Ben Lambert is a software engineer and was previously the lead author for DevOps and Microsoft Azure training content at Cloud Academy. His courses and learning paths covered Cloud Ecosystem technologies such as DC/OS, configuration management tools, and containers. As a software engineer, Ben’s experience includes building highly available web and mobile apps. When he’s not building software, he’s hiking, camping, or creating video games.