Build a Python environment | Python, PyCharm

computer

What computers can do:

  1. arithmetic operation
  2. logical judgment
  3. data storage
  4. Telecommunication
  5. ...more and more complex tasks

All of the following may be referred to as "computers":

insert image description here

A computer is mainly composed of the following important components

  1. CPU central processing unit : brain, arithmetic operation, logical judgment

  2. Storage : (internal memory, external storage) to store data

    • The difference between memory and external storage (hard disk, etc.):
      1. The storage space of the internal memory is small, and the storage space of the external storage is large.
      2. The access speed of the internal memory is fast, but the access speed of the external storage is slow.
      3. The memory is more expensive than the external storage
      . 4. The data on the internal memory is easy to lose (the data is lost when the power is turned off), and the data on the external memory can be stored persistently (the data is also there when the power is off)

    (Compared to memory, it can be stored for a longer period of time~ Generally, mechanical hard disks store data for a few years to more than ten years~)

  3. Input devices : keyboard, mouse, microphone

  4. Output devices : monitors, speakers, headphones, printers

    Some devices are both input devices and output devices
    touch screen ~ network card

PS: CPU is the pinnacle of human science and technology at present, and its technological content can be compared with CPU. Only the hydrogen bomb has
restricted the export of "chips" to China by the United States. The chip here mainly refers to CPU. Although the country has the ability to independently develop CPU , but the overall level, compared with the international first-line Intel, AMD and other manufacturers, there is still a certain gap

PSS: In fact, a graphics card (GPU) is a computing chip similar to a CPU, and
a CPU is a "universal computing chip" that can handle various problems in various scenarios, just like students trained in colleges and universities, who can contribute to various industries and fields

GPU is a "special-purpose computing chip", which is particularly good at processing floating-point calculations, just like students trained by computers, focusing on Internet software technology

The above composition structure is called "Von Neumann architecture". Von Neumann is the father of computer

In addition to being the grandfather of computers, Von Neumann is also a mathematician, physicist, chemist, founder of "Game Theory", and participated in the Manhattan Project (as an atomic bomb manufacturing consultant). According to rumors, Von
Neumann The big brother mentally calculated eight-digit division at the age of six, mastered calculus at the age of eight, read through the history of the world at the age of ten, and published his first paper on mathematics at the age of seventeen
. Bit Turing boss, also played a vital role in World War II


programming

A computer needs a body endowed by hardware and a soul endowed by software

"Software" (or called a program), instructs the computer to follow what rules to perform tasks

Making software is to clarify what kind of tasks the software should accomplish. The process of making software is called "software development", or it can also be called "programming".

Programming is actually a more rigorous and complicated matter, so a profession dedicated to programming has been derived, that is, programmers

In the process of programming, programmers need to use a special way to communicate with the computer, which is the "programming language", and Python is an important member of the programming language!

The specific process of writing software using a programming language is called "software development", commonly known as "knocking code"

What are the programming languages

Programming languages ​​can be roughly divided into three categories

  • machine language
  • Assembly language
  • high level language

Among them, machine language and assembly language are closer to computers, and it is not easy for humans to understand.
Therefore, the programming languages ​​used by programmers are mainly high-level languages.

There are many types of high-level languages, and the following are the programming languages ​​commonly used in actual development

insert image description here


Python background knowledge

1、Python

Guido van Rossum (Guido van Rossum) is a Dutch programmer (known as Uncle Turtle, the first three letters of his name are Gui)

insert image description here

At Christmas in 1989 (33 years old at the time), Uncle Turtle started the development of Python because he was bored at home and passed the time. The
first official version was released in 1991.
1991 is a magical year
. Python, the World Wide Web , Linux, Vim, Qt, the first laptop, all born in 1991

2. What can Python do?

After years of development, Python is currently a programming language with a very wide range of application scenarios

  • Scientific Computing & Data Analysis
  • Web development (building a website)
  • Automated operation and maintenance
  • artificial intelligence
  • Crawler
  • automated test

insert image description here

3. Advantages and disadvantages of Python

advantage:

  • Concise and concise grammar, easy to use
  • Powerful and versatile
  • Rich ecology, with a large number of mature third-party libraries
  • It is convenient to call the code written in C/C++ for high-performance/system-level operation

shortcoming:

  • Execution efficiency is relatively weak
  • Weak support for multi-core concurrent programs
  • The dynamic type system is not very friendly for large projects

4. The prospect of Python (Qian Jing)?

Although there are many application scenarios for Python, it is relatively rare to find jobs that use Python purely

More often, Python is used as an auxiliary language

At work, Python is more like a tool. When you need it, you can pick it up and use it. It can solve many problems conveniently
. This is like a game of King of Glory.


Build a Python environment

If you want to be able to develop Python, you need to build a Python environment.
The environment that needs to be installed is mainly two parts:

  • Operating environment: Python
  • Development environment: PyCharm

1. Install Python

Supplement about Python version

The Python version currently in mainstream use is the Python 3 series, but in the future, in the company, when you come into contact with some older projects, you may still be using Python 2. There is still a
big difference in syntax between the 3 series and the 2 series. The learning content is mainly based on the Python 3 series

Note: It is best to check the "Add Python 3.10 to PATH" option
to remember the installation directory of Python (which may be used later)

insert image description here

The most critical of these is this python.exe, and the subsequent running of the Python program depends entirely on this python.exe

insert image description here

If you double-click the python.exe directly, it will open the Python interactive interpreter (console program). In this interactive interpreter, you can enter the Python code. Directly enter
the code print('hello') and press Press the enter key, and the result of hello will be printed


2. Install PyCharm

Although the Python code can be executed through the interactive interpreter, it is not convenient to write the code, and more professional development tools are needed to write the Python code.
Currently, the Python development tools commonly used in the industry mainly include the following options

insert image description here

The most mainstream development tools are PyCharm and VS Code

PyCharm

PS: JetBrains is an Internet company in the Czech Republic. Its main business is to develop programming tools. Ideas like Java IDEA, C++ CLion, Python PyCharm, Go Land, etc. are all made by JetBrains, and these tools are very powerful. , is deeply loved by the majority of programmers, so netizens also affectionately call these development tools "JB Family Bucket"

Click on the location circled by the box to download

insert image description here

PS: There are three versions of PyCharm

  • Professional Edition

  • Community Edition

  • Educational Edition

Compared with the community version, the professional version has more functions, but the professional version is charged, and the community version is free (obviously for free). The education version has the same
functions as the professional version, but you need to go to the JB official website to apply with your edu mailbox

It is recommended to check this option, so that if you right-click any directory, you can directly open the directory with PyCharm

insert image description here


3. Run hello world

1. Create a project and select the location of the project

insert image description here

2. Associate the Python interpreter:

insert image description here

Note that under normal circumstances, PyCharm can automatically recognize the location of the Python interpreter, but if it is not automatically recognized, it does not
matter, click on the right... and select the path location of the previously installed Python

3. Right-click the project directory on the left and select New -> Python File

insert image description here

4. Run: Ctrl+Shift+F10

insert image description here


4. Make basic settings

set font size

PyCharm's default font is relatively small, it looks very eye-catching, you can set it larger
Select File -> Settings

insert image description here

Find Editor -> Font, and adjust the font Size and Line height appropriately

Size indicates the font size, the larger the number, the larger the text
Line height indicates the line height, the larger the number, the greater the space between two lines of text

insert image description here

set background image

insert image description here


Guess you like

Origin blog.csdn.net/qq_56884023/article/details/132253646