The previous tutorial is about Python Primitives, In this tutorial, we discuss some coding approaches in python.
Before the discussion of Coding Approaches, first you need to know, How to Get and Install Python. Follow the link below
There are three basic approaches to coding in Python. We already used one of them – the interactive Python Shell.
Coding Approaches in Python are as
1. The Shell (redux)
This is the least powerful of the three. Although you can create functions in the Shell, typically it is reserved for simple, one-line statements to get quick feedback on your code.
For example, let’s look at a simple expression. Open the Shell and run:
>>> 24 + 10
The Python Shell simply evaluated
24 + 10, adding the two numbers, and outputted the sum,
Try one more:
>>> import this
Take a minute to read the output. These are some important concepts in Python, which will help you write idiomatic Python code.
Close the Python interactive Shell. Once closed, our code is gone. In other words, the code typed into the Python Shell is not persistent – and cannot be reused. As coders, we want code that we can reuse to save precious keystrokes. Unfortunately, the Python Shell fails in this regard.
Python comes with a program named IDLE (named after Monty Python’s Eric Idle). IDLE is interactive and can be used exactly like the Python Shell. It can also be used for code reuse since we can create and save Python code. That said, IDLE still is not as powerful as the last method, so we will skip it for now.
If you are interested in using IDLE check out the excellent guide One Day of IDLE Toying.
3. Code Editor
The best approach is to use an actual coding editor. Some people prefer an Integrated Development Environment (IDE), but a far simpler code editor is much better for learning purposes.
Why? When you are learning something new you want to peel off as many layers of complexity as possible. Simplify things. By adding a complex IDE into the mix, which you will have to learn how to operate, you are just adding more and more layers, making the task – learning Python – even more difficult.