Python Tutorial

Python Reading Files

To read a file in Python, you need to open the file using the built-in open() function. After opening the file, you can use read()...

Python Opening Closing Files

Python provides several built-in functions for creating, reading, writing files. You don’t need a third-party module to work with files. To access a file for...

Python Date & Time

Python provides date and time related functions in datetime module. There are 5 classes in datetime module. datetimedatetimetimedeltatzinfo datetime datetime class stores both date and time data....

Python Lambda

Lambda functions are similar to regular functions in Python. Lambda functions are small (usually one line) and anonymous functions. Examine the code below. The function...

Python Exceptions

Exception handling is important to prevent crashes. For instance, consider the code below. The function division() simply divides two arguments and returns the result....

Python Classes and Objects

In Python, classes are used to bring related data and functions together. To create a class, use class keyword. In the following code, you can...

Python Functions

Functions are reusable blocks of code that can be executed more than once in a program. You can access a function by its name....

Python Break, Continue, Pass Statements

Break Statement break statement is used in for/while loop structures to exit loop immediately. Suppose that you are searching for an item in a list....

Python While Loops

To execute a block of code over and over again, you can use while statement. while statement executes the code in loop as long...

Python For Loops

For loop is an iterator in Python. It is used to iterate over iterable objects like strings, lists, tuples. # Iterating through a string val =...