Why You Should Learn How To Code?
Take It Easy
First of all, keep calm, everything is gonna be alright (listen to Bob Marley).
You don't need to become a professional at programming.
I am not a professional at programming.
So what? Why should you learn to code?
Well, learning Python basics is actually easier than to learn English or French.
And on top of that, it will be helpful if you want to learn any human language.
And it's not enough, it's actually useful for nearly any task involving a computer.
And when I say a computer, I am referring to any electronical device that allows you to automate something which means your smartphone, your tablet, but also your camera, your TV, eventually your car... even your fridge and many other things in your house.
Hold on, calm down, I'm not telling you that you will become a hacker over night (spoiler: I'm not!).
I'm just telling you, the same way your parents helped you learn the basics of your mother tongue and then let you explore the world, in a way I will be your father for Python language learning.
I'll give you the basics and then you will be free to explore as you wish.
If you understand French and/or want to support my work you can have look on the books I've already published on Amazon:
The series of lessons I'm preparing for you right now are probably becoming my new book on Python programming.
So, according to your ease or difficulty to follow and implement the material let me know any constructive criticism you may have.
Feel absolutely free to tell me anything that you think could be an improvement.
Let's talk about the basics
First of all, why Python and not JavaScript or Swift or Java or whatever any other programming language among the thousands out there?
Well, Python is one of the easiest language to start with AND one of the most popular in many industry AND the one that is the preferred language for beginners (Harvard chose it, the French education system chose it, many MOOCs on Coursera and other eLearning platforms chose it as well).
It's a very well documented language with many tutorials available for free and on top of that you don't need to install anything to start.
We are going to use Google Colab which a 100% FREE app available on the web as soon as you have a Gmail account (which is FREE!).
Click on that link to access to the material of this first lesson: python4lingisticslesson1
The link will lead you to an interactive notebook.
This is the reference code that is working so you can only read it, cannot modify it which is better to keep a working code as a reference.
Your first mission, if you accept it, will be to copy/duplicate it so that you will have a second notebook where you will be able to experiment.
Remember the babies who learn the human language, they experiment, they try, they play with the language.
For programming languages that's the same, with 3 major differences:
The lexicon is a lot smaller so you almost have nothing to memorize (which is a good news).
The Python interpreter itself will warn you anytime you make a syntax error (actually we should call it an information message).
Any time you will have a programming bug, chances are that someone else on the internet has already faced and solved that problem.
Python Syntax And Semantics
First of all, the hashtag symbol # is representing a comment.
A comment sginals to the machine to ignore what's written in it.
In a way, a comment is only dedicated to us fellow humans.
I used it to give you some explanations and instructions.
A variable is like in math but a lot more flexible.
If I ask you what number should be added to 1 to get 3?
I hope you will tell 2.
Since I didn't tell you the mistery number, as a math teacher I would write:
solve the equation x + 1 = 3.
Hence, x would be the variable.
But in programming we could say something more concrete.
For example, let say I personalize the message with your first name at the beginning of this article/letter.
Many of my readers likely have different first name.
But all the rest of the article is the same so only your first name is a variable.
Here we are: first_name = your_first_name
You see, it's even simpler than equations because in Python variables can take actual words as names which make them more relevant than just 'x' or 'y' or 'z'.
It's actually recommended to use meaningful names for your variables.
So variables are labels, references to some data.
A data could be a number, a string (of characters) like your name and many other things that we'll see later on.
In this first lesson we'll stick to numbers and strings.
After variables, there are functions.
Functions were initially like in math, but once again it's far simpler and easier to manipulate them.
Let say you want to double a number.
In math you will write something like: f(x) = 2 * x
Anytime you give a number x then f(x) gives you the double.
For example f(3) = 6.
In Python, a function has a name for example double
and parenthesis like in math.
For example double(3) = 6
.
But, contrary to math, a Python function can do a lot of different things.
For example you could have a function that counts the letter of a string.
count_letters("Hello") = 5
But, a function could take more than one argument, for example the function merge_2_strings
.
For example, merge_2_strings("Hello", "World") = "Hello World"
.
These examples above are functions that I'll teach you to make, we call them original functions.
I have a great news, Python comes with a bunch of built-in functions also called primitives (no they are not made by cavemen).
In the notebook I show you some basic primitives very useful.
Finally there is a slightly different way to think about functions, we call that methods.
A method is a function on an object.
Well, an object is something that, at first you don't need to worry about.
But, for those like me who want to understand everything everytime I'll give you some explanations here.
Let say our program wants to model a car which is a physical object.
Any physical object has characteristics that allow us to describe its appearance and functionalities.
The properties of its appearance are called attributes and its functionalities are called methods.
So if my_car
is my object I could call the method .start()
on it and in Python syntax it will be written: my_car.start()
Now let's come back to something very simple, do you remember your first name? Of course you do.
We could want to count how many letters are in it.
So instead of create an original function from scratch we could use the built-in method .count()
.
We could do that because in Python (almost) everything is an object.
Don't worry, the code is self explanatory and you'll be guided.
And if after trying the examples and doing the exercises you feel lost ask your questions and I'll answer to you.
What’s Next?
Well now it's time to put your hands on.
So, if you haven't done it yet click on the Google Colab link here: https://colab.research.google.com/drive/1kvfcczVPzTtiomkZDe8-4-kxkVTs9Lie?usp=sharing
Copy/duplicate it in another notebook (yours) where you'll make the experiments.
Let me know on the comments what do you think about this first lesson.
Is it correct, too difficult, too easy?
And see you tomorrow for the next lesson.
Noted!
Au fact.. I have to get home to get on my computer and I need to get some PWs I don't gave with me.. I will make a more comprehensive comment then!