Learn Python The Hard Way to Learn (37)-Review

Source: Internet
Author: User
Tags floor division

Now it is time to review python keywords and symbols. The following lists some important python keywords and symbols.

Based on your memory, first write down the functions of these keywords, and then go online to find out their actual usage. Some of them may be difficult to find, but you should keep trying.

Write down the cards that you mistakenly remember, and write down the cards that you do not know. Then you can learn about them later.

Finally, use them in the program to ensure that you can use them correctly.

Keywords
And is True only when both are True.
Del deletes an element from the list.
From export objects from the module
Not negative, True to False, False to True
A while LOOP is better to be used in an infinite loop.
Use as and with together to generate an alias.
The abbreviation of elif else if, used with if.
Global defines a global variable.
Or is False.
Use with and as together to generate aliases
Assert asserted that a condition is True. If it is not True, an AssertionError is returned.
Use else and if together
If condition judgment
The pass operation is null, indicating that nothing is done.
Yield is a generator.
Break bounce cycle
Handle the exception with the try command.
Import Module
Print information
Class defines a class
Exec dynamic execution of python code
In loop output list and other elements
Raise raises an exception.
Continue jumps out of the current loop and enters the next loop
Code block that must be executed during finally Exception Handling, used with try
Is compares two objects
Return returns information in the function.
Def defines a function
For Loop
Lambda creates an anonymous Function
Try catch exceptions
Data Type
True Boolean True
False Boolean False
None null
Strings characters
Numbers number
Floats floating point number
Lists List
Escape characters
\ Output \
\ 'Output'
\ "Output"
\ A bell
\ B Return
\ F form feed
\ N line feed
\ R press ENTER
\ T Tab
\ V vertical Tab
Format a string
% D format integer
% I formatted integer
% U format the unsigned integer (disused, not supported)
% O Format the unsigned octal number
% X format the unsigned hexadecimal number (lowercase letter)
% X format the unsigned hexadecimal number (uppercase letters)
% E format the floating point number using scientific notation
% E serves the same purpose as % e
% F format the floating point number. You can specify the precision after the decimal point. The default value is 6 decimal places. For example, %. 2f shows 2 decimal places.
% F is the same as % f
% G determines whether to use % f or % e Based on the value size.
% G is the same as % g
% C format characters and ASCII code;
% S Format String
% R large string
% Output %
Operator
+
-
*
** Multiplication party
/
// Floor division, returns an integer not greater than the result
%
<
>
> =
<=
=
! =
<> Not equal
() Tuples
[] List
{} Set
@ Function modifier: it is also a function. The modified function is the parameter of this function.
, Separator, also indicates no line breaks, print Spaces
: The new code snippet starts.
. Call
= Value assignment
; Statement Terminator, not recommended
+ =
-=
* =
/=
** =
// =
% =
Read code
Find some code to read. You have mastered enough knowledge to read the code. Maybe you do not understand the meaning of some code. Next I will tell you how to read the code.

Print the code you downloaded, right, print, because your eyes and brain are more likely to understand things on paper than on a computer.

Then, do the following:
Let's see what every function is doing.
Where to assign an initial value for each variable
Do not confuse some variables with the same name.
There are no else if statements, are they correct?
Infinite Loop while
Finally, you cannot understand the part for any reason.
Third, write comments to all functions, including usage, parameters, and variables.

Finally, trace the execution of the Code, one row of tracking. Write down the values of some key variables in the operation.

If the above is done, let's go back to the computer to see if we can find something new.

Extra score exercise
1. See what is a flowchart.

2. If you find an error while reading the code, correct it and tell the author.

3. Another trick is to use # as a comment to help others read the code. Author: lixiang0522
 


Author: lixiang0522

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.