Repository navigation
Home
Pyordle is a Python 3 implementation of a popular online word game in 2022. It is for teaching Python basics and is thus not of professional code quality. The basic version is text-only; optional enhancements include a graphical user interface, and a solver to automatically solve similar puzzles or give hints to the player.
- Sample code with GUI and solver, hint and demo modes
- Sample implementation with solver, hint and demo modes as a single file on online-python
- Original
- Hello Wordl
- Online: online-python – must open pyordle_answers.txt and pyordle_valid.txt as tabs, no tkinter
- Online: onlinegdb – must open pyordle_answers.txt and pyordle_valid.txt as tabs, broken tkinter
- Windows: single-file Python interpreter – no tkinter
- Android: Pydroid 3 – cannot call with command-line arguments, contains ads
- about me
- about this course
- tell us your
- name
- programming experience
- what you hope to get from this course
- about Python
- Python 2 vs 3 (print, input, strings, /, names of things etc)
- set up Python
- simple variables
- naming conventions
- int
- float
- bool
- strings
- multiline strings
- extracting characters
- lower, upper
- operators
- precedence
- /
- shortcut operators (e.g. +=)
- input vs raw_input
- .format vs %
- multiline commands (\)
- multicommand lines (;)
- comments
- indentation
- functions
- default parameters
- return
- global
Exercise 1: Have a go at exercise 1 in the sidebar!
- list
- tuple
- set
- dict
- list comprehension
- len
- range
- join
- extracting elements
- reversing a list
- reading files
- writing files
Exercise 2: Read word lists into sets
- if, elif, else
- while
-
for
- enumerate
- items, keys, values
- break
- continue
Exercise 3: Input valid guesses
- command-line parameters
- Web access
Exercise 4: Think up an algorithm to evaluate players' guesses
- sorted
- lambda
Exercise 5: Display the results and end-game messages
- object-oriented (class)
- exceptions
- multithreading
- regular expressions
- specific applications
- advanced games (Pygame, PyOpenGL)
- numerical computing and statistics (numpy, scipy)
- imaging (PIL, OpenCV)
- machine learning (PyTorch, TensorFlow)
The "Solution template" link above gives an outline of the text-only game. Comments marked TODO: and ... are to be completed by the learner.
In exercise 1,
- try to understand the workflow
- implement display_message to print a newline followed by the message given
- randomly pick a word from answer_s as answer
For exercise 2,
- copy pyordle_answers.txt and pyordle_valid.txt to the same folder as the Python script
- read these word lists into sets answer_s and valid_s
As exercise 3,
- implement input_guess to accept a valid guess from the player
In exercise 4,
- implement evaluate_guess to populate guess_mark_l with the correct "colours"
For exercise 5,
- implement display_result to tell the user the result
- display appropriate message when a game ends
As optional exercises,
- implement a hint mode to suggest possible words to the player
- implement a demo mode to let the computer play itself
- implement a solver mode to let the computer solve a third-party puzzle
- implement a graphical user interface using tkinter
The modes can be either read from a command-line argument or hardcoded.
If your environment does not support reading local files, such as some online interpreters, below is a version with the word lists compressed and encoded into the Python script under the comment ## Read words (how it works is beyond the scope of this course!)