The Python language has many similarities to Perl, C and Java.
However, there are definite differences between the languages
Python is meant to be an easily readable language. Its formatting is
visually uncluttered and it uses English keywords where other
languages use punctuation. Unlike many other languages, it does not
use curly brackets to delimit blocks, and semicolons after
statements are optional. I will pick out a few of the syntactic
details that stand out and talk briefly on them.
Indentation and Escape sequences
Python uses whitespace indentaton, rather than curly user brackets
to delimit blocks An increase in indentation comes after certain
statements, e.g nested statements; a decrease in indentation
signifies the end of the current block.
def add_three(x):
sum = x + 3
if (x.isnumeric()):
print(sum)
else:
print("Please enter a number")
Python emphasises readability and clean code. Escape sequences also
help in this regard. Python's interaction with users is also
commendable. Using the input
keyword, data can be
collected from users. For this data to be entered on a new line,
Python provides a code for that.
input('Please enter your name: \n')
result:
Please enter your name:
*cursor*
Quotation and Comments in Python
A hash sign (#) that is not inside a string literal begins a
comment. All characters after the # and up to the end of the
physical line are part of the comment and the Python interpreter
ignores them.
#A comment
print("Showing comment")
Python accepts both single (') and double (") quotation marks.
However, as with other languages If you are starting an expression
with a single quotation mark, kindly finish it with a single
quotation mark, else, the interpreter will scream and point you
precisely to your error. Another fun fact about the Python
interpreter, the error messages are quite informative and detailed.