Init.py Guide - IncrediCoders/Python1 GitHub Wiki

Paul Python added this page on July 29, 2025
We initialize the code by tucking some of it away in the init.py files. This allows us to focus more on the code we want to teach you and that we want you to write!
So, this page provides a list of all the input.py files we have for this book! That's for each level and for all the challenges (potentially 21 init.py files)! And then we link to them (so you can check them out), and we provide a summary of the code that's in each file.
Pick a level to see what's in its init.py files:
Note: The init.py file has the same contents for Main game, Challenge 1, and Challenge 2.
-
Main Game
- Part 1: Imports dependencies and assigns the global variables.
- Imports the file path, the
pygame
module, and thetextwrap
module.
- Imports the file path, the
- Part 2: Creates a framework of general classes and methods.
-
load_file(fileName):
Grabs the image files from your folder. -
display_text(screen, current_text):
Displays text to the screen. It also wraps the text for formatting.
-
- Part 3: Sets up for the Class Introductions game.
- Initializes Pygame, the font object, and the window's title.
- Sets up the screen.
-
display(background, current_text, current_character):
Displays a character to the screen
- Part 1: Imports dependencies and assigns the global variables.
- Challenge 1
- Challenge 2
-
Main Game
- Part 1: Imports dependencies and assigns the global variables.
- Imports the file path, the
sys
module, thepygame
module, therandom
module, and thetime
module from the import path.
- Imports the file path, the
- Part 2: Create a framework of general classes and methods.
-
get_file(fileName):
Grabs the image files from your folder. -
read_file(fileName):
Puts the TXT file into thefile
variable.
-
- Part 3: Sets up the Classroom Quiz game.
- Draws a border around our answer rectangles so the user can see exactly where to click.
- Picks the text style and size.
- Sets the window size for our game.
- Loads the images (sprites) and puts them in the variables (assigns to variables).
- Randomly shuffles the answers so that the player doesn't know the correct answer.
- Displays the image of Mrs. Codala telling you if the choice is correct.
- Loads and displays the new question.
- Shows the image of Mrs. Codala telling you the game is done.
-
check_game_started():
Checks if the player clicks the text to start the game. - Loads the introduction screen to start a new game.
- Exits the game if the player clicks the Close button.
- Part 1: Imports dependencies and assigns the global variables.
- Challenge 1
- Challenge 2
We hope you took all that to heart, and you're ready to learn (or to continue learning)! Let's get back to the book! And you should probably also check out the rest of our resources, at IncrediCoders: Python Adventures - All Online Resources.
And you can take a gander at all the rest of our Big Book Buddies, which are pages we have on the Wiki that help out as buddies of the book!