A small collection of four standalone Python exercises covering text processing, functions, recursion, collections, and basic parsing.
These scripts were written for programming practice. They are best suited to learners who already know basic Python syntax and want to explore how common programming concepts work through examples.
| Exercise | What it does | Concepts |
|---|---|---|
| Array Declaration Parser | Reads a Pascal-style array declaration and extracts its type and dimensions into a descriptor. | Regular expressions, string parsing, lists |
| Recursive Digit Processing | Turns an integer into a list of digits using recursion, then transforms the list based on its length. | Functions, recursion, global variables, lists |
| Student Exam Score Analysis | Scores three students against an answer key, calculates the class average, and supports name lookup. | Functions, dictionaries, tuples, loops |
| Text and Word-Frequency Analysis | Removes selected stop words and punctuation, counts words, extracts unique words, and groups the results. | Strings, sets, dictionaries, collections.Counter |
Note: The original filenames have been preserved. In particular,
simple game .pyis a text-processing exercise, not an interactive game.
Requirements: Python 3. All four exercises use the Python standard library; no third-party packages are required.
Clone the repository:
git clone https://github.com/SelimUysal/Python-simple-code.git
cd Python-simple-codeRun an exercise from your terminal. Filenames contain spaces, so keep the quotation marks:
python "simple game .py"On systems where python does not refer to Python 3, use python3 instead.
Run:
python "simple game .py"Enter a short phrase, such as:
The cat and the dog. The cat!
The script prints intermediate results, including the cleaned word list, word frequencies, unique words, and grouped words. Stop-word filtering currently covers only a, an, and the.
Run:
python "EBNF programining language .py"Example input:
DATA: array [1..5] of integer;
The parser produces a list describing the array declaration, including its element type and dimensions. Its accepted syntax is deliberately limited; it is not a complete EBNF or Pascal parser.
- Open a script and identify its inputs, functions, and outputs.
- Run it using the suggested example.
- Try changing the input and predicting the result.
- Improve error handling, variable naming, or code structure as an exercise.
- These are learning exercises, not production-ready utilities; input validation and edge-case handling are limited.
function .pyuseseval(input(...)), which can execute arbitrary Python expressions. Run it only with trusted input; replacingevalwith safe parsing is a recommended improvement.- The exam-scoring exercise assumes the entered answer strings are compatible in length with the answer key.
- Some implementations may produce unexpected results for boundary cases. Review and test them before reusing the code in other projects.
Purpose: Learn by running, inspecting, and improving small Python programs.