Python break Statement

The break statement in Python is used to get out of the current loop. We can’t use break statement outside the loop, it will throw an error as “SyntaxError: ‘break’ outside loop“. We can use break statement with for loop and while loops. If the break statement is present in a nested loop, it terminates …

Python break Statement Read More »

Python while Loop

Python while loop is used to repeat a block of code until the specified condition is False. The while loop is used when we don’t know the number of times the code block has to execute. We should take proper care in writing while loop condition if the condition never returns False, the while loop …

Python while Loop Read More »

Python for Loop

Python for loop is used to iterate over an iterable. Any object that returns its elements one by one to be iterated over a for loop is called Iterable in Python. Some of the common examples of iterables are List, Tuple, and String. The for loop is the core building block of python programming. Implementing …

Python for Loop Read More »

Python if else elif Statement

Python if-elif-else statement is used to write a conditional flow code. The statements are in the order of if…elif…else. The ‘elif’ is short for ‘else if’ statement. It’s shortened to reduce excessive indentation. The else and elif statements are optional. There can be multiple elif statements. We can have only one else block for an …

Python if else elif Statement Read More »

Python return Statement

The python return statement is used in a function to return something to the caller program. We can use the return statement inside a function only. In Python, every function returns something. If there are no return statements, then it returns None. If the return statement contains an expression, it’s evaluated first and then the …

Python return Statement Read More »

Python Functions

Functions in Python is a block of code with a name. We can call a function by its name and the code inside the function block will be executed. We can’t use reserved keywords as the function name. A function name must follow the Python identifiers definition rules. Function Parameters We can pass some data …

Python Functions Read More »

Python Operators

Operators in Python are used to perform a specific operation on variables and values. Python has a lot of operators that are either keywords or special characters. The values or variables on which these operators work are called operands. Types of Python Operators Python operators can be classified into the following categories. Arithmetic Operators Logical …

Python Operators Read More »

Python Data Types

Python is an object-oriented programming language. Every variable in Python is an instance of some class. There are many pre-defined Python data types. We can create our own classes to define custom data types in Python. What are the Popular Data Types in Python? Some of the popular data types in Python are: Numbers – …

Python Data Types Read More »

Indentation in Python

Indentation in Python is used to create a group of statements. Many popular languages such as C, and Java uses braces ({ }) to define a block of code, and Python uses indentation. What is Indentation in Python? Indentation in Python refers to the whitespaces at the start of the line. We can create indentation …

Indentation in Python Read More »