Lesson: Python basic syntax yuan

 

Python environment configuration:

first step:

Step Two: Click the image above: Python 3.6.4 version, download

The third step: pay attention to the red arrow where you want to hook on, then click on the install now, to start the installation

 

Step Four: Start -> Search: idle came out

 

Python programming two ways:

Interactive: real-time operating results for each input sentence for grammar exercises

File type: bulk execute a set of statements and operating results, the main way of programming

Elemental analysis syntax:

Indent: Expression and hierarchy between code contains the only means, generally with a length of four spaces, or a TAB

Note: single-line comments: # at the beginning, followed by the comment content; multiline comments: In '' 'at the beginning and end

Name: identifier associated with the process

Naming rules: uppercase and lowercase characters and a combination of letters, numbers, underscores and Chinese characters; case sensitive, the first letter can not be a number, not the same as a reserved word

Reserved words: is defined within the programming language used and reserved identifier, Python reserved word 33

type of data:

 String: an ordered sequence of characters of zero or more characters; represented by a pair of single or double quotes

 Number of strings: forward and reverse declining numbers incrementing number

Use [] to obtain characters in one or more characters

Index: Returns a single character string <string> [M]

Example: "Please enter the temperature value with a negative sign:" [0] or TempStr [-1]

Slice: Returns a string in a string substring <string> [M: N]

 Example: "Please enter the temperature value with a negative sign:" [1: 3] or TempStr [0: -1]

 Type list: an ordered sequence of zero or more data consisting of a list of the [], a comma (,) between each element

Example: [ 'F', 'f'] denotes two elements 'F' and 'f' 

 

Python input and output

Input Function: input function obtains user input from a console using the format: <variable> = input (<message string>), the user input information stored in the character string type <variable> in.

输出函数:print()  以字符形式向控制台输出结果的函数;

评估函数:eval() :去掉参数最外侧引号并执行余下语句的函数

 

Guess you like

Origin www.cnblogs.com/lbl-1998/p/11177839.html