Sri has Published 22 Articles

How many types of inheritance are there in Python?

Sri

Sri

Updated on 29-Jun-2020 11:16:47

Inheritance is concept where one class accesses the methods and properties of another class.Parent class is the class being inherited from, also called base class.Child class is the class that inherits from another class, also called derived class.There are two types of inheritance in python −Multiple InheritanceMultilevel InheritanceMultiple Inheritance −In multiple ... Read More

Explain subn() methods of “re” module in Python ?

Sri

Sri

Updated on 30-Jul-2019 22:30:26

A regular expression is a special sequence of characters that helps you match or find other strings or sets of strings, using a specialized syntax held in a pattern. Regular expressions are widely used in UNIX world. The re module in python refers to the module Regular Expressions (RE). It ... Read More

How to get doc strings in Python?

Sri

Sri

Updated on 30-Jul-2019 22:30:26

Doc strings is the documentation string which is string literal, and it occurs in the class, module, function or method definition, and it is written as a first statement.There are two types of a Doc strings:one-line Doc stringsmulti-line Doc stringsThese are mainly used in DataScience /Machine Learning Programming.one-line Doc stringsThis type of Doc ... Read More

How are arguments passed by value or by reference in Python?

Sri

Sri

Updated on 30-Jul-2019 22:30:26

Python uses a mechanism, which is known as "Call-by-Object", sometimes also called "Call by Object Reference" or "Call by Sharing"If you pass immutable arguments like integers, strings or tuples to a function, the passing acts like Call-by-value. It's different, if we pass mutable arguments.All parameters (arguments) in the Python language ... Read More

What is the difference between del, remove and pop on lists in python ?

Sri

Sri

Updated on 30-Jul-2019 22:30:26

It does't matter how many lines of code you write in a program. When you want to remove or delete any elements from the Python list, you have to think about the difference between remove, del and pop in Python List and which one to useremove : remove() removes the first matching value ... Read More

How does Python's super() work with multiple inheritance?

Sri

Sri

Updated on 30-Jul-2019 22:30:26

Before going to explain super() first we need to know about multiple inheritance concept.Multiple inheritance : Means one child class can inherit multiple parent classes.In the following example Child class inherited attributes methods from the Parent class.Exampleclass Father:    fathername = ""    def father(self):    print(self.fathername) class Mother:   ... Read More

How to write a recursive function in Python?

Sri

Sri

Updated on 30-Jul-2019 22:30:26

A recursive function is a function that calls itself during its execution. This enables the function to repeat itself several times, outputting the result and the end of each iteration. Recursion has something to do with infinity. Following is an example of recursive function to find the factorial of an integer.Factorial of a ... Read More

How To Do Math With Lists in python ?

Sri

Sri

Updated on 30-Jul-2019 22:30:26

We  not only use lists to store a collection of values, but we also use it to perform some mathematical calculations or operations to do.Example 1import math data = 21.6 print('The floor of 21.6 is:', math.floor(data))OutputThe floor of 21.6 is: 21How To Calculate the Weighted Average of a ListExample 2cost ... Read More

What is tuple unpacking in Python?

Sri

Sri

Updated on 30-Jul-2019 22:30:26

Before defining tuple unpacking we need to understand what is tuple.Tuple : In Python tuples are used to store immutable object.A tuple is a sequence of immutable Python objects. Tuples are sequences, the tuples cannot be changed and tuples use parentheses. it assigns (RHS)right hand side of values into (LHS)Left ... Read More

Is Python Object Oriented or Procedural?

Sri

Sri

Updated on 30-Jul-2019 22:30:26

Yes, Python support both Object  Oriented and Procedural  Programming language as it is a high level programming language designed for general purpose programming. Python are multi-paradigm, you can write programs or libraries that are largely procedural, object-oriented, or functional in all of these languages. It depends on what you mean by ... Read More

Advertisements