Learning Python - Part 1 - Familiarise yourself with the Python Console and write your first Python program!

in #programming7 years ago (edited)




Before reading this post you should download Python 3 from here. 

Python 2 or 3

 Today, two versions of Python are available: Python 2 and the newer Python 3.  As a beginner i recommend you to go for Python 3, and all the code that will be in this course will be in Python 3.

The Python Console

When Python is downloaded there is something that comes with it wich is the IDLE.

Open it and you will see a page like this.

Try to type in the console a number!

>>> 231 

231

When you type a number in the console it returns that number.
Now try to type for example

>>> 2 + 2
4

This time type a word or a letter

>>> i love pizzas
SyntaxError: invalid syntax

The python console doesn't accept words unless you type with it a certain word: print.

Print

Print is one of the ways to print text in the console, it is as easy as that.

Now go to File > New file. A new window will appear and type in it:

>>> print("Hello World!")

Then save it anywhere you want and run it (you can just click "f5").

Hello World!

The code will be executed, now you learned your first "FUNCTION" we will talk more about it in future posts!




 

Coin Marketplace

STEEM 0.27
TRX 0.13
JST 0.031
BTC 62177.56
ETH 2918.14
USDT 1.00
SBD 3.66