Found 34494 Articles for Programming

What is the proper declaration of main in C++?

Samual Sam
Updated on 26-Jun-2020 09:05:26

89 Views

The main() function is a global function. It is used to start the execution of program. Every program should have main(). The command line arguments argc and argv are optional.The standard prototype of main() function is as follows.int main() { body } OR int main(int argc, char *argv[]) { body }Here,argc − Number of arguments passed to the program from the environment where program runs.argv − pointer to the first element of an array.The following is an example of main()Example Live Demo#include using namespace std; int sum(int x, int y) {    int s = x + y;    cout

Decimal Functions in Python

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

12K+ Views

In Python, there is a module called Decimal, which is used to do some decimal floating point related tasks. This module provides correctly-rounded floating point arithmetic. To use it at first we need to import it the Decimal standard library module. import decimal In this section we will see some important functions of the Decimal module. The square root function sqrt() and Exponent function exp() The sqrt() method is used to calculate the square root of a given decimal type object. And the exp() method returns the e^x value for the given x as Decimal number. Example Code ... Read More

Create a Website Alarm Using Python

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

385 Views

In this section we will see how to create the website alarm system using Python. Problem Statement Open a website URL on the browser by taking a website URL and time. When the system time reaches the specified time, the webpage will be opened. We can store different web pages in our bookmark sections. Sometimes we need to open some web pages every day on a specific time to do some work. For that purpose, we can set this type of website alarm to do the work. In this case we are using some standard library modules like sys, web ... Read More

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

717 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

625 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

Advertisements