Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Python Articles
Page 284 of 852
Difference between Yield and Return in Python?
In Python, the definition of generators is accomplished with the help of the yield statement. Therefore, before we dive into the specifics of what yield actually does, it's important that you get an overview of generators. If you have exposure to Python, then there is a good probability that you have previously worked with Python generators. Generators play an important function in Python. In Python, iterators can be generated using generators, however this process takes a somewhat different form. Python Generators are functions that may be dynamically paused and resumed and create a succession of outcomes. They can also be ...
Read MoreHow to convert pandas offset to Python date?
In this article, we convert the pandas offset to date in python. When you subtract the pandas from a date object, you get a pandas Timestamp object. You can convert this object to a String format date or Date object(Standard Python date). Or you can use the timedelta object from the datetime library. Example 1 In the following example code, we remove the offset of 10 days using to_offset(“10D”) from the pandas pd.to_datetime(‘2018-01-04’). from pandas.tseries.frequencies import to_offset import pandas as pd dt = pd.to_datetime('2018-01-04') - to_offset("10D") print(type(dt)) print(dt) Output The output of the above code is as follows. ...
Read MoreHow do we compare Python Dates?
In this article, we will understand how to compare python dates. They are different methods to identify which date is greater or lesser and these methods will be explored in detail. Using the timedelta() method and operator In this method, we use the datetime module and operator to compare two dates. To alter date and time, the datatime module provides timedelta() method. The timedelta() method takes the number of days as an input and returns the date. This method is used to perform arithmetic manipulations. Syntax The syntax of the timedelta() method from the datetime module in python ...
Read MoreDifference between Python and Ruby
Python is a high-level, general-purpose programming language. It is used in website development, machine learning, and creative software technology. Guido Van Rossam created Python in the Netherlands in 1989. Python became public in 1991. New programmers are typically advised to learn Python. Ruby is an interpreted, open-source, object-oriented language. It was developed by Yukihiro Matsumoto in the year 1995. Ruby is an object-oriented language, hence everything is an object. OOP gives developer projects a modular structure. Read through this article to find out more about Python and Ruby and how they are different from each other. What is ...
Read MoreFind sum of even factors of a number in Python Program
Let’s start our article with an explanation of how to find the sum of even factors of a number but what are factors? Factors are the numbers which completely divide the given number leaving zero as remainder or we can say factors are the multiples of the number. Example 1 − If we are given a number 60 Factors of 60 (6*10=2*3*2*5) are 2, 5 and 3 But according to the question, we must find out the sum of even factors so, in the above given example, the even factor will be only 2. Also, if the given number is an ...
Read MoreDifference between IPv4 and IPv6
IPv4 and IPv6 are internet protocol versions, with IPv6 being an upgraded version of IPv4. There are several differences between the IPv4 and IPv6 protocols, including their functionality, but the most important difference is the quantity of addresses (Address space) that they create.Read through this article to find out more about IPv4 and IPv6 and how they are different from each other.What is Internet Protocol (IP)?The Internet Protocol is a set of rules that allows our computers to communicate via the Internet. IP addresses are basically in charge of directing the data packets to their correct destinations. IP controls all ...
Read MoreHow to destroy an object in Python?
When an object is deleted or destroyed, a destructor is invoked. Before terminating an object, cleanup tasks like closing database connections or filehandles are completed using the destructor. The garbage collector in Python manages memory automatically. for instance, when an object is no longer relevant, it clears the memory. In Python, the destructor is entirely automatic and never called manually. In the following two scenarios, the destructor is called − When an object is no longer relevant or it goes out of scope The object's reference counter reaches zero. Using the __del__() method In Python, a destructor is ...
Read MoreData Hiding in Python
Data hiding is also known as data encapsulation and it is the process of hiding the implementation of specific parts of the application from the user. Data hiding combines members of class thereby restricting direct access to the members of the class. Data hiding plays a major role in making an application secure and more robust Data hiding in Python Data hiding in python is a technique of preventing methods and variables of a class from being accessed directly outside of the class in which the methods and variables are initialized. Data hiding of essential member function prevents the end ...
Read MorePython Program to Read First n Lines of a File
In this article, we will show you how to read and print the first N lines of a text file for the given N value using python. Assume we have taken a text file with the name ExampleTextFile.txt consisting of some random text. We will return the first N lines of a text file for the given N value. ExampleTextFile.txt Good Morning Tutorials Point This is Tutorials Point sample File Consisting of Specific abbreviated source codes in Python Seaborn Scala Imagination Summary and Explanation Welcome user Learn with a joy Algorithm (Steps) Following are the Algorithm/steps to be followed ...
Read MoreHow to Print Lines Containing Given String in File using Python?
In this article, we will show you how to print all the lines that contain a given specific string in a given text file using python. Assume we have taken a text file with the name ExampleTextFile.txt consisting of some random text. We will return the lines from a text file containing a given particular string from a text file. ExampleTextFile.txt Good morning to TutorialsPoint This is TutorialsPoint sample File Consisting of Specific source codes in Python, Seaborn, Scala Summary and Explanation Welcome to TutorialsPoint Learn with a joy Good morning to TutorialsPoint Algorithm (Steps) Following are the Algorithm/steps ...
Read More