- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10784 Articles for Python
781 Views
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: mothername = "" def mother(self): print(self.mothername) class Child(Father, Mother): def parent(self): print("Father :", self.fathername) print("Mother :", self.mothername) s1 = Child() s1.fathername = "Srinivas" s1.mothername = "Anjali" s1.parent()OutputFather : Srinivas Mother : AnjaliIn the following example shows ( i.e) super() works with multiple inheritancessuper() : ... Read More
434 Views
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 or object, not a specific indexing. lets say list.remove(value)Examplelist=[10, 20, 30, 40] list.remove(30) print(list)Output[10, 20, 40]del : del removes the item at a specific index. lets say del list[index]Examplelist = [10, 20, 30, 40, 55] del list[1] print(list)Output[10, 30, 40, 55]pop : pop removes the item at a specific index and returns ... Read More
12K+ Views
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 are passed by reference. It means if you change what a parameter refers to within a function, the change also reflects back in the calling function.Examplestudent={'Archana':28, 'krishna':25, 'Ramesh':32, 'vineeth':25} def test(student): new={'alok':30, 'Nevadan':28} student.update(new) print("Inside the function", student) return test(student) print("outside the function:", student)OutputInside the function ... Read More
921 Views
Yes, Python supports polymorphism. The word polymorphism means having many forms. Polymorphism is an important feature of class definition in Python that is utilised when you have commonly named methods across classes or sub classes. Polymorphism can be carried out through inheritance, with sub classes making use of base class methods or overriding them. There are two types of polymorphism Overloading Overriding Overloading Overloading occurs when two or more methods in one class have the same method name but different parameters. Overriding Overriding means having two methods with the same method name and parameters (i.e., method signature). One ... Read More
3K+ Views
Yes, Python supports multiple inheritance. Like C++, a class can be derived from more than one base classes in Python. This is called Multiple Inheritance. In multiple inheritance, the features of all the base classes are inherited into the derived class. Let us see the syntax − Syntax Class Base1: Body of the class Class Base2: Body of the class Class Base3: Body of the class . . . Class BaseN: Body of the class Class Derived(Base1, Base2, Base3, … , BaseN): Body of the class The Derived class inherits from both Base1, Base2 and Base3classes. ... Read More
406 Views
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 inheritance one child class can inherit multiple parent classes.Exampleclass Father: fathername = "" def father(self): print(self.fathername) class Mother: mothername = "" def mother(self): print(self.mothername) class Daughter(Father, Mother): def parent(self): print("Father :", self.fathername) ... Read More
644 Views
Numerical Dataset in Python is for numerical datatypes. Sorting algorithm for integers, includes the following in Python − Bubble sort Shell sort Selection sort Bubble Sort in Python Bubble Sort is comparison-based sorting. The adjacent elements are compared and swapped to make the correct sequence − Example def bubblesort(myList): # Swap the elements to arrange in order for iter_num in range(len(myList)-1, 0, -1): for idx in range(iter_num): if myList[idx]>myList[idx+1]: temp = myList[idx] myList[idx] = myList[idx+1] myList[idx+1] = temp # Unsorted List myList = [40, 23, 7, 49, 32, 98, 76, 48, 87] print("Unsorted List = ", ... Read More
7K+ Views
CPython CPython is the implementation of the language called “Python” in C. Python is an interpreted programming language. Hence, Python programmers need interpreters to convert Python code into machine code. Whereas Cython is a compiled programming language. The Cython programs can be executed directly by the CPU of the underlying computer without using any interpreter. Cython Cython is designed as a C-extension for Python. The developers can use Cython to speed up Python code execution. But they can still write and run Python programs without using Cython. But the programmers have to install both Python and C-compiler as a pre-requisite ... Read More
2K+ Views
Python defines variety of data types of objects. These objects are stored in memory and object mutability depends upon the type, like Lists and Dictionaries are mutable it means that we can change their content without changing their identity. Other objects like Integers, Floats, Strings, and Tuples have no provision to change there assigned value for an index.List is mutable: Lists are just like the arrays, declared in other languages. Lists need not be homogeneous always which makes it a most powerful tool in Python. Lists are mutable, and hence, they can be altered even after their creation.Example#Write a python ... Read More
6K+ Views
Compilation − The source code in python is saved as a .py file which is then compiled into a format known as byte code, byte code is then converted to machine code. After the compilation, the code is stored in .pyc files and is regenerated when the source is updated. This process is known as compilation. Linking − Linking is the final phase where all the functions are linked with their definitions as the linker knows where all these functions are implemented. This process is known as linking. image compilation.jpg----- Note − Python programs are both compiled as well as ... Read More