Learning the basics of python

python basis content ①

    1. What is python?

          - A computer language, computer language into

          - high-level language: python, java, Ruby, C #, C ++ ......

          - base language: C language, assembly

          - The computer can directly execute the basis of language, but the basic language is more complex, knocking a lot of trouble codes

          - high-level language will be automatically converted into the base language, and then provided to the computer to perform.

    2. After installing python, print ( "hello world")

          -python executable file extension can be arbitrary

          - but in order to facilitate the implementation of pycharm, agreed to use commonly known as ".py" suffix

    3. The python implementation

          - Input a "python execution file path is path" in cmd

          - and a running python interpreter, enter the code and real-time execution

    4. The top of the code "#! / Usr / bin / env python" meaning

          - Tell python path location Linux system, win system to ignore

    5. Top Code "# - * - coding: utf8 - * -" meaning

          - comes encoder may not recognize Chinese, requires the interpreter to call uft8 encoder, 3.0 or later ignored

    6. How to use python simple interaction

          - Usage [Learn input output system after waiting for user feedback, and then the next line of code]

              input ( 'Please any input:')

              print ( 'Well done!')

          - Understand the assignment

              n = input ( 'I really handsome')

              print(n)

    7. A preliminary understanding of the significance of variables

          - is the value of a variable changes over time

          - variables can be made: constitute a "letter", "number", "underline"

          - Variable writing rules:

              Just how to write

              But "can not start with a number," "Do not use python keyword" "Do not repeat the python built-in"

                          The system does not recognize the impact of running python python operational impact

          - Note: Multi-word with "_" link, look professional

    8. Understand the conditional statement (I prefer the judge called the statement) "if"

          -format     

              if conditions:

                  how is it going

              else:

                  how is it going

          - Examples

              if 1==1 :

                  print('ok')

              else:

                  print('no')

          - Learn to use under many conditions "elif"

          - Learn about the statement can be nested

          - a simple example:

          n = input ( 'Enter a username')
          IF n-== 'Male':
              Print ( 'look to a photo')
          elif n-== 'beauty':
              Print ( 'micro-channel add chant')
          elif n-== 'star':
              Print ( 'sign your name to chant')
          the else:
              Print ( 'mud triumph')
          #Print ( 'Nice to meet you')    
          - [no] skip is performed with the pass

          - [to write the English grammar symbol, or a variety of error]                 

    9. Basic data types

          - String: quotation marks (English grammar under the symbol !!!)

              n = 'I'm a guy'

              n = '' I'm a guy ''

              n = '' 'I'm a guy' ''

              n = "I'm a guy."

              n = "" I'm a guy. ""

              n = "" "I'm a guy." ""

          - Three quotes indicate when the comment branches displayed

          - addition, subtraction [+ - * /]

              addition:

              a="jalskfgoas"

              b="dasfase"

              c=a+b

              print(c)                     

              jalskfgoasdasfase

              multiplication:

              = sda

              b=a*2

              print(b)                 

              sdasda

          - Digital has addition, subtraction, with no difference in a child's learning

          - numbers in () are quoted in the print, is not calculated, the output string

          - Supplementary: ** square, take the remainder%, // take quotient of the division (division calculations result rounded)

          - Example: Write the code judgment odd and even

          n=int(input('give me a number:'))

          a1=n%2

          if a1 == 0:

              print ( 'even number')
          Else:
              print ( 'odd')

          Note that the first line to indicate the n is an integer, otherwise an error.

Guess you like

Origin www.cnblogs.com/shuloulongxiu-lili/p/12342706.html