AmitDiwan has Published 10744 Articles

Difference between Python iterable and iterator

AmitDiwan

AmitDiwan

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

1K+ Views

What is an iterable? An iterable can be loosely defined as an object which would generate an iterator when passed to inbuilt method iter(). There are a couple of conditions, for an object to be iterable, the object of the class needs to define two instance method: __len__ and __getitem__. ... Read More

How to input multiple values from user in one line in Python?

AmitDiwan

AmitDiwan

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

5K+ Views

In Python, to get values from users, use the input(). This works the same as scanf() in C language. Input multiple values from a user in a single line using input() To input multiple values in one line, use the input() method − x, y, z = input(), input(), input() ... Read More

Essential Python Tips And Tricks For Programmers?

AmitDiwan

AmitDiwan

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

254 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

555 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

Does Python support polymorphism?

AmitDiwan

AmitDiwan

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

1K+ 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

4K+ 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

What is the difference between Cython and CPython?

AmitDiwan

AmitDiwan

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

9K+ 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

330 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

806 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

How to write an empty function in Python?

AmitDiwan

AmitDiwan

Updated on 11-Aug-2022 12:05:44

2K+ Views

In this article, we will see how we can create an empty functions in Python. A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing. Function blocks begin ... Read More

Advertisements