Python Getting Started
Syntax :
Python scripts can be directly executed using terminal/cmd
print('Hello Python')
#PYTHON OUPUT
Hello Python
Executing using a file.
step 1 ) Go to the directory where your python script is located.
step 2 ) Open Command Line your file name example: python my_first_python.py.
Note: python
must be mentioned before the file name.
Python code is easily understandable its emphasis on clean and efficient code. unlike any other server-side Programming language Python coding structure differs
Other programming language use {brackets} to structure code and for them. But Python indentation of code is for readability.
Example :
if 12 > 5:
print('Yes Twelve is greater than Five')
#PYTHON OUPUT
Yes Twelve is greater than Five
Note : In above example their is
:(colon)
insisted of{ (barckets) }
if 12 > 5:
print('Yes Twelve is greater than Five')
#PYTHON ERROR OUPUT
IndentationError: expected an indented block
Commenting in Python
#
is used for commenting in python.
print('This line will be printed')
#print('This line will not be printed')
#PYTHON OUPUT
This line will be printed