All Posts

Components of a Python program

Components of a Python program

In this tutorial, we will learn about the basic components of a Python program. A Python program may have several components to perform a specific task. The main components of a Python program are as follows:

  • Comments
  • Expressions
  • Statements
  • Blocks
  • Functions
  • Modules

Comments

Comments are lines in your code that are not executed. They are used to provide explanations or documentation for the code.

Expressions

Expressions are combinations of symbols like operators and operands that represent a value.

2 + 3 # Python Expression
5

result = 2 + 3 # Python Statement
print(result) # Python print statement
5

 

Statements

A statement performs a certain action. It is an instruction that the Python interpreter can execute. A Python statement is made up of one or more Python expressions.

Blocks

Blocks are group of statements that are indented at the same level.

 

Functions

Functions are blocks of reusable code that perform a specific task. We can define our own functions or use built-in functions.

Python program components

 

—

Python Tutorials

Python Tutorial on this website can be found at:

https://www.testingdocs.com/python-tutorials/