National Computer Rank Exam 2 Tutorial Python Language Program Design - Chapter 1 [Program Design Basic Method]

tags: Python Level 2  python  data analysis  Programming language

Everyone is good, I haven't met with you for a long time! ! I have been busy with my own things, so I haven't updated it for a long time. I am sorry to say to everyone. Recently, Xu boldly will continue to update some of our Python content, so stay tuned! ! !
Then let's get started all! ! ! ! !

Test point

Python language features

Programming language overview

1. The programming language is a computer instruction to understand and identify the user's operation intent, which allows the computer to automatically perform various arithmetic processing according to a specific rule.

2. A set of computer instructions organized in accordance with the programming language rules are called computer programs.

3. Advanced programming language can be divided into two categories of execution mechanism: static language and scripting languages, static language use compilation mode, and the scripting language is performed using interpretation. For example, the C language is a static language, and the Python language is a scripting language.

4. Programming languages ​​that use compilation execution are static languages, such as C language, Java language; programming languages ​​with explanation are scripting languages, such as JavaScript language, PHP language

Compilation and explanation

Compiling the source code to the process of the target code, usually, the source code is a high-level language code, the target code is a machine language code, and the compiled computer program is called a compiler.

The interpretation is the process of running the source code by converting the source code into the target code. The interpreted computer program is called an interpreter.
Compilation is a one-time translation, once the program is compiled, no need for compiler or source code.

1. For the same source code, the target code generated by the compilation is faster.

2, the target code can be run without the compiler, and it is flexible on the same type of operating system.

Explanation requires an interpreter and source code when running each program.

1. Interpretation of execution requires retaining source code, and the program error correction and maintenance are very convenient.

2, as long as there is an interpreter, the source code can be run on any operating system, which is portable.

Computer Programming

Calculating thinking is a third thinking pattern that distinguishes on logical thinking representative of mathematics and empirical thinking in physics.

Programming is a process of solving problems
1. First, you need to analyze the problem, the interaction between abstract content
2. Design the deterministic method of using computer solving problems,
3, in turn to solve the problem by writing and debugging the code

This is a complete process from abstract issues to solve problems.

Python language overview

Python minimum program

>>>print("Hello World")
Hello World

The first line of ">>>" is a prompt of the Python language operation environment
The second line is the execution result of the Python statement

Python language supports direct use of non-Western characters in Chinese, the execution of the Chinese Python minimum program in the operational environment
The effect is as follows:,

>>>print("Hello World")
 Hello World 

Python development environment configuration

Install
Go to the Python homepage download and install Python Basic development and transportation
Line environment, URL:

Python Software URL

1. Select different versions depending on the operating system.
2, download the corresponding Python 3.0 series version of the program

Install

Python interpreter

The Python interpreter has two important tools:
1, IDLE: Python integrated development environment, used to write and debug python code;

2, PIP: PYTHON Third Party Library Installation Tools to install third-party libraries on current computers

Editing method for the Python program

Start Interactive Python Running Environment Output Data by IDLE

Open IDLE, click Ctrl + N to open a new window, enter the statement and save it, use the quick key to build F5 to run the program

Python program running method

The Python program has two ways of operation: interactive and file.
1. Interactively use the Python interpreter to instantly respond to the code input by the user, give the output result.

2. Filewritten Python program in one or more files, start the code in the Python interpreter batch execution file.

3. Interactive is generally used to debug a small number of code, and the file is the most common programming method.

4, the environment that started IDLE is the Python interactive running environment, entering the code after >>> prompt, enter exit () or quit () can exit, no >>> line represents the result.

>>>a = 100
>>>a = a + 1
>>>print(a)
101

5, the file program is written in the editing window of the iDLE, you can use the shortcut key "F5" or select "Run - Run Module" option in the menu to run Python code
6. In addition, you can run the Python program via Windows command line (cmd.exe), which can be run using the command line Python code.py using the command line Python Code.py. In the graphical operating system, you can run the Python program directly through the mouse.

7. The operating system that does not have the Python interpreter cannot run the Python program directly, you need to pack the Python source code to make an executable, which is called "program release".

Basic writing method

IPO program writing method
1, enter data
Input is the beginning of a program. The data to be processed has a variety of sources, forming a variety of input methods, including: file input, network input, console input, interactive interface output, random data input, internal parameter input, etc.

2, process data
Process is the process of calculating the input data to generate output results. The process of calculating the problem is collectively referred to as "algorithm", which is the most important part of the program. It can be said that the algorithm is the soul of a program.

3, output data
Output (Print) is the way the program shows the results of operations. The output of the program includes: console output, graphics output, file output, network output, internal variable output, etc. within the operating system.

Python program characteristics

Python program characteristics

Python has versatility.

The Python language can be used for almost any development of program design related applications, not only suitable for training to become thinking, more suitable for specific technical fields such as data analysis, machine learning, artificial intelligence, web development.

Python syntax is simple.

Python syntax is mainly used to accurately express problems logic, closer to natural language, only 33 reserved words, very simple.

Python has high yield.

The Python interpreter provides hundreds of built-in classes and function libraries. In addition, programmers around the world contribute more than 100,000 third-party function libraries through open source communities, almost covering various fields of computer technology, and writing Python programs can be utilized. There is a built-in or third-party code with a good programming ecology.

In addition to the three important features of the Python syntax, there are some specific features of the Python program.

  • Platform-independent
  • Force readable
  • Support Chinese

Platform-independent

The Python program can be executed in a computer environment of any installation interpreter, so the cross-operative system can be run without modification.

Force readable

Python reflects the logical relationship between statements by enhanced indentation (the first line of articles in the article), significantly improves the readability of the program, thereby enhancing the maintenanceability of the Python program.

Support Chinese

The Python 3.x version uses Unicode encoding to express all character information. Unicode is an international universal expression character encoding system, which allows the Python program to directly support all kinds of natural language characters such as English, Chinese, French, and German, which is more flexible and efficient in handling Chinese.

Instance analysis: Python applet

Calculation of the Columns of Fibo

F(0)=0, F(1)=1,
F(n)=F(n-2)+F(n-1)Where N>=2

Calculation of circular area

Calculate the area according to the radius of the circle.

Draw a pentagonal red star

Draw a five-angle red star graphic with a Python program.


Program operation timing

Record it to a loop count and output its runtime.

Draw a colorful circle

Draw 7 different colors of circles, make up a seven-color circle pattern.

chapter summary

This chapter is mainly for readers designed by beginners, specifically explaining the basic concepts of programming languages, understanding the IPO writing methods developed by procedures, configuring the specific steps of the Python development environment, and the Python language and Python program characteristics, etc., further give 5 A simple Python instance code, helping the reader to test the Python development environment and have an intuitive understanding of the language.

The Python Grand Opera is about to be staged, let's chase.

If you encounter something on the way to learn Python, you can find Xiaobian to seek help! !

The most important thing is definitely, don't forget to give Xiaobian one-button three! ! ! !

Intelligent Recommendation

Computer Level 2 - Python Language Program Design - Integrated Application

There is a Python source file "py301.py under the candidate folder. Please follow the file to modify the code to implement the following functions. Caesa is a very ancient encryption algorithm. W...

National Computer Rank Examination Level 2 Python Language Programming Exam —— Notes of related compulsory test library (below)

Relevant compulsory library notes (on) Notes on the relevant compulsory library (below) Table of Contents (continued): 4. pyinstaller 5. jieba 6. wordcloud pyinstaller ↶ 1. Check whether it is install...

National Computer Rank Examination Level 2 Python Language Programming Exam Outline (2022 Edition)

National Computer Rank Examination Level 2 Python Language Programming Exam Outline (2022 Edition) Recommended small program for computer level-2 Python brushing questions basic requirements Master th...

Chapter 1 Computer and Program Design Overview Questions

Chapter 1 Computer and Program Design Overview Sketch 2. 3. 4. The code is as follows: 5. The code is as follows: (Note that the bit operation is used here, the simple algorithm isnum%2==0) 6. The cod...

Python language program design - Chapter 2 problem solving

This is the answer to the problem in the second chapter. The serial number of the possible topic is a bit misplaced....

More Recommendation

Caught "Python language program design" notes - Chapter 1

Temperature conversion: Program Format Framework:   Code highlight indentation: Expression program format frame - Strictly clear: indentation is part of the grammar, indent incorrect procedures r...

GO Program Design Language Chapter 6-Method

Method Method receiver p Selector shaped like p.x or P.Path () GO allows any type of type to add method, which can add methods to a named type, as long as its bottom layer is not a pointer or interfac...

Computer program design technology level (Java language) exam summary (theory)

twenty one. (1 point) The following Java source file code snippet is wrong (B) A. package testpackage;   public class Test{//do something…} B. import java.io.*;   package testpackage;   public ...

Computer program design technology level (Java language) exam questions (theory)

1. (1 point) A Java program runs from top to bottom is (c) A. Operating system, Java program, JRE / JVM, hardware B. JRE / JVM, Java program, hardware, operating system C. Java program, JRE / JVM, ope...

C language program design (Chapter 2)

C language program design (Chapter 2) 1. Classification and representation of constant In the process of running the program, the amount that the value cannot be changed is called constant (1) Supreme...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top