Programming is interesting and extremely popular nowadays. But it feels like most of modern books are either for people who are already familiar with programming or to far away from something real world. Easy case, my nephew is trying to learn programming but has some old fashioned courses in school with programming languages that are not practical at all.
The purpose for this series of articles is to build some middleground. That is simple to start with, but applicable to real world problems.
There are many different programming languages that fits into this problem but I believe Python is the simplest one to start with.
Let’s dive in and write our first program straight away!
# prints "Hello world!" to output
print("Hello world!") # let's run
Let’s put this two lines of code in file main.py
and try to execute it in terminal by running the following command python main.py. And that’s it. First program is executed and printed Hello world! message to the output!
Let’s walk through the code: print – is a special function, that prints everything that is passed to it as a parameter. It’s pretty powerful, but in this particular example we are using it in a very simple way, just passing a string as a parameter.
Strings in python could be denoted via single or double quotation marks, so 'hello' and "hello" are identical.
The last interesting thing in this sample is # signs. It’s a comment. Everything that goes after it is for human, and will be ignored by interpreter. However any code on a new line is not a comment automatically.
This is a very basic code to start with. Let’s continue with more interesting scenarios in next articles
Leave a comment