How to create function in Python

A function is a block of code that performs some specific task and returns back to the caller. It has a unique name.

They are helpful when need to perform the same task with different-different values or require to use the same block of code in other places within the program.

If any changes require in the future then only need to update the function code and it will automatically make changes where the function it been called.

The main aim of a function is –

  1. To make the program more readable, and organized,
  2. Reduce code repetition.

How to create function in Python

Read more

Loop control statements in Python

Loop control statements are used to handle the flow of the loop e.g. terminate the loop or skip some block when the particular condition occurs.

There are the following types of loop control statements in Python –

  1. break
  2. continue
  3. pass

Loop control statements in Python

Read more

Different Types of Loop statement in Python

Loop statements are an essential part of any programming language, as they allow us to repeat a block of code multiple times. This reduces the coding work and the frustration of writing the same code multiple times.

In Python, there are different types of loop statements that are used for various purposes.

There are the following types of loops available in Python –

  1. While
  2. for

You can also specify the else block with a looping statement.

Different Types of Loop statement in Python

Read more

Different types of Logical operators in Python

Logical operators are used to combine conditional statements and perform logical operations. It plays a crucial role in decision-making and control flow in a program.

If in your program there is a nested if statement to execute a block of code, it works but it also makes the code lengthy.

For solving this you can use logical operators by using that combine more than one relational expression and according to the logical operator return true or false.

They are 3 logical operators in Python –

  1.  And
  2. Or
  3.  Not

Different types of Logical operators in Python

Read more