Quick start with Python
In this section you will write your first Python programs. Yes, we will do it right away, without theory or setting up environment (that will come later).
Our Python Project
This course is project based. We are building a simulation of Bank system and learning Python along the way. Isn't that cool? :) But for real, best learning is project based learning. This section describes what we are building within this course.
Introduction to Python (theory and environment)
This is a theoretical section. You can quickly read trough it or return back to it if you are tired of coding at any point.
Python Basics (variables, operators, input and output)
Before working on a more complex subjects we need to get our basics. Python variables, how to handle operators, strings, inputs and outputs.
Data structures in Python
Programming is all about managing data. To be able to manage data good, we need to know different ways to keep this data stored (data structures).
Code flow in Python
Programming is also abaut managing decisions. To be able to control our program, we need to learn code flow rules.
Functions in Python
Programming is all about reusing. We don't want to code same things over and over again. This is why we need functions.
Object Oriented programming in Python
Finally, it is time for us to make our banking software example. This part actually goes above "Python for Beginners", but still, try it. You might like it.
Debugging in Python
If we are to continue our programming career we will have bugs, lots of them. We need to learn how to find and fix them.
Commenting and documentation in Python
Long story short: In the first lesson we coded our first Python program. Then in the second lesson we broke it intentionally and fixed it again. Finally, we want to document it.
- comment – code which will not be executed (it is still in our program, but compiler will ignore it)
- inline comment – comment which is commenting only one line
- comment block – comment which is commenting multiple lines of code
- doc-block – comment which is actually a documentation (usually contains description of function, methods, authors, etc.)
- Code smell – This is a programming jargon, which usually means that there are too much comments. In this case, it is suspected that code is not good, so the comments are there to (like a deodorant) to improve a bad smell of rotten code.
Disclaimer: Throughout this course, examples will have lots of comments (even where something is obvious). Reason for this is to make them understandable for learning purposes. In a production, lots of these comments would be excluded. Furthermore, lots of approaches and oversimplified examples would never be used in a production code (… or would they…).
Ok, lets put some comments (documentation) in our code.
We will take the example from the previous lesson and make it look like this.
Quick reminder, we are using Online Python compiler – https://www.onlinegdb.com/online_python_compiler
Note: As you can see, this time you have only screenshot (no code example), which means you will have to type it (no copy paste this time).
Single line comment
- To make a single line comment, we write # at the beginning of a code line. Example on line 6.
- If we put a # somewhere in the middle of the line, then only part of that line will be commented (right part of the line). Examples on lines 10, 12 and 13.
- Triple quotes ”’ are used to make a comment block (multiple lines of code which are commented).
- Comment block is usually used to give us some information about code (task, author, date, etc.). Example lines 1-4.
- Comment block can also be used to make part of the code ‘inactive’. Meaning, code will still remain, but it won’t be executed. Example lines 17-20.