Foreword¶
The interest in programming is constantly increasing, and not without a good a reason. However, mastering this skill can sometimes be troublesome. Some things in programming are hard in their own right, but often the difficulty comes from the way programming is tought to beginners. The way of explaining key concepts, the order of presenting/learning, examples that are used, selected programming language, and so on, can all be the factors that inhibit or facilitate learning.
We believe that we have eliminated most of the reasons which make learning programming more burdensome than it has to be:
We tend to first show why the things we are presenting here are needed, and only then to explain them. We believe this has a beneficial effect on readers’ motivation to learn;
Examples that we use most often have a storyline in order to inspire you to go through them; tedious mechanical exercises are avoided as much as possible;
We explain only what is needed to solve an upcomming problem; we leave more difficult things for later;
We do not deal with an overview of the language capabilities; reference manuals exist with this purpose;
We use the increasingly popular programming language Python, which is currently considered the best choice for beginners and is very applicable in real life situations;
No prior knowledge in the field of programming is assumed, and mathematical knowledge on the level of the first few grades of primary school will be sufficient;
Regarding technical details:
You can solve tasks in the browser and immediately get the answer whether your programs are working properly;
With some tasks, a hint or a solution is given, which is not immediately visible. When you click on the “Hint” or the “Solution” button, a hint, possibly detailed instruction or, sometimes, a complete program that solves the task appears. When the compelete program is given, you can copy it to the area for your solution and try it out;
In the initial tasks, you can see a block diagram for your program, similar to those in Scratch (https://scratch.mit.edu/), or at https://code.org/. You can even change the program using block-commands, and then go back to Python with those changes;
In many tasks, you can test your solution on several pre-prepared tests to confirm that the result is not accidentally good in just one case, but that you actually did what was expected;
In short, we did our best to enable you to enter the world of writing computer programs in a pleasant way and reach the level at which you can apply your knowledge in practice.
Before we begin, you should pay attention to several facts about learning programming in general:
Your solution can be quite ok even if it’s different from ours. There is almost always more than one correct way to solve a task.
Programming is best learned through writing programs. Do not just read and solve tasks in your head, or even worse, look at the solutions and think if you would have solved these tasks the same way. Write the programs. Even if you are able to formulate the exact program in your head (although you might just think you are), your hands need to pass through the process of writing that program as well. Actually, doing something is always more than just knowing how to do it.
No matter how hard we try, we can not show or tell you everything - be curious, try out different ideas and see how they work, play with it.
If you have problems in solving some of the tasks, do not worry - it’s completely normal. Have patience and be careful. Try to understand the message about the problem. If necessary, reanalyze the examples and explanations that you have been reading up to then. In case you do peek into a solution, you can copy it or type it with or without looking to the solution (if you type it, you should become independent sooner), but, to achieve progress in learning programming, it is important that you try to fully comprehend the solutions and ideas behind them.
We wish you a fun and successful programming joruney!
Textual Programming in Python by Petlja.org is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Content¶
- Karel
- Basics of programming in Python
- Introduction to Python
- Python programs
- Text values
- Reading data
- Programs with Computation - Exercise
- Math functions
- Math Functions - Exercise
- Branching statements
- Complex branching
- Programs with known input data
- Data collections
- Counting and summing
- Lists
- Computing with lists
- Defining functions
- Dictionaries
- Graphics Programming with Pygame
- The PyGame library
- Writing a PyGame program
- Drawing
- Drawing rectangles, ellipses, and circles
- Drawing straight lines and polygons
- Drawing from reference
- Drawing from reference - additional examples
- Moving the drawing
- Changing the drawing size
- Drawing with the help of loops
- Drawing polygons with loops
- Making more complex drawings using loops
- Displaying ready-made images
- Displaying ready-made images - tasks
- Animation
- Interaction