Found 10784 Articles for Python

OrderedDict in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

3K+ Views

The OrderedDict is a subclass of dict object in Python. The only difference between OrderedDict and dict is that, in OrderedDict, it maintains the orders of keys as inserted. In the dict, the ordering may or may not be happen. The OrderedDict is a standard library class, which is located in the collections module. To use it at first we need to import it the collections standard library module. import collections In this section we will see some operations on OrderedDictand difference between OrderedDict and Dict. We can put some keys and values in the Dict and OrderedDict. ... Read More

Deque in Python

Samual Sam
Updated on 26-Jun-2020 09:08:39

6K+ Views

The Deque is basically a generalization of stack and queue structure, where it is initialized from left to right. It uses the list object to create a deque.It provides O(1) time complexity for popping and appending.The Dequeis a standard library class, which is located in the collections module.To use it at first we need to import it the collections standard library module.import collectionsIn this section we will see some functions of the Deque classThe Appending functions on DequeThere are two different types of append. The append() method is used to add elements at the right end of the queue, and ... Read More

Namedtuple in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

3K+ Views

The NamedTuple is another class, under the collections module. Like the dictionary type objects, it contains keys and that are mapped to some values. In this case we can access the elements using keys and indexes. To use it at first we need to import it the collections standard library module. import collections In this section we will see some functions of the NamedTuple class. The accessing methods of NamedTuple From NamedTuple, we can access the values using indexes, keys and the getattr() method. The attribute values of NamedTuple are ordered. So we can access them using the ... Read More

ChainMap in Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

718 Views

The ChainMap is used to encapsulates the dictionaries into single unit. The ChainMapis a standard library class, which is located in the collections module. To use it at first we need to import it the collections standard library module. import collections In this section we will see some functions of the ChainMap class The maps and keys() values() functions The maps is used to display all key value pairs of all the dictionaries from the ChainMap. The keys() method will return the keys from the ChainMap, and values() method returns all the values() of different keys from the ... Read More

Erosion and Dilation of images using OpenCV in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

627 Views

In this problem, we will see how Python can do some Morphological Operations like Erosion and Dilation using the OpenCV module. The OpenCV library is mainly designed for computer vision. It is open source. Originally it was designed by Intel. This is free to use under open-source BSD license. To use the OpenCV functionality, we need to download them using pip. sudo pip3 install opencv-python What is Erosion Image and how it works? In the Erosion, it erodes away the boundaries of foreground objects. It is used to remove small white noises from the images. Erosion can also ... Read More

Python Program to calculate the Round Trip Time (RTT)

karthikeya Boyini
Updated on 26-Jun-2020 08:56:00

2K+ Views

Here we will see how Python can be used to get the Round Trip Time (RTT). The RTT is the time which is taken by the entire trip of a signal. It means the time between the starting time when a signal is sent and the receiving time of the acknowledge signal.The RTT results varies on different parameters like.The data transfer rate of the sender’s side.The nature of the transmission media.The actual distance between the sender and receiver.The number of nodes between sender and receiver.The amount of traffic on LAN.Number of requests handled by intermediate points.Example Codeimport time import requests ... Read More

Speech Recognition in Python using Google Speech API

Samual Sam
Updated on 30-Jul-2019 22:30:23

1K+ Views

The speech recognition is one of the most useful features in several applications like home automation, AI etc. In this section we will see how the speech recognition can be done using Python and Google’s Speech API. In this case we will give an audio using microphone for speech recognizing. To configure the microphones, there are some parameters. To use this module, we have to install the SpeechRecognition module. There is another module called pyaudio, which is optional. Using this we can set different modes of audio. sudo pip3 install SpeechRecognition sudo apt-get install python3-pyaudio For External Microphones ... Read More

Birthday Reminder Application in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

638 Views

In this section we will see how to create a birthday reminder application using Python. Problem Statement Create an application using Python, which can check whether there is any birthday on the current day or not. If it is the birthday of some listed person, send a notification to the System with the name of that person. We need a file, where we can store the date and month and the name of the person as a lookup file for this application. The file will look like this − Here we will convert this application to a start-up application ... Read More

Unix filename pattern matching in Python

Samual Sam
Updated on 26-Jun-2020 08:57:31

1K+ Views

Here we will see how we can get the UNIX shell style pattern matching techniques using Python. There is a module called fnmatch, which is used to do the work. This module is used to compare file name against a pattern, then returns True or False according to the matches.To use it at first we need to import it the fnmatch standard library module.import fnmatchIn the Unix terminal, there are some wildcards to match the patterns. These are like below −‘*’ The asterisk is used to match everything.‘?’ Question Mark is for matching a single character.[seq] Sequences are used to ... Read More

Python Interface to UNIX syslog library routines

George John
Updated on 30-Jul-2019 22:30:23

221 Views

To get the UNIX syslog library information, we need to use the syslog module into our programs. This module has syslog has different modules for the syslog library. To use this module, we should import it using − import syslog The methods are like below − Method syslog.syslog(message) or syslog.syslog(priority, message) This method is used to send a string type message to the system logger. Each message has a priority. The priority argument can be used to set the priority of the given message. Method syslog.openlog([ident[, logoption[, facility]]]) This method is used to logging options of subsequent syslog ... Read More

Advertisements