AmitDiwan has Published 11365 Articles

Essential Python Tips And Tricks For Programmers?

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:39:26

153 Views

We are going to cover some useful python tricks and tips that will come handy when you are writing program in competitive programming or for your company as they reduce the code and optimized execution. Get n largest elements in a list using the module heapq Example import heapq ... Read More

Count Negative Numbers in a Column-Wise and Row-Wise Sorted Matrix using Python?

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:29:20

428 Views

In this example, we will count Negative Numbers in a Column-Wise and Row-Wise Sorted Matrix. At first, we will create a matrix − mat = [ [-1, 3, 5, 7], [-6, -3, 1, 4], [-5, -1, -10, 12] ] Pass the ... Read More

Generate all permutation of a set in Python?

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:24:43

4K+ Views

Arranging all the members of a set into some order or sequence and if the set is already ordered, rearranging (reordering) its elements is called permutation. Generate all permutations using for loop We will generate permutations using for loop − Example def permutFunc(myList): # No permutations for empty list ... Read More

Does Python support polymorphism?

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:21:42

920 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 ... Read More

Does Python support multiple inheritance?

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:19:02

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: ... Read More

Quine in Python

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:17:14

1K+ Views

The Quine is a program, which takes no input, but it produces output. It will show its own source code. Additionally, Quine has some conditions. We cannot open the source code file inside the program. Example 1 Here a simple string formatting is working. We are defining a variable ‘a’, ... Read More

Timer objects in Python

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:15:19

3K+ Views

In Python, Timer is a subclass of Thread class. Calling the start() method, the timer starts. Timer objects are used to create some actions which are bounded by the time period. Using timer object create some threads that carries out some actions. The Timer is stopped using the cancel() method. ... Read More

What is the difference between Cython and CPython?

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:09:59

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 ... Read More

Difference between various Implementations of Python?

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:08:24

167 Views

Most developers know about python, irrespective of what python is implemented in their system. Therefore, what do I mean by “python”, is it a python the abstract interface? Do we mean CPython, the common Python implementation (not the Cython)?. Or we mean something else entirely? Or we mean Jython or ... Read More

Write a sorting algorithm for a numerical dataset in Python?

AmitDiwan

AmitDiwan

Updated on 12-Aug-2022 12:07:03

643 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 ... Read More

Advertisements