Python 3: Lesson 1 - Installation & Your first line of code
Python 3: Lesson 1 - Installation & Your first line of code

By CN00b | Python | 16 Sep 2019


Hi people,

In this lesson i'll show you how to install, setup and write your first line of code in Python.
Head to the official site and in the upper left side you'll see Downloads tab. Select your operating system (e.g. Windows) and make sure you download the latest version.

351665157-6227b05728266b770cdc77835117be38b33ca101df1b4873b20981ca3484aa51.jpeg
Run the installer and once the prompt window appears, make sure you check "Add Python to PATH"before continuing. This move add the interpreter in your execution path. You can do this separate, but why to get things complicated?
Now, juck click "Install Now".

351665157-2ef02b763ba1ae37b834e8d3afab3759568a0ef04bf363790b2f216342917781.jpeg
So, the instalation process just finished and you are not sure if it's installed or not?
Well, here comes the easy part: press "win key + r" and type "cmd". A black window will appear and here will be your first interaction with Python. Don't worry, you are not forced to learn Python programming in this sad black window ( only if you want to). Python has built in an interpreted, called IDLE where you can code or you can use an external interpreter ( recommended).
I the black window, type "python" and hit enter. This will show you the version installed and you are ready now to write your first Python code.
"Interpreted" it's a new word for you? Well, now you are ready for your first lines of code.

351665157-3dde642796275264a1490d93a9dac115084d695807dadc419adf1b1ee73b34fc.jpeg
Type" 2+2 " and hit enter. Surprised? This is what Python do! Not wasting time like other programming languages to compile. This makes is simple to use and understand.
Now, try to type and enter "hello". Not working, aa? :P This is because it's interpreted as a string and must be declared. I'll talk about this later.
So i said earlier about your first code or program in Python.
Well, the most important function in Python, is the " print " function. You'll use this 90% of time. This will show you what you want to express in your code.
As in many programming languages the first program in called "Hello World", i'll name our first line of code " Hello Publish0x" :P
Important:
- A big difference you must count, the whitespaces. Python doesn't care about whitespaces, you can have as many as you want in your code, as long as they are not at the beginning at the code. For example, "space 1+1" won't work, will give you an indentation error. In Python, whitespaces matters only at the beginning of the code. Python uses 4 spaces to organize code in code blocks. This makes it easier to use, read and debug.

So, the print function. To print, you must declare something in parantheses.

351665157-c87bdf3590d53f37a83acd1d6bee5ba8bf83493aacc5fb9c2dc908c91b095d95.jpeg

print(1+1) - 0,1,2,3,4,5... are integers, words are strings. Strings are marked with " ".
print(Hello Publish0x) - what, error? well, Strings are marked with " ".
print("Hello Publish0x")
Congrats, you just wrote your first Python line of code!

See you in the next lesson,

Cheers!


CN00b
CN00b

IT Hardware/ Software Noob Crypto Enthusiast Mountains Explorer


Python
Python

In this blog, i'll provide various lessons and tips for begginers and not only (later) about Python (version 3.xx), how to get started, how to use it, how to build an AI, etc. I'll try to cover more parts, but easy to understand, maybe 1-2 lessons/day.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.