Python study notes second (chapter two)

Course Contents:

(1) Basic data types: numbers, characters, Boolean; complex data types: lists, primitives, dictionaries, collections;

(2) Operations on basic data types: numbers can be +-* / modulo and quotient; operations on complex data types: add, delete, check, and modify;

(3) Variable names: uppercase and lowercase letters, numbers, underscores, and Chinese characters. Note: the first letter cannot be a number;

(4) Naming rules for variable names: camel case naming, StudentOfClass (often used for class names); underscore naming, age_of_student;

(5) Data control process: sequential process, while loop, for loop, if conditional branch;

(6) Input and output: input, eval, print, format (format output);

(7) Indentation: use indentation for the loop body (4 bytes);

(8) PEP8 format, programming reference format;

Easy to forget content:

(1) The expression of the dictionary: {201901: "Xiao Ming", 201902: "Xiao Hong", 201903: "Xiao Zhang"}, the method of accessing the dictionary: student[key]

Will get value

(2) The expression of the collection: {"Xiao Ming", 123, True, False}

(3) PEP8 format, there must be a space between the two elements, please refer to PEP8 format for specific format

(4) The format of standard output : Please refer to the second chapter of the video (42:15) for how formate outputs data in a standard format.

(5) Comment: single-line comment#; multi-line comment """ """

(6) The input function will get a string, if the string is a number, you can use the eval function to convert the string to a number eval (input ("Please enter a number"))

(7) For, while, if use format : colon:, the use of semicolon, this is particularly easy to confuse and easy to forget

(8) Packing: x, y = 1, 2; y, x = y, x can realize the conversion between numbers

summary:

(1) List [] square brackets, tuple () parentheses, dictionary {} curly brackets, set {} curly brackets

(2) Variable names: uppercase and lowercase letters, numbers, underscores, and Chinese characters. Numbers cannot be used for the first letter

(3) While, for, and if statements are often used, the expression format needs to be kept in mind

(4) Variable name naming rules: camel case AgeOfStudent, underlined age_of_student

(5) Boolean type True , False

(6) The print function will automatically wrap after the output under normal conditions. If you want to stay in this line next time, you need to use end, print ("asd", end="")

(7) Elements in lists, tuples, dictionaries, and sets are separated by commas

Guess you like

Origin blog.csdn.net/dqefd2e4f1/article/details/112860372