[ SRE_ARENA ]
PYTHON BASICS & SYNTAX

The Language of Automation.

Implementation Code: 1. Syntax & Indentation
PYTHON
if 5 > 2:
    print('Yes')
    print('This is part of the if block')

# If you forget the indentation, Python crashes
if 5 > 2:
print('Crash') # IndentationError!

# You can use multiline strings as comments
'''
This is a multiline string that is not assigned to a variable,
so Python simply ignores it during execution.
'''
DOWNLOADING CONCEPT: 1. SYNTAX & INDENTATION...

↳Unlike C++ or JavaScript which use curly braces {} to define blocks of code, Python uses indentation (whitespace at the beginning of a line).

  • ↳If you skip the indentation, Python will throw an IndentationError.
  • ↳The standard is to use 4 spaces.
  • ↳Comments in Python start with a #.
  • ↳Python does not really have a syntax for multi-line comments, so developers often use multi-line strings ('''...''') not assigned to a variable, which Python ignores.
▲ LIVE INCIDENTA script is failing because someone forgot how Python types work.
sre@arena:~/python-basics
sre@arena:~$ python -c "print('Server ' + 5 + ' is down')"