AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

Python Syntax


Python Tutorial » Python Syntax

Python syntax can be executed by writing directly in the Command Line:

Welcome to your first page Python tutorial!:
>>> print("Hello my Python tutorial!")
Hello my Python tutorial!

Or creating a python file on the server, as .py extension file, and running it in the Command Line:

Welcome to your first page Python tutorial!:
E:\Users\Your_Directory_Name\python_myfile.py


Python Indentation - examples


Indentation refers to the spaces at the beginning of a code line.
Python uses indentation to indicate a block of code.

Example:
if 9 > 7:
  print("Nine is greater than seven!")
Output:
Nine is greater than seven!


Python will give you an error if you skip the indentation:

Example: Syntax Error:
if 9 > 7:
print("Nine is greater than seven!")
Output:
ERROR


The number of spaces is up to you as a programmer, but it has to be at least one.

Example:
if 9 > 7:
  print("Nine is greater than seven!")
if 9 > 7:
   print("Nine is greater than seven!")
Output:
Nine is greater than seven!
Nine is greater than seven!


You have to use the same number of spaces in the same block of code, otherwise Python will give you an error:

Example: Syntax Error:
if 9 > 7:
  print("Nine is greater than seven!")
   print("Nine is greater than seven!")
Output:
ERROR




pithon free online tutorial
Python Syntax - python

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.