Classes and Objects
Simply put, the class is a blueprint and template objects, and objects are instances of classes. In object-oriented programming world, everything is an object , the object has attributes and behavior of each object is unique, and objects belonging to a certain class.
- Import library, import library name
- for loop, if the count is used where
- Start End step
- range interval after closing a front opening.
range(start,end,[step])
- Output Format
% ->% (), then the integer% d,% f the floating-point connection, the connection string% s.
{} -> the format (), any type of it can be directly passed, and then formatted output. - print console (terminal) Print
end end in what way, by default a newline "\ the n-"
flush flush the buffer.
-
Function class can have its own parameters
when you want to share this parameter, then hit the "self" mark.
Case:
Defined categories:
object is not a parameter
defined class only two steps:
1. Use the identifier ClassName class (object):
2. Rewrite __init__ function, but keep in mind, it is absolutely necessary on a "self" marker
because'll learn later inherited when in succession when the situation might have collided with the function name.
or, the class will contain multiple variables, multiple functions, then you need to use the "self" means to differentiate.
3. kind of mass participation is in the __init__ function. Note that if you use multiple parameters may be a function, then
you just go to define the parameters in the __init__ function
Case:
Case:
Exercise:
King pesticides
Man-machine war
→ 1. Click on the man-machine, multiplayer, Versus buttons (input)
→ 2. Selection of characters (Dian Wei, Zhao, Luban)
→ 3. Display fighting force, defense
→ 4. People determined randomly the personal computer 1, including combat power, display information such as name ...
→ 5. enter the start button ...
→ 6. enter the page is loaded ...