Learning Python Part-25: Error and Exceptions

When writing a program, most of the times we will encounter errors. There are various possible reasons for which errors are generated. There are  two distinguishable types of errors: syntax errors and exceptions.Syntax Erros:Not following the proper syntax of the programming language will generate a syntax error. It is also known as parsing error.Example:if a < … Continue reading Learning Python Part-25: Error and Exceptions

Learning Python Part-24: Recursive function, Lambda Function

Python Recursive Function:Recursion is the process of defining something in terms of itself. We know that in Python, a function can call other functions. It is even possible for the function to call itself.  These type of construct are termed as recursive functions.Following is an example of recursive function to find the factorial of an integer.Factorial … Continue reading Learning Python Part-24: Recursive function, Lambda Function

Learning Python Part-23: Python Functions

In Python, function is a group of statements that perform a specific task. As we discussed about modules, how they help manage the code, Functions help break our program into smaller and modular chunks.As our program grows larger and larger, functions make it more organized and manageable.Furthermore, it avoids repetition and makes code reusable.Syntax: def … Continue reading Learning Python Part-23: Python Functions

Learning Python Part-22: Python Flow Control

Before we go ahead and discuss about python flow control using if statements, for loop and while loop. Let's understand Python indentation quickly.Python Indentation:Programming languages like C, C++, Java use braces { } to define a block of code. However, Python uses indentation to define the code block. Indentation basically means, use of whitespaces.Generally 4 whitespaces (4 … Continue reading Learning Python Part-22: Python Flow Control

Learning Python Part-21: Python Files and Directories

Python Files:File is a named location on disk to store related information. It is used to store data in a non-volatile memory (e.g. hard disk) persistently. Since, random access memory (RAM) is volatile memory, it loses data whenever computer is turned off or rebooted, so we use files for storing the data.When we want to read … Continue reading Learning Python Part-21: Python Files and Directories