Introduction to Python Statements

Python vs Other Languages


Let's create a simple statement that says: "If a is greater than b, assign 2 to a and 4 to b"

Take a look at these two if statements (we will learn about building out if statements soon).

Version 1 (Other Languages)

if (a>b){
    a = 2;
    b = 4;
}

Version 2 (Python)

if a>b:
    a = 2
    b = 4

Indentation

Here is some pseudo-code to indicate the use of whitespace and indentation in Python:

Other Languages

if (x)
    if(y)
        code-statement;
else
    another-code-statement;

Python

if x:
    if y:
        code-statement
else:
    another-code-statement

Note how Python is so heavily driven by code indentation and whitespace. 
This means that code readability is a core part of the design of the Python language.

Comments

Post a Comment

Popular posts from this blog

Solve the Sudoku Python

Solve the Sudoku Java

Find Duplicates Java