Home > Courses > Python > Introduction to Python

How to start with python programming

Last updated : December 13, 2020

What is Python?

Python is a high-level programming language. It is simple to read and easy to understand, making it easy to develop applications rapidly. If you are new to programming, Python is a great language to start. Pythons' shallow learning curve enables many programmers new to Python to get started with new projects with the least amount of time spent learning. Like SQL, Python code is similar to the English language. That makes it easy for us to understand, but not for the computer platforms that we use. Therefore, English like Python code we write should be translated into an intermediate language that machines can understand. This is called interpretation and is done by the Python interpreter, commonly known as a compiler.

Python is cross-platform independent, which makes creating applications with Python much productive. Python can be used to create a variety of applications, such as Web Applications, games, Machine Learning, Artificial Intelligence, Data Science, Desktop apps, and Web Scraping applications.

History of Python

Python was created in the 1980s by Guido van Rossum. Python's design philosophy emphasizes code readability and simplicity. Python consists of best practices from several other languages such as ABC, Modula-3, C, and C++.

Why learn Python?

Python is a platform-independent scripting language, which is easy to read and understand. Its syntax is similar to English and has less syntax and complexity compared to other high-level languages.

Python is a good entry point for people who are new to programming.

Advantages of Python

  • Python is a Beginner's Language, English like and has a simple syntax
  • Python supports both functional and object-oriented programming
  • Python is an interpreted language. Python code is interpreted and executed at runtime by the interpreter. It also can be compiled to byte code to build large scale applications
  • It can be integrated with other programming languages with the least effort
  • It supports lifecycle methods such as automatic garbage collection
  • Python supports GUI applications that can be ported into different platforms

Installing the Python interpreter

Before we write our first line of Python code, we have to have the Python compiler installed on our working platform.

To install the compiler, visit https://www.python.org/downloads and download the recommended compiler version. See the header section of the page to download the recommended version.

Installation is straight forward, no different than any other app installation. Make sure to set the PATH variable during the installation process. Once the installation is complete, open the python shell. In windows, type IDLE in the search text box and press enter. This will open your Python shell. You are ready to code in Python.

Python Idle console
Figure 1 : Python Idle console

Writing some basic Python commands

Python shell behaves similarly to the windows command line. It interacts with the user by responding to each command input, meaning one command at a time. Below are some sample commands you can issue to shell to get yourself familiar with Python syntax.

>>> import sys
>>> sys.version
'3.8.6 (tags/v3.8.6:db45529, Sep 23 2020, 15:52:53) [MSC v.1927 64 bit (AMD64)]'
>>> sys.version_info
sys.version_info(major=3, minor=8, micro=6, releaselevel='final', serial=0)
>>> 5.0*2.0
10.0
>>> (4.0**0.5)**0.5
1.4142135623730951
>>> var1=24.5
>>> var2=17.5
>>> var1
24.5
>>> var2
17.5
>>> var1+var2
42.0

As you may have noticed, the Python shell is helpful to test out some commands. But it cannot offer anything useful for us to use in the real-world production environment. Once the Python shell window is closed, all the statements you issued will be wiped out.

To develop a reusable application, we have to save the Python code on a file and execute it as needed. We will use this approach as our code gets longer and complex.

In the next chapter, we will learn about Python variables and data types.

Lance
By: Lance
Lance is a software engineer with over 15 years of experience in full-stack software development.
Read more...

Leave a comment

No Comments