Basics of Python

Basics of Python:

When you start to learn Python very first thing you've to learn the basics of python. One of the easy to learn a programming language better, first of all, learn the basics of that language is the key to learn to program. so before you start to learn the basics of Python Programming first you must read Introduction to Python then continue with this. It becomes easier for you to learn the basics of python

In this Section, We will discuss the Basics of Python Programming with example. In which, we include various basics of Python Programming language comments, literal (int and complex literals), number, string, variable, data types (Numbers, List, Tuple, Strings, Dictionary, etc), identifier, Indentation, Selection (if, if-else and if-elif), Iteration (while loop, for loop, nested loops), and Control statements like break statement, continue statement, pass statement in Python.


All of the basics of Python Programming language given below:


1. Comments: In python programming, comments are represented by a symbol hash (#) and are mainly used as notes for the reader of the program. We can use a single line and multi-line comments in Python. A comment may appear at the start of a line of code, but not within a string literal.
example:  # Print is a statement
                 # print("hello")
              """ “”” for Multi line comments

2. literal: A literal is that the parser recognizes as a syntax for writing an object directly.
example:
-2, -1, 0, 1, 2 (int literals)
2+3j, 0+5j, 2j, -3-5j (complex literals)

Also, read Introduction to Python

3. Number: Number Data Type in Python, Python supports integers, floating-point numbers, and complex numbers.
example:
int, float, and complex
5 is integer whereas
5.0 is a floating-point number.

4. String: In Python Programming, A string is a sequence of characters. A string is basically a group of words. Strings can be written as:

example:
Single quote (‘hello world’)
Double quote (“hello world”)
Three quotes or multiline string  ("""hello world""")

5. Variable: A variable in a python program gives data to the computer for processing. Every value in Python has a datatype. There are different data types in Python that are Numbers, List, Tuple, Strings, Dictionary, etc.

6. Identifier: In Python Programming, An identifier is used to identify a variable, function, class, module or another object. It starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9).

7. Indentation: Indentation is used at the beginning of a statement. when the statements with the same indentation belong to the same group called a suite.

8. Selection: Selection statements are also referred to as decision making or branching statements. The selection statements are used to select a part of the program that executed based on a condition. Python provides the following selection statements.


if statement

if-else statement
if-elif statement

9. Iteration: Python programming language provides the following types of loops to handle looping requirements.


while loop

for loop
nested loops

10. Control Statements: The control statements are the statements that change execution from its normal sequence. when execution leaves a scope then all automatic objects created in that scope are destroyed. Python supports the following control statements.


Continue Statement -  It will returns control to the beginning of the loop.

.
Break Statement - It brings the control out of the loop. In this, we use the break keyword in the program.


Also, read Introduction to Python


Pass Statement-  In the case of Pass statement is additionally used to write empty loops. Pass statement is also used for empty control statements, functions and classes with pass keyword.