faif /
python-patterns
A collection of design patterns/idioms in Python
84/100 healthLoading repository data…
asweigart / repository
A collection of text-based games written in Python 3 that only use "standard i/o".
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A collection of Python 3 source code for simple, text-based games & simulations to use as example programs.
INSTALL: pip install --user gamesbyexample
(Use pip3 on macOS and Linux.)
RUN LAUNCHER: python -m gamesbyexample
I'm not accepting pull requests currently, but feel free to leave comments or send suggestions to al@inventwithpython.com
If you need help installing Python, visit https://installpython3.com/
First, install the Python interpreter. This comes with the barebones IDLE editor. There are other editors you can use. On Windows, you can also use the Visual Studio Code editor. PyCharm Community Edition is an editor for Windows, Linux, and macOS. You can also use a browser-based editor like REPL.it. These are all free.
Then, click in the src and gamesbyexample folders in this repo to find the .py files of various Python games. For example, this is the code for snailrace.py. The code for each game its entirely in one .py file, so you can copy the code directly into your editor. I recommend typing it in by hand, rather than using copy-paste. This will give you "muscle memory" of each part of the code. (Though some of these games require you download a data file into the same folder as your .py file.) Then you can run the program. If you get error messages, note the line number in the error message and check for typos you've made.
After learning basic syntax, many programmers want to move on to the next step and see how these programming concepts are used in "real" programs. Most open source projects are far too large and complicated. These games have been designed to be short, simple, and fun. You can use them as learning examples to see how to make your own programs.
Note that some programs require you to download an extra file from this repo. For example, the [sudoku.py](https://github.com/asweigart/PythonStdioGames/blob/master/src/gamesbyexample/sudoku.py) game loads its puzzles from the [sudokupuzzles.txt](https://github.com/asweigart/PythonStdioGames/blob/master/src/gamesbyexample/sudokupuzzles.txt) file.
After beginners learn the syntax of Python and basic programming concepts (loops, branching, functions, etc.) they often hit a dead-end: "How do I become better at programming?" At this point, people will tell them to work on their own practice projects (which leaves them without guidance on what to make and how to make it) or to contribute to open source projects (which can be difficult to find, understand its code base, and get guidance on how to contribute).
What helped me learn to code was finding small projects whose source code I copied and then made small adjustments to. This gave me insight on how loops, branching, and functions combined together into actual programs.
To help others down the same path, I'm creating a collection of example programs aimed at being easy to copy and understand by beginners. These programs (mostly games) have the following constraints:
print() and input() in Python. The output being in the same text medium as the text source code makes it less abstract, and easier to see the cause-effect relationship between code and output. This means there's no graphics or mouse input, but makes it simple to port these programs to other languages since they all support stdio text.input() means the program must wait for the user to enter text, but this means we can't have real-time programs that respond to single key-presses.help() function to work in the interactive shell.Additional guidelines include:
bext module, which adds curses-like features like color, clearing the screen, and moving the cursori and j, or x and y.# (!) that describe minor changes that they can make (increasing health, changing difficulty, etc.)assert statements to catch common typos the student makes when typing in the code, especially for constants that they may modify.input(), but note that you'll never be able to interrupt when the user is typing.pyperclip module can be used to interact with the clipboard. Large amounts of text can be input-ed into or output-ed from the program using the clipboard.After making several of these programs, I've notice various "categories" of program complexity. Programs can be of zero or more of these categories:
bext module, but can clear/refresh the screen, draw at arbitrary places on the screen in color, etc.input(), the user edits variables at the top of the file to change the settings in the program.Additional modules I recommend using:
bext for colorful text and controlling the positioning of the text cursor.blessings for a better version of curses.pyperclip for copying/pasting text with the clipboard.playsound for playing audio files.pyttsx3 for text to speech.pytextcavas for 2D strings you can draw onpyrect for rectangle data structurepybresenham for various line-drawing functionsAlphabetize Quiz - A time-based quiz game to see how fast you can alphabetize letters.
Alphabetize Word Quiz - A time-based quiz game to see how fast you can alphabetize words.
Analog Clock - An analog clock animation. Press Ctrl-C to stop.
Bagels - A deductive logic game where you must guess a number based on clues.
Birthday Paradox Simulation - Explore the mathematics of the "Birthday Paradox". More info at https://en.wikipedia.org/wiki/Birthday_problem
Blackjack - A card game also known as 21. More info at: https://en.wikipedia.org/wiki/Blackjack
Bouncing Ball - A bouncing ball animation. Press Ctrl-C to stop.
Bouncing Lines - A bouncing line animation. Press Ctrl-C to stop.
Calendar Maker - Create monthly calendars, saved to a text file and fit for printing.
Chance Checkers - Checkers, but you can move 3 random checkers per turn. These checkers are randomly decided, and can be the player's own checkers or their opponents', but you can't move your opponents' promoted checkers. In this version, capturing is not mandatory.
Daleks - Try to get the robots to crash into each other.
Checkers - The classic checkers board game. In this version, capturing is not mandatory.
Chomp - A dangerously delicious logic game. Inspired by a Frederik Schuh and David Gale puzzle, published by Martin Gardner in Scientific American (January 1973) More info at: https://en.wikipedia.org/wiki/Chomp
Clickbait Headline Generator - A clickbait headline generator for your soulless content farm.
Coin Flip Simulator - Simulate a large number of coin flips.
Collatz Sequence - Generates numbers for the Collatz sequence, given a starting number.
*Collatz Sequence Sta
Selected from shared topics, language and repository description—not editorial ratings.
faif /
A collection of design patterns/idioms in Python
84/100 healthPython-World /
A collection of simple python mini projects to enhance your python skills
42/100 healthfortra /
Impacket is a collection of Python classes for working with network protocols.
The-Cool-Coders /
A Collection of application ideas that can be used to improve your coding skills ❤.
93/100 healthlazyprogrammer /
A collection of machine learning examples and tutorials.
86/100 healthgoogle-deepmind /
OpenSpiel is a collection of environments and algorithms for research in general reinforcement learning and search/planning in games.
91/100 health