English Study ONE
Python Glossary
Python Chinese English Comparison
Create an instance and assign attributes
It is equivalent to creating a series of attributes equivalent to instance for testcase
相当于给testcase创建一系列等同于instance的属性
The purpose of testing is to protect other code blocks
Create a survey object and a set of answers for the test method used
Test for Anonymous Survey class
Collect anonymous survey answers
Store a question and prepare for storing the answer
Launching unit-tests with arguments python -m unit-test(使用参数python -m unit-test启动单元测试 )
passable test –> reptile(爬虫)
Unit tests and test cases –> Key-value pair
separate –> separator
The split()
method splits the string into multiple parts using spaces as the separator, and stores these parts in a list.
Possible exception types –> skeleton –> Debug code block
By using an absolute path, files anywhere in the system can be read.
Divide the code into a series of functions that complete specific tasks. This process is called refactoring
Save and read user-generated(生成的) data
JSON –> JavaScript Object Notation ——>placeholder
Calculate how many words the file contains
text —–> we will take a test for today`s text
Analyze the text <==> text analysis
Use try-except-else code blocks to defend against unintentisonal user errors and malicious attacks
a simple attempt to simulate the calculator
Use exceptions to avoid crashes
zero division error
Create a list containing the contents of each line of the file
read()
returns an empty string when it reaches the end of the file
The keyword with
will close the file when it is no longer needed –> with-as loop strcture
when creating a subclass, the super class must be in the current file.
Properties that need to be modified <==> attributes that need to be modified
python standard library
Custom workflow
This import method is not recommended ==> from module_name import *
Print a message indicating the battery’s range –> Import a single class
Set the value of the odometer to the specified value, and it is forbidden to dial the odometer back.
Store multiple classes in one module –> Same level directory
Import multiple classes from one module –> Import the entire module
this car can go approximately 240 miles on full charge.
print a message indicating the battery`s range
battery capacity:电池容量
use instances as attributes
override the method of super class
It automatically gets all the attributes and methods of another class.
assign a default value to the property
Create instance based on class
A simple attempt to simulate a dog
object oriented programming:面向对象编程
to separate adjacent functions:将相邻函数分开
Function writing guide=Guidelines for function writing
Assign alias to function using as
:使用as给函数指定别名
Call function directly
ignore unresolved reference ‘module’:忽略未引用的模块
Store functions in modules:将函数存储在模型中
pass a copy of the list instead of original
Prohibited function modification list:禁止函数修改列表
Please enter the name of the album you want to query.
Nested functions in while loop
Non-essential:非必要的
formal parameters:形参(x,y,variable)
arguments:实参(specific information–pass–>formal parameters)
pass parameters to the function=pass arguments to the function
docstring:annotate
argument:争论,参数=parameter
Use user-input to populate the dictionary.
continue and break applies to any loop body.
There must be conditional judgments such as if in front.
There must be conditional statements such as if in front.
Return operation according to bool:根据bool返回操作
Direct termination:直接终止
Schematic diagram:示意图
sketch:速写,略图,草绘
Escape character:转义符
vocabulary:词汇表
comparison:比较,比喻
Conditional statement:条件语句
archives:档案,把…存档
response poll:回应调查
polling active:轮询活动
The pastrami is sold out:五香熏牛肉卖完了
Dream resort:理想的度假胜地
poll results:投票结果
Python English Short Sentences
The only difference between the test class and the test function is that you need to create an instance before the test class
In this example, the use of try-except-else code block provides two important advantages, to avoid allowing users to see the traceback; so that the program can continue to analyze and find other files.
For the method of the supclass, as long as it does not conform to the behavior of the instance simulated by the subclass. It can be overridden, and a method can be defined in the subclass, that is, it has the same name as the method of the supclass to be overridden. In this way, Python will not consider the supclass method, but only pay attention to the corresponding method you define in the subclass.
Guidelines for functions writing:
- When specifying default values for parameters, there should be no spaces on both sides of the equal sign.
- This Convention should also be followed for keyword-arguments in function calls.
- If a program or module contains multiple functions, use two empty lines to separate adjacent functions.
When the default values are specified for the parameter, there should be no spaces on the sides of the equals, and this agreement should also be followed for the keyword-arguments in the function call.
If a program or module contains multiple functions, two adjacent blank functions can be used to separate the adjacent functions.
The best way to quote is to import only the functions you need, or import the entire module and use the period notation句号表示法
.
The best practice for references is either两者中的任一个
to import only the functions you need to use, or to import the entire module and use a period representation.
The best way to do this is to import only the functions you need, or import the entire module and use the period notation.
引用的最佳的做法是,要么只导入你需要使用的函数,要么导入整个模块并使用句点表示法
The module and the files that need to call the functions in the module should be placed in the same directory.模块与需要调用模块内函数的文件要放在同一目录下
The import
statement allows the code in the module to be used in the currently running program file.
I have a dog, and it`s name is floret.
Function allows your program to be divided into multiple small parts, each part is responsible for completing a specific task.
if you could visit one place in the world, where would you go?
which mountain would you like to climb someday?
The for-in loop structure is used to traverse the static list, and the while-break loop structure is used to traverse the dynamic list.
:verifying user
:the following users have been confirmed
Please enter the number of restaurant reservations you want to reserve
:Sorry, there are no tables available.
:Congratulations! there are enough seats
If the program falls into an endless loop, you can close the terminal window that displays the program output.
Please enter your age and I will tell you the price of the movie ticket.
Python Terms
function’s abbreviation is fn
Use as
to assign an alias to a function:使用as给函数指定别名
When calling this function, it can handle it correctly no matter how many key-value pairs are provided.调用这个函数,无论多少提供多少额外的键值对,它都能正确处理.
Unboundlocalerror : local variable ‘full_info’ referenced before assignment:
Unboundlocalerror:分配前已引用局部变量’full_info’(外部变量与内部变量冲突)
Encapsulate these values in a dictionary:将这些值封装到字典中
TypeError: describe_pet() missing 1 required positional argument: ‘pet_name
:类型错误,describe函数确实一个必要的实参’pet_name’
Equivalent function call:等效的函数调用
The order of positional arguments is important:位置实参的顺序十分重要.
Domain’s DNS record could not be retrieved:无法检索域的DNS记录。
The while-loop contains conditional statements
Return to circulatory body
Conditional judgment
Operation down
sublime text:代码编辑器