More and more people are learning Python, but how is it enough just to learn the theory? How do you practice Python? This is already a python beginner’s skill!
In fact, the best practical practice, is playing games.
You won’t believe it, but these five games are enough to get you started on Python.
How to practice Python? Let’s play gobang man-machine versus game
(There are five games in the tail!)
Use PyGame to draw a 19 × 19 or 15 × 15 board
Move later:
When the left mouse button is clicked, the position of the mouse click can be obtained. Then, according to the position of the board, the position of the chess pieces on the board can be calculated.
Victory decision:
When a son falls, how to determine whether victory?
Computer drop:
This is the most important part of the whole game function, that is, how to teach the computer to play backgammon.
For example, explain to the computer several basic forms of backgammon: even five, live four, blunt four, live three, sleep three, live two, sleep second (specific will be specified in the specific implementation steps).
Scoring mechanism:
How to score? This is worth considering.
The overall logic is spelled out in the implementation steps
Effect:
Part of the code display:
These are just a few. For the full project, including source files, images, etc., see the bottom of this article!
How to practice Python? Let’s play plane wars
A cool aircraft war game developed in Python (due to space constraints, not detailed, the corresponding source file at the bottom, etc.)
Python Minesweeper, Python Plants vs. Zombies, And Python Tetris!
By learning these games, you’ll be able to put your Python knowledge to use and have the hands-on experience you need.
Method:
If you do not have this, if you need it, you can look at my name, which is the full spelling of “Python female number one”, “in danger” look for me to get it, what all do not want, just take it!
How to practice Python? Did you learn? This is a fun, useful and valuable exercise that you should try!