-
WHAT IS DATETIME MODULE IN PYTHON
Python Datetime Module Python Datetime Module in Python provides us the different features to work with dates as date object by importing the datetime module. Current Date Python code to import the datetime module to access current date output (Note-it will show the current date and time, at the time of execution of code on…
-
WHAT IS POLYMORPHISM IN PYTHON
PYTHON POLYMORPHISM Polymorphism is one of the OOP(object-oriented programming) concepts. Polymorphism in Python is the ability of an object to take many forms. The word “polymorphism” means “many forms”, and in programming, it refers to methods/functions/operators with the same name that can be executed on many objects or classes. Function Polymorphism in Python In Python…
-
WHAT IS A PYTHON MODULE
Python Module Module is a file or library of codes or set of methods, that can be included in our Application. How to create a module? Creating Module- Module can be created by saving the code in a file with the file extension .py. Python Code- Save below code in file named mymodule.py Using Module-…
-
WHAT IS PYTHON ITERATOR
Python Iterators An Iterator is an object that contains a countable no. of values or elements that can be traversed. An iterator allows a programmer to traverse through all the elements of a collection or iterable objects. An iterator is an object which implements the iterator protocol, which consist of the methods __iter__() and __next__().…
-
WHAT IS PYTHON INHERITANCE
Python Inheritance Inheritance is a mechanism of object-oriented programming for deriving new classes (sub classes) from existing ones such as super class or base class. It allows us to define a class that inherits all the methods and properties from another class. Parent class or base class, is the class being inherited from. Child class…
-
WHAT IS PYTHON CONSTRUCTOR
Python Constructor- A constructor is a special type of method or function that is used to initialize the instance members of the class. Constructor definition is automatically executed when we create the object of the class. Constructors also verify that there are enough resources for the object to perform any start-up task. The _init_() method…
-
WHAT IS A CLASS AND OBJECT IN PYTHON
Definition of Python Class and Object Python Class The Class is a logical entity that has some attributes and methods, in other words, we can also say that the class is like an object constructor or a “blueprint” for creating objects. Python Objects The Object is an entity that has a state and behavior. How…
-
WHAT ARE LAMBDA FUNCTIONS IN PYTHON
Definition of Python Lambda Functions Lambda Functions are anonymous or unnamed short functions. Syntax of Lambda Functions in Python Examples of Python Lambda Functions Lambda function with single argument Code Output Lambda function with multiple arguments Lambda functions can take any number of arguments Code output
-
HOW TO USE FUNCTIONS IN PYTHON
WHAT IS A FUNCTION IN PYTHON? A function is a named sequence of statements or a block of code that only runs when it is called by its name. We can pass data, known as parameters, into a function. On calling a function it will execute the block of code and can return data as…
-
HOW TO USE FOR LOOPS IN PYTHON
A For loop is used to execute a set of statements, once for each item in a list, tuple, set, dictionary, string, or any iterable object, etc. As shown in below example it will print each fruit available in the list output The break Statement The break statement is used to stop the loop before…
-
HOW TO USE WHILE LOOP IN PYTHON
The while Loop While loop is used to execute a set of statements as long as the provided condition is true, as shown in below example that i will be printed as long as i is less than 5 output The break Statement The break statement is used to stop the loop even if the…
-
HOW TO USE IF ELSE IN THE PYTHON
Use of if, elif, if… else Statements in Python