Lola vs. python D01: the basics of python entry

01.python introduction

  • Origin: 1989, Uncle Turtle

  • Features: simple entry, concise grammar , does not pay attention to complex grammar, derived from C language

  • Current popular languages: java, c, python, java script, go (new language from Google)

  • Application scope: scientific computing, artificial intelligence, website development, big data, cloud computing...

  • Bottleneck: Python is interpreted and executed, with low performance

  • Version compatibility: currently mainly 2 and 3, the gap is large, beginners must start with python3

  • Interpreter: cpython is the most commonly used interpreter based on C language

02.Getting started with python development

install software

  • windows environment variable problem
    picture display

Development environment

IDE (integrated development environment)

  • Don't worry about which development environment, the core is the same
  • The development environment IDE is just a plug-in of the interpreter , just to reduce the error rate, especially writing errors

Operation command

  • python enter the python editor
  • **>>>** Prompt (English)
  • ctrl+Z close the interactive window
  • ctrl+C interrupt program execution
  • run/F5 Run the program

Insert picture description here

Precautions

  • Spaces are also characters, don’t use them randomly
  • All characters are input in English

Basic program format

1. Appropriate spaces and indentation issues
(1) The statement starts from the first column of the new line
(2) The blank at the beginning of the logical line (spaces and tabs) is used to determine the indentation level of the logical line, which is used to determine the statement Grouping.
(3) Uniform indentation style: each indentation level (one tab/four spaces); Python uses indentation instead of {} to indicate program blocks
2. Python is case-sensitive
3. Comments: Line comments plus #; paragraph Comment ('''''')

Programmer training manual

The objective law of learning:

  1. Shou break away
    Shou: Respect the teacher and knowledge
  2. Establish a system first, focus on the big and let go of the small, and put things first
  3. The solution to the problem:

Graphical programming

Turtle turtle drawing
focuses on the teacher's programming ideas

Program structure

Python is composed of modules. The creation and execution of python files
are executed sequentially
: ctrl+s! ! !
Usually a "four spaces" means one indentation, tab key to
# use # comment, the comment is a good habit
\ line connector

Object

  • In python, everything is an object, and each object consists of:Identification, type type, value composition
  • The essence of the object: a memory block with a specific value and supporting specific types of related operations. Similar to large and small parking spaces, with parking number and parking type
  • The meaning of a=3, identifying id (memory address), type int, value 3

Insert picture description here

Quote

  • Objects are in the heap, variables are in the stack
  • Variables do not need to display the declared type. According to the object referenced by the variable, the python interpreter automatically determines the data type
  • Each object has a data type, and only supports operations supported by that type
    Insert picture description here

Identifier

  • Identifier: Used for names of variables, functions, classes, modules, etc.
  • Identifier rules:
    -* is case-sensitive,
    -* must start with a letter or underscore, followed by letters, numbers, and underscores
    -* no keywords can be used
    -* try to avoid the beginning or end of a double dash
  • python help document F1

Insert picture description here

Variable declaration and assignment

  • Variables must be initialized (assigned first) before being used
  • Delete variables and garbage collection: del a; the object is not referenced by garbage collection

Guess you like

Origin blog.csdn.net/Lolalalalala/article/details/109224664