week1 - Introduction to Python Basics 1, Basic Syntax, Flow Control

Knowledge content:

1. Introduction to python

2. Variables and input and output

3. Branch structure

4. Loop structure

 

 

 

1. Introduction to python

Main application areas of Python:

  • Cloud computing : the most popular language for cloud computing, typical application OpenStack
  • WEB development : Many excellent WEB frameworks, many large websites are developed in Python, Youtube, Dropbox, Douban. . . , the typical WEB framework is Django
  • Scientific computing, artificial intelligence : typical libraries NumPy, SciPy, Matplotlib, Enthought libraries, pandas
  • System operation and maintenance : a necessary language for operation and maintenance personnel
  • Finance : Quantitative trading, financial analysis, in the field of financial engineering, Python is not only used, but also used the most, and its importance is increasing year by year. Reason: As a dynamic language, Python has a clear and simple language structure, rich libraries, mature and stable, scientific computing and statistical analysis are very powerful, production efficiency is much higher than c, c++, java, especially good at strategy backtesting
  • Graphical GUI : PyQT, WxPython, TkInter

Applications of Python in some companies: 

  • Google: Google App Engine, code.google.com, Google earth, Google crawlers, Google ads and other projects are all using Python to develop
  • CIA: The CIA website is developed in Python
  • NASA: NASA heavily uses Python for data analysis and computation
  • YouTube: The world's largest video site YouTube is developed in Python
  • Dropbox: The largest online cloud storage website in the United States, all implemented in Python, the website handles 1 billion file uploads and downloads every day
  • Instagram: the largest photo sharing social network in the United States, more than 30 million photos are shared every day, all developed in python
  • Facebook: A large number of basic libraries are implemented in Python
  • Redhat: The yum package management tool in the world's most popular Linux distribution is developed in python
  • Douban: Almost all of the company's business is developed through Python
  • Zhihu: The largest Q&A community in China, developed through Python (Quora abroad)
  • Dr. Chunyu: A well-known online medical website in China is developed in Python
  • In addition to the above, companies such as Sohu, Kingsoft, Tencent, Shanda, NetEase, Baidu, Ali, Taobao, Tudou, Sina, and Guoke are using Python to complete various tasks

Advantages and disadvantages of python:

Look at the advantages first

  1. The positioning of Python is "elegant", "clear", and "simple", so Python programs always look simple and easy to understand. Beginners learn Python, not only is it easy to get started, but in the future, they can write those very, very complex programs.
  2. The development efficiency is very high. Python has a very powerful third-party library. Basically, you want to realize any function through the computer. There are corresponding modules in the official Python library to support it. After downloading and calling directly, develop on the basis of the basic library. , greatly reducing the development cycle and avoiding repeated wheel building.
  3. High-level language - When you write programs in Python, you don't need to think about low-level details like how to manage the memory your program uses
  4. Portability - Due to its open source nature, Python has been ported to many platforms (modified to work on different platforms). If you are careful to avoid using system-dependent features, then all your Python programs will run without modification on almost every system platform on the market
  5. Extensibility - If you need a critical piece of your code to run faster or want some algorithms to be private, you can write parts of your program in C or C++ and use them in your Python program.
  6. Embeddability - You can embed Python into your C/C++ programs to provide scripting capabilities to your program users.

Look at the disadvantages again:

  1. The speed is slow. The running speed of Python is indeed much slower than that of C language, and it is also slower than that of JAVA, so this is the main reason why many so-called big cows disdain to use Python, but in fact, the running speed referred to here is slow. In most cases, users cannot directly perceive it, and it must be reflected by testing tools. For example, if you use C to run a program, it takes 0.01s, and it takes 0.1s to use Python. In this way, C language is directly 10 times faster than Python. It is very exaggerated, but you cannot directly perceive it with the naked eye, because the smallest unit of time that a normal person can perceive is about 0.15-0.4s, haha. In fact, in most cases, Python can fully meet your program speed requirements, unless you want to write a search engine that requires extremely high speed. In this case, of course, it is recommended that you use C to achieve it.
  2. The code cannot be encrypted, because PYTHON is an interpreted language, and its source code is stored in the form of name text, but I don't think this is a disadvantage. If your project requires the source code to be encrypted, then you don't Should be implemented in Python.
  3. Threads cannot take advantage of multiple CPUs, which is one of the most criticized shortcomings of Python. GIL, the Global Interpreter Lock, is a tool used by computer programming language interpreters to synchronize threads , so that there is only one thread at any time. Threads are executing, and Python's threads are native threads of the operating system. A pthread on Linux and a Win thread on Windows, the execution of the thread is entirely scheduled by the operating system. A python interpreter process has one main thread and multiple execution threads of user programs. Even on multi-core CPU platforms, parallel execution of multiple threads is prohibited due to the presence of the GIL. A compromise solution to this problem will be discussed in detail later in the Threads and Processes chapter.

 

 

2. Variables and input and output

 

 

3. Branch structure

 

 

4. Cyclic structure

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325374542&siteId=291194637