Some modern programming exercises
This project shows how modern programming exercises should be made. This exercises have a graphical user interface instead of the usual textual interface, which are less and less used, or even known, by most of the people which are mainly using smartphones. For more about the rationale behind this project, see https://q37.info/s/cbms43s9.
Simply retrieve the repository (
git clone https://github.com/epeios-q37/basics-exercises, or get the corresponding ZIP file here: https://q37.info/s/js7fm3vj), and, in a console, from to the root directory,
python main.py (you can change the language of the exercises by modifying
main.py). You can also specifically launch an exercise with
python (en|fr)/(A|B|C|Z_(1|2(a|b)|3)).py (for example:
python fr/B.py). You can (should) use
python3 instead of
Alternatively, you can also use Repl.it, so you have nothing to install on your computer. Follow this link, click on the green
run button, select an exercise, and then click on the then displayed URL. To choose another exercise, click on the green
The files found under the
fr root directories are examples of what the students have to figure out.
The A, B and C exercises are variations of the famous Hello, World! program, and are intended to familiarize the student with strings, string concatenation, function calling and definition… Exercise C is interactive.
The Z series of exercises deals with more advanced programming concepts.
The Z_1 exercise deals with the solving of first-degree (in)equations. The student has to find out how to calculate the solutions of such an (in)equation, and can test if its code works properly through a convenient user interface, without having to program this interface.
The Z_2a and Z_2b exercises are example of use of the turtle graphics API. Exercise Z_2b is interactive.
The purpose of the Z_3 exercise is to program the hangman game. As for the other exercises, the student handles the user interface by using very simple functions and can therefore focus on the handling of the inputs from the user.
NOTA: click on the above pictures to see the source code of the corresponding exercise.
In this other GitHub repository, the same game is elaborated step by step through a set of exercises.
workshop/assets directory contains files used for the exercises. The
ab sub-directory is for exercises A and B, the
z_2a… respectively for the exercises C, Z_1, Z_2a… The content of the
Body.html files will be put in the body section of the HTML main page, and the content of the
Head.html files will be put in the head section of the same page. CSS rules are usually put in the latter file.
For the displaying, here are the currently available functions:
For the turtle graphics, here are the currently available functions: