Beginners Introduction to the Syntax and Symantics of the Python Programming Language
Variables are not pre-declared in Python.
In Python, conditional operators like
if condition:
... do something ...
else:
... do some-other-thing ...
give different options for different conditions.
For instance:
if age > 18:
print("You are grown-up now.")
else:
print("You are still young.")
In Python, iteration operations are done using loops:
while loop:
while condition:
... do something ...
and
for loop:
for i in a_number:
... do something ...
In Python, the arithmetic operators do exactly what you would expect:
+ means add;
- means subtract;
* means multiply;
/ means divide; and
% means moduli.
Note: Moduli means remainder after division.
Dividing 5 by 2 (5 ÷ 2) gives a remainder of 1.
Hence 5 % 2 = 1;
# is used for comments in Python.
Python comments are just remarks (explanations) you write along side your
code for clarity purposes (help you define what you are doing);
and also for future remembrance of what a piece of code was meant for.
The compiler neither needs nor processes them.
Tip: You don't need to write out comments as you follow our demonstrations.
Python References
For a more thorough explanation of Python, please visit any of the following links:
A Beginner's Python Tutorial - Very comprehensive Python tutorial with plenty of practice examples!
Python Documentation - the Python documentation!
Feel free to do an internet search for "Python Tutorial"!