English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python Basic Tutorial

Python Flow Control

Python Functions

Python Data Types

Python File Operations

Python Objects and Classes

Python Date and Time

Advanced Knowledge of Python

Python Reference Manual

Introduction to Python

Python is a cross-platform computer programming language. It is an object-oriented dynamic typing language, originally designed for writing automation scripts (shell scripts). With the continuous updates of the language and the addition of new language features, it is increasingly used for the development of independent and large projects.

What is Python?

Python is a popular programming language. It was created by Guido van Rossum in1991Year created.

It is used for:

  • Web development (server-side)

  • Software development

  • Mathematics

  • System scripts

What can Python do?

  • Python can be used on servers to create web applications.

  • Python can be used with software to create workflows.

  • Python can connect to database systems. It can also read and modify files.

  • Python can be used to handle big data and perform complex mathematical operations.

  • Python can be used for rapid prototyping or for production software development.

Why Python?

  • Python can run on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.).

  • Python has a simple syntax similar to English.

  • Python's syntax allows developers to write fewer lines than other programming languages.

  • Python runs on an interpreter system, which means that code can be executed immediately after writing. This means that prototyping can be done very quickly.

  • Python can be processed in a procedural, object-oriented, or functional manner.

The functions of Python

  • Easy to learn -Python has very few keywords, a simple structure, and clearly defined syntax.

  • Easy to maintain -Python's source code is very easy to maintain.

  • Extensive standard library -Most of Python's libraries have high portability and cross-platform compatibility on UNIX, Windows, and Mac.

  • Interactive mode -Python supports interactive mode, which allows for interactive testing and debugging of code snippets.

  • Portable -Python can run on various hardware platforms and has the same interface on all platforms.

  • Extensible -You can add low-level modules to the Python interpreter. These modules enable programmers to add or customize their tools, thereby improving efficiency.

  • Database -Python provides interfaces to all major commercial databases.

  • GUI programming -Python supports GUI applications that can be created and ported to many system calls, libraries, and Windows systems (such as Windows MFC, Macintosh, and Unix's X Window system).

Python installation

Many PCs have already installed Python.

To check if you have installed Python, open the terminal and type:

  python --version

If Python is not installed on the computer, it can be downloaded for free from the following website:https://www.python.org/

Python quick start

Python is an interpreted programming language, which means that as a developer, you need to write Python() files in a text editor with the .py extension, and then place these files in the Python interpreter to execute them.

The way to run a Python file in the command line is as follows:

  python helloworld.py

either

  ./helloworld.py

Python command line

To test a small amount of code in Python, sometimes the quickest and simplest method is not to write the code into a file. This can be done because Python itself can be run as a command line. Enter python in your terminal:

  python

From there you can write any Python code:

  Python 3.6.6rc1+ (default, Jun 22 2018, 08:07:48) 
  [GCC 8.1.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>>

It says "Hello, World!" in the command line:

  Python 3.6.6rc1+ (default, Jun 22 2018, 08:07:48) 
  [GCC 8.1.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>>print("Hello, World!")
  
  Hello, World!

After completing the operation in the python command line, just type the following content to exit the python command line interface:

exit()