Professional Documents
Culture Documents
Home /
Tutorial /
Python Syntax
Python Syntax
By Manoj 7.1 K Views 16 min read Updated on June 15, 2021
In this module, we will learn the basic Python syntax to write a Python program. We will be introduced to various elements of the
Python syntax such as Python line structure, whitespace, indentation, identifiers, and more.
Python Tutorial
Python Tutorial
Fundamentals of Python
Python Introduction
What is Python?
Python Version
Python Frameworks
Python Syntax
Comments in Python
Python Variables -
Constant, Global & Static
Variables
Numbers in Python
String in Python
Python Lists
Tuple in Python
Python Sets
Python Dictionary
Python Operators
Type conversion in
Python
Python If Else
Statements
Python Functions -
Define & Call a Functions
in Python
Lambda Function in
Python
Python Built in
Functions with Examples
A syntax of any language refers to the structure of that language which includes a certain set of rules, subjective to that
specific language. The Python syntax also comprises a set of rules and elements that collectively make up the Python
Syntax.
Following is the list of topics that we will cover in this module, in case you want to jump to a specific one.
Variable = 6
NOTE: A logical line that only contains spaces, comments, or tabs are called blank lines and they are ignored by the
interpreter.
Looking for Data Science with Python training All-in-1 Combo Training? Enroll now!
Example:
print ("this\
We can also use explicit line joining to join two or more physical lines into a logical line, using back slash.
Example:
'March', 'April']
Example:
a=10; b=30;
print(a); print(b);
Most of the programming languages provide indentation for better code formatting and don’t enforce to have it. But in
Python it is mandatory. This is why indentation is so crucial in Python.
For example, if we run the following code, we will get an error of ‘expected indentation’:
a=1
if a>0 :
Identifiers
Go for this in-depth job-oriented Python Training in Hyderabad now!
Identifiers in Python are nothing but user-defined names to represent programmable entities like (Python Variables, Python
Functions, Python Class, Python Modules), or any other objects. But, there are a few rules that we need to follow while
defining an identifier. They are:
We can use a sequence of letters [lowercase (a to z) or uppercase (A to Z)], and we can also mix up digits (0 to 9) or an
underscore (_) while defining an identifier.
We can’t use digits to begin an identifier’s name.
We should not use Reserved Keywords to define an identifier.
Other than underscore (_), we are not allowed to use any other special characters.
Even though python doc says that we can name an identifier with unlimited length, it is not entirely true. Using a large
name (more than 79 chars) would lead to the violation of a rule set by the PEP8 standard.
Reserved Words
Reserved words are nothing but a set of special words, which are reserved by Python and have specific meanings.
Remember that we are not allowed to use keywords as Variables in Python.
Reserved words in Python are case sensitive. Following table shows all these reserved words used in Python.
as el if or yield
Python Quotations
In Python, single quotes and double quotes, both are supported for strings. If we have started a string with a single quote, it
is mandatory to end it with a single quote only. The same goes with double quotes.
Example:
This brings us to the end of this module to Learn Python. We learned about the Python Syntax along with the Python basics
Syntax and Python Coding. Next module highlights Python variables. See you there!
Further, check our offers for Python training in London and prepare to excel in career with our free Python Interview Q
uestions
Previous Next
Course Schedule
Name Date
2022-05-07 2022-05-08
2022-05-14 2022-05-15
2022-05-21 2022-05-22
Leave a Reply
Your email address will not be published. Required fields are marked *
Comment
Name * Email *
Post Comment
Browse Categories
Master Program
Big Data
Data Science
Business Intelligence
Salesforce
Cloud Computing
Mobile Development
Digital Marketing
Database
Programming
Testing
Project Management
Website Development
Chennai Jersey City Dubai Los Angeles San Francisco Singapore Toronto Bangalore Chicago Houston
Hyderabad London Melbourne New York San Jose Sydney Atlanta Austin Boston Charlotte Columbus
Dallas Denver Fremont Irving Mountain View Philadelphia Phoenix San Diego Seattle Sunnyvale
Washington Ashburn Kochi Kolkata Pune Noida Jaipur Delhi Gurgaon Mumbai Lucknow Gorakhpur
MEDIA
CONTACT US
TUTORIALS
COMMUNITY
INTERVIEW QUESTIONS