Introduction to Python (1) Python overview and environment construction

Author: Xiou

1 Overview

Python is a high-level scripting language that combines interpretability, compilation, interactivity, and object-oriented.

Python is designed to be highly readable. Compared with other languages, it often uses English keywords and some punctuation marks in other languages. It has more distinctive grammatical structures than other languages.

Python is an interpreted language: this means that there is no compilation part of the development process. Similar to PHP and Perl languages.

Python is an interactive language: this means that you can execute code directly after a Python prompt >>>.

Python is an object-oriented language: This means that Python supports an object-oriented style or programming technique in which code is encapsulated in objects.

Python is a beginner's language: Python is a great language for beginning programmers, supporting a wide range of application development, from simple word processing to WWW browsers to games.

Let's briefly understand what we are going to do, we will run our first program - hello_world.py. To do this, we first need to check that we have a newer version of Python installed on our computer.

If not, install it. You'll also install a text editor for writing and running Python programs. As you type Python code, this text editor recognizes them and highlights the different parts, allowing you to easily understand the structure of the code.

Version 1.1 and download

Every programming language is constantly evolving with the introduction of new concepts and technologies, and Python developers are always working to enrich and enhance its functions.

We are using the latest version of Python 3.11, but as long as we have installed Python 3.11 or higher, the reference code we will use later can run.

Python's latest source code, binary documents, news information, etc. can be viewed on Python's official website:

Python official website: https://www.python.org/

You can also download Python documentation at the link below, you can download documentation in HTML, PDF, and PostScript formats.

Python document download address: https://www.python.org/doc/

insert image description here

1.2 Features of Python

1. Easy to learn: Python has relatively few keywords, simple structure, and a well-defined syntax, making it easier to learn.

2. Ease of reading: Python code is more clearly defined.

3. Easy to maintain: Python's success lies in its source code is quite easy to maintain.

4. An extensive standard library: One of Python's greatest strengths is its rich library, cross-platform, and compatible with UNIX, Windows, and Macintosh.

5. Interactive mode: Supported by interactive mode, you can input the language to execute the code and get the result from the terminal, and interactively test and debug code fragments.

6. Portability: Based on its open source nature, Python has been ported (that is, made to work) to many platforms.

7. Extensible: If you need a key piece of code that runs quickly, or want to write some algorithms that you don't want to open, you can use C or C++ to complete that part of the program, and then call it from your Python program.

8. Database: Python provides interfaces to all major commercial databases.

9. GUI programming: Python supports GUI can be created and ported to many system calls.

10. Embeddable: You can embed Python into C/C++ programs, allowing users of your programs to obtain "scripting" capabilities.

2. Environment construction

Refer to the link below:

Python environment construction

Integrated Development Environment (IDE: Integrated Development Environment): PyCharm is a Python IDE created by JetBrains, which supports macOS, Windows, and Linux systems.

PyCharm functions: debugging, syntax highlighting, project management, code jump, smart prompt, auto-completion, unit testing, version control...

PyCharm download address: https://www.jetbrains.com/pycharm/download/

PyCharm installation address: http://www.runoob.com/w3cnote/pycharm-windows-install.html

3. The first program "hello, world"

Open PyCharm and create a new project:
insert image description here

As shown in the figure: a blank editing area appears.

Income example code:

print("hello,world")

insert image description here

The output result is shown in the figure.

4. Possible problems

If you can't run the program hello_world.py, you can try the following solutions. These general methods are applicable to all programming problems.

▲ When there is a serious error in the program, Python will display traceback, that is, an error report. Python pored over the file, trying to figure out what's wrong with it. The trackback may provide clues as to what is wrong with the program.

▲ Step away from the computer and take a break before trying again. Don't forget that syntax is very important in programming, and even one missing colon, mismatched quotes, or mismatched parentheses can cause the program to not run correctly. Please read the relevant content of this chapter again, and re-examine the code you have written to see if you can find errors.

▲ Tear down and start over. You probably don't need to uninstall any software, but it might be reasonable to delete the file hello_world.py and recreate it.

▲ Have someone else repeat the steps in this chapter on your computer or another computer, and watch carefully. You may have missed a small step that someone else just happened not to miss.

▲ Ask someone who knows Python to help. When you think about it, you may find that you know someone who uses Python.

Guess you like

Origin blog.csdn.net/qq_41600018/article/details/130450411