“This is the second day of my participation in the Gwen Challenge in November. See details: The Last Gwen Challenge in 2021”

Write at the front 👀

There is an old saying called “Life is hard, I use Python” 🌝 Python has become one of the most popular programming languages in the world in recent years 🌍 Python is really friendly to beginners like me. Here is the basic use and syntax of Python3 🤞

Python3 download and install

  1. You can skip to Thonny because it comes with a python3.7 interpreter and doesn’t need another one of your own.
  2. Official Download link
  3. Rule over all kinds of hand parties(This version is:3.8.10 win - 64)
  4. After the installation is complete, find the installation package, click Modify, and Add Python to Environment Variables. This allows you to run Python on an environment such as CMD. Other check box no special requirements can not point, directly next.

Choose an editor for your Python

1. Pycharm

PyCharm was developed by renowned software development company JetBrains. Like the development of artificial intelligence and machine learning, it is the first choice for programmers. Powerful, support web development, provide intelligent code function, can be more accurate and quick bug repair, support remote development. However, the interface is a little complicated, and the professional version is charged (you can also get a one-year free trial through the education mailbox or xuexin website, the author is currently applying). There is no special requirement that the community version is enough. Pycharm

2.VSCode

VSCcode developed by Microsoft, plug-ins rich, powerful, shortcut practical, remote development free, support a variety of languages, is considered by many programmers the best IDE editor. (I currently use it as the main) VSCode download address

3.Thonny

Thonny is considered a Python IDE for beginners, developed by the University of Tartu. Simple interface, not too many complex functions, easy to use. Thonny download address

  • Since its installation package is on GitHub, the download will be slow or even impossible to open.
  • If you, like me, can’t download, you can try PIP
  1. Open the CMDWin +R Enter CMD and press Enter
  2. The inputpip install thonnyenter
  3. If it’s still slow, you can use the mirror source, and then click through like an accelerator.
  • Input:pip install thonny -i https://mirrors.aliyun.com/pypi/simple/
  • I have been down here.

  • But Thonny under PIP has no desktop icon. Opening mode:Win +R Enter Thonny and press EnterOr in theControl panel address barThat’s the direct inputThonny

Try interacting with Python 👏

  • Open CMD and typepythonAnd hit enter, see>>>The interface is displayed successfully.
  • Try to enterPrint (' Stubborn horn ')And press enter.
  • ctrl+ZExit the interaction,>>>Disappear indicates successful exit.
  • If you are not familiar with command line operations, you can check out the following article 👇

Summary of CMD Common Commands Windows Users need to know – Zhihu (zhihu.com)

  • You can see that the Python version is Win3.8.10

4. Python syntax features

1. Code format

  1. No special rules, use UTF-8 encoding
  2. Python features: UseThe indentationTo represent a block of code without curly braces{}And the semicolon;
  • It is best to represent an indent with four Spaces (although the number of indent Spaces is variable, statements in the same code block must contain the same number of indent Spaces)
  • So Python is very useful for developing code specifications

2, comments,

  1. #Represents a single line comment
  2. ' ' 'or"" "Represents a multi-line comment
  3. Note in the word editor will not read, usually write code to develop the habit of writing notes, convenient for themselves and others to read the code, because to the future real development to write tens of thousands of code, they do not know what is.

3. Identifier

  1. The first characterMust be a letter or underscore _.
  2. The rest is made up ofThe letter,digitalandThe underscore _Composition.
  3. rightcaseSensitive. (For example, Lzh and Lzh are two different identifiers)
  4. Can’t!The keyword(for, while, if) as an identifier. Here is the Python keyword 👇
  • There is no need to define variable data types in Python, which is why it has fewer keywords.

4, statements,

  1. It is usually one statement per line, but backslashes can be used if the statement is too long\Represents a multi-line statement.

2. If a list, dictionary, or tuple has multiple lines in [], {}, or (), do not use a backslash\They are separated by commas as shown below

3. Use a semicolon (;) between multiple statements in the same line;Segmentation (distinguish C, C language is used, segmentation) as shown below:

5, a blank line

  • Unlike indentation, blank lines are not part of Python syntax. Write without inserting blank lines and run without error. However, blank lines are used to separate two pieces of code with different functions or meanings for future maintenance or refactoring. (The layman’s point is to make the code more readable and less crowded.)
  • Blank lines are also part of the program code.

6. Print ()

  • Unlike Python2,Python3In theprintThe default output is newline. To implement non-newline, add to the end of the variableend=""See the picture below:

  • withoutend=""There are no newlines in the multiplication table

  • addedend=""The multiplication table breaks

7, input(

  • Wait for user input, press Enter and exit.
  • Input () is a string, and it converts you to a string even if you type a number.
  • A plus sign+Connecting and seamless, comma.There’s also a link but there’s a space in between.
  • type()You can view data types

8. Other points to pay attention to ✨

  1. Punctuation must be in English, otherwise it will report errors.
  2. Write code to pay attention to the above mentioned specifications, more space and indentation, remember line breaks, multi-marked comments.

Write in the back

  • Thanks for watching 💕
  • Author ability is insufficient, welcome big guy to point out or supplement.