Full Record CodeCombat Code (Python learning tool) - Kithgard dungeon Code 1

Kithgard dungeon
Note: When you call the function, content to add parentheses after the function, otherwise in python, would not think you call this function content, and your hero will stand still like a stick will not be executed on the lower left and right move! ! !

hero.moveRight ()
hero.moveDown ()
hero.moveRight ()
. 1
2
. 3
hidden gem
hero.moveRight ()
hero.moveDown ()
hero.moveUp ()
hero.moveUp ()
hero.moveRight ()
. 1
2
. 3
4
5
content to explain: we can give this method to pass the appropriate parameters, such as code follows, we give 2 parameters, then the code will allow you to identify the hero to move two steps instead of one step up.

SUMMARY When using the same method, we can merge the content of exemplary methods may be combined as follows:

hero.moveRight ()
hero.moveDown ()
hero.moveUp (2)
hero.moveRight ()
. 1
2
. 3
. 4
shadow guard
hero.moveRight ()
hero.moveUp ()
hero.moveRight ()
hero.moveDown ()
Hero. moveRight ()
. 1
2
. 3
. 4
. 5
amnesia jeweler
when the code does not have an extra incentive than 9

hero.moveRight ()
hero.moveDown ()
hero.moveRight ()
hero.moveRight ()
hero.moveUp ()
hero.moveRight ()
. 1
2
. 3
. 4
. 5
. 6
as we just mentioned, combined can also be written

hero.moveRight ()
hero.moveDown ()
hero.moveRight (2)
hero.moveUp ()
hero.moveRight ()
1
2
3
4
5
真实姓名
hero.moveRight ()
hero.attack ( "brake")
hero.attack ( "Brake")
hero.moveRight ()
hero.attack ( "truce")
hero.attack ( "truce")
1
2
3
4
5
6
不详的征兆
hero.moveRight ()
hero.moveRight ()
hero.moveUp ()
Hero .moveRight ()
hero.moveRight ()
hero.moveRight ()
hero.moveDown ()
hero.moveRight ()
hero.moveDown ()
hero.moveRight ()
1
2
3
4
5
6
7
8
9
10
tedious watching a headache, so novices can write gradually, more and more skilled that when we need to make our code a concise

hero.moveRight (2)
hero.moveUp ()
hero.moveRight (3)
hero.moveDown ()
hero.moveRight ()
hero.moveDown ()
hero.moveRight ()
1
2
3
4
5
6
7
逆时针回转
hero.moveDown ()
hero.moveDown ()
hero.moveRight ()
hero.moveUp ()
hero.moveRight ()
1
2
3
4
5

hero.moveDown (2)
hero.moveRight ()
hero.moveUp ()
hero.moveRight ()
. 1
2
. 3
. 4
Name Dictionary:
defined functions:
1. Function block using the definition def keyword beginning, and back to keep the function name ( ), draw a line on the back of colon
2. any incoming parameters should be placed in brackets
3. complete the function of a particular group of statements to complete the function groups of statements by calling the function name
4. content second line inside the function use indentation
5. If the function returns a value, we return to use, if not written return, represents a return to the default None
6. The function name must start with a letter or underscore, may comprise a combination of numbers, letters, underline, etc., must not contain punctuation !
7. The function name is not the same, then if the function is defined as previously defined behind the cover
8. If the same function name, but not the same case, it is possible, counted as two different functions
9. reserved function names can not be used word, the same built-in function will override the
time 10. the defined function, if the function mode annotation annotate, three quotes
--------------------- 

Guess you like

Origin www.cnblogs.com/ly570/p/11026705.html