Basic understanding of Python

1. Computer Basics

  • CPU: the human brain, computing deal
  • Memory: temporary storage of data, data breakpoints will disappear, fast data storage
  • Hard: permanent storage of various data with respect to the slower memory storage
  • OS: is essentially a software for controlling data transfer between various hardware and interacting with a computer

2. Python applications and history

  • Python is the founder Guido. Fanluosumu (Guido van Rossum). During Christmas 1989, in Amsterdam turtle t to pass the time, the amount determined to develop a new script interpreter, as a succession of ABC language . (turtle t: 2005 Columbia Valley to join in 2012, in 2013 to join Dropbox until now, still holds the Python core development direction, is called benevolent dictator)
  • The main areas of python
    • Cloud computing: cloud computing the hottest language, typical use OpenStack
    • Web Development: Web development framework based on Python a lot, such as Django, Tornado, Flask and so development speed, low learning curve, can help build up quickly available WEB service.
    • Scientific computing, artificial intelligence: With the development NumPy, SciPy, Matplotlib, Enthoughlibrars and many other libraries, Python more suited to do scientific calculations, draw high-quality 2D and 3D images and scientific computing of the most popular commercial. compared software Matlab, Python is a general-purpose programming language, application scripting language than Matlab adopted a broader, more library support Although Matlab many advanced features and toolbox is still no substitute , but there are still a lot of work in the daily research and development can do it with a python
    • Automated operation and maintenance: This is the preferred operation and maintenance division programming language, Python has gained recognition in the operation and maintenance aspects of automation, such as Saltstack and Ansible are famous automation platform
    • Web Crawler: Also known as spiders, is to obtain data of big data tools are not core business web crawler automatically, day and night, high intelligence climb to take the free data on the Internet, big data-related companies will be less. many programming language to write web crawler, there are many, but Python is definitely one of them mainstream, gas Scripy reptiles framework is widely used.
    • Financial Planning Analysis: quantitative trading, financial analysis, financial engineering, not only with the Python language, and most used, but also the importance of increased annually reason: As a Python dynamic language, clear and simple language structure, rich library, mature and stable , scientific computing and statistical analysis is very fast hardware, production efficiency is much higher than C, C ++, java, especially good strategy backtesting.
    • Graphics GUI: PyQT, WxPython, Tkinter
    • Game Development: Python in online game development, there are many applications compared to Lua or C ++, Python Lua has a higher order than the ability to abstract, can be described with less code business logic game, compared to Lua, Python is more suitable for. Host one kind of language, that is the entry point of the program is Python that end would be better, then write some extensions .Python very suitable for the preparation of more than 10,000 line items when necessary with C / C ++, and can well put online scale projects controlled within 10 million lines of code, well-known game "civilization" is written in Python
  • In some companies Python applications
    • Google: Google App Engine, code.google.com, Google earth, Google reptiles, Google ads and other projects are in extensive use of Python development
    • CIA: CIA website was developed by Python
    • NASA: US Space Agency (NASA) extensive use of Python for data analysis and computation
    • YouTube: the world's largest video site YouTube is to use Python developed
    • Dropbox: America's largest online cloud storage sites, all implemented in Python, handle every day the site to upload and download files of one billion
    • Instagram: America's largest photo-sharing social networking sites, more than 30 million photos every day to be shared, developed entirely in Python
    • Fackbook: a lot of basic libraries are implemented by Python
    • Redhat: the world's most popular Linux distribution version of yum package management tool that is developed in Python
    • Watercress: Company substantially all of the business is developed by Python
    • Know almost: the largest Q & A community, by the Python development (foreign Quora)
    • Rain Doctor: well-known online medical website is developed by Python
    • In addition to the above, as well as Sohu, Jinshan, Tencent, Shanda, Netease, Baidu, Alibaba, Taobao, potatoes, Sina, shell and other companies are using Python to complete a variety of tasks
  • Python version
    • Python2 +:. C, Java, C # source code is not uniform, the code (function) is repeated, difficult maintenance
    • Python3 +:. Code unity, reduce maintenance difficulty
  • What is a Python language

    • Compiled: compiled from start to finish only once
      • Advantages: run fast
      • Disadvantages: slow development
      • Representatives language: C, C ++, Go
    • Interpreted: Compile a sentence (progressive compilation)
      • Advantages: high development efficiency
      • Shortcoming; running slow
      • Representatives language: Python, Ruby, PHP
  • Python's strengths and weaknesses

    • advantage
      • Python position is "elegant" and "clear", "simple", so Python program always looks easy to understand for beginners blood Python, not only easy entry, and deep down in the future, you can write those very, very complex procedures
      • Development efficiency is very high, Python has a very powerful third-party libraries, you basically want to achieve through any computer functions, Python official library has a corresponding module support, directly after downloading calls, and then to build on the foundation of the library and greatly reduce the development cycle, to avoid duplication create the wheel
      • High-level language: When you use the Python programming language, you need to consider how to manage a class of low-level details of memory used by your program
      • Portability: Because of his open-source nature, Python has been ported on many platforms if you are careful to avoid any system-dependent features, then all your Python programs without modification on almost all platforms on the market. on the run
      • Scalability: If you need faster a critical piece of code to run or want some algorithms are not open, you can put part of your program in C or C ++, and then use them in your Python programs
      • Embeddable: You can embed Python within your C / C ++ program, which provides scripting capability to your program's users
    • Shortcoming
      • Slow: for example, C language is 10 times faster than Python,
      • Code can not be encrypted, because Python is an interpreted language, his file is stored in the form of source code
  • Python species
    • Cpyhon: CPython, the interpreter uses C language development
    • jython: Python interpreter is running on the Java platform, Python code can be directly compiled into Java bytecode execution
    • IronPython: Jython and similar, except that it is run Python interpreter on the Microsoft .Net platform, Python code can be compiled directly to the success of .Net bytecode
    • PyPy: Python interpreter another, its goal is the use of JIT execution speed .PyPy technology, Python dynamically compiled code (note not explained), it is possible to significantly improve the execution speed of the Python code.

3. Variables

  • Rules defined variables
    • Numbers, letters, underscores
    • You can not begin with a number
    • You can not use Python keywords
    • You can not use Chinese and Pinyin
    • Case sensitive
    • Variable name to have meaning
    • Recommended wording: Hump body and underscore (the official recommended)

4. Constant

  • ALL CAPS is constant, constant does not modify the recommendations

5. Comment

  • Single-line comments: Only comments line, can not wrap
  • Multi-line comments: You can newline character on the nature #

6. Data Type

  • Integer (int) - Digital
  • String (str) # three quotes when assigning content represents a string, then quotes does not mean comment
    • + String: String + String # string splicing
    • * String: string * Digital # can only multiply the number
  • Boolean value
    • True: True
    • False: False
  • List

  • Originator

  • dictionary

  • set

3. user interaction (input)

  • Variable name = input ( "message") # A Python 3 version of the input acquired are all string types
  • type (): View Type

4. Control Flow Statements

  • Simple if

    • if conditions:

      Result

  • pick one of two

    • if conditions:

      Result

      else:

      result:

  • One of many # select 0 or 1 when no else, else there is to choose a time

    • if conditions:

      Result

      elif condition:

      Result

      elif condition:

      Result

      ​ else:

      Result

  • Multiple choice # You can select all, you can not choose a

    • if conditions:

      Result

      if conditions:

      Result

      if conditions:

      Result

      if conditions:

      Result

  • Nesting
    • Several options can be combined nested manner

Guess you like

Origin www.cnblogs.com/W-Y-C/p/10968461.html