We can use the Counter method from the collections module from collections import Counter dict1 = {'a': 5, 'b': 3, 'c': 2} dict2 = {'a': 2, 'b': 4, 'c': 3} new_dict = Counter(dict1) + Counter(dict2) …

Last updated 3 years, 8 months ago | 1679 views

Tags:- Python

Django | Request/Response Cycle Whenever a request is received by the Django server. The Request is processed by various middlewares and is passed to the URL Router. Then, the server looks for a matching URL in the urlpatterns …

Last updated 3 years, 10 months ago | 1677 views

Tags:- Django

Python | Monkey Patching In Python, the term monkey patch only refers to dynamic modifications of a class or module at run-time.   # m.py class A: def func(self): print("Hi") import m def monkey(self): print …

Last updated 3 years, 10 months ago | 1676 views

Tags:- Python

Python | Delete a file Using command  os.remove(file_name)   Use the os module to delete a file, we need to first import it, and then use the remove() function provided by the module to delete the file. It …

Last updated 3 years, 10 months ago | 1673 views

Tags:- Python

Python | Pickling, and Unpickling The pickle module accepts any Python object and converts it into a string representation and dumps it into a file by using the dump function, this process is called pickling. …

Last updated 3 years, 10 months ago | 1665 views

Tags:- Python

Python | enumerate() Function The enumerate() function is used to iterate through the sequence and retrieve the index position and its corresponding value at the same time.   lst = ["A","B","C"] print (list(enumerate(lst))) #[(0, 'A'), (1, 'B'), …

Last updated 3 years, 10 months ago | 1665 views

Tags:- Python

Python | lists, and tuples Lists and Tuples both are sequence data types that can store a collection of objects in Python. They are both heterogeneous data types means that you can store any kind of …

Last updated 3 years, 10 months ago | 1663 views

Tags:- Python

Some of the more well-known companies that make use of Django are:’ Instagram Mozilla Firefox Reddit YouTube Disqus Bitbucket Spotify NASA Pinterest Eventbrite, etc.

Last updated 3 years, 10 months ago | 1659 views

Tags:- Django

Python | accessors, mutators, and @property What we call getters and setters in languages like Java, we term accessors and mutators in Python. In Java, if we have a user-defined class with the property ‘x’, we …

Last updated 3 years, 10 months ago | 1650 views

Tags:- Python

Optimization is at the heart of many scientific and engineering problems—from minimizing cost functions to training machine learning models. Python’s SciPy library provides a robust module called scipy.optimize that offers a suite of optimization algorithms …

Last updated 11 months ago | 1649 views

Tags:- Python SciPy

Python | new_style and old_style Old-style: With old-style classes, class and type are not quite the same things.  If obj is an instance of an old-style class, obj __class__ designates the class, but the type(obj) is always …

Last updated 3 years, 10 months ago | 1648 views

Tags:- Python

Python | Generator Functions that return an iterable set of items are called generators. It is a normal function except that it yields expression in the function. It does not implements __itr__ and next() method and …

Last updated 3 years, 10 months ago | 1647 views

Tags:- Python

Python | split() and join() You can use split() method to split a string based on a delimiter to a list of strings. and join() method is used to join a list of strings based on …

Last updated 3 years, 10 months ago | 1638 views

Tags:- Python

Compared to other frameworks, Django offers more code reusability. As Django is a combination of apps, copying those apps from one directory to another with some tweaks to the settings.py file won't need much time …

Last updated 3 years, 8 months ago | 1633 views

Tags:- Django

Python |  issubclass() This is done by using a method called issubclass() provided by python. The method tells us if any class is a child of another class by returning true or false accordingly.     …

Last updated 3 years, 10 months ago | 1630 views

Tags:- Python