Found 33676 Articles for Programming

Python Tools for Web scraping

Samual Sam
Updated on 26-Jun-2020 09:29:53

339 Views

In computer science Web scraping means extracting data from websites. Using this technique transform the unstructured data on the web into structured data.Most common web Scraping tools In Python3 are −Urllib2RequestsBeautifulSoupLxmlSeleniumMechanicalSoupUrllib2 − This tool is pre-installed with Python. This module is used for extracting the URL's. Using urlopen () function fetching the URL's using different protocols (FTP, HTTPetc.).Example codefrom urllib.request import urlopen my_html = urlopen("https://www.tutorialspoint.com/") print(my_html.read())Outputb'\r \r

Generating random strings until a given string is generated using Python

Samual Sam
Updated on 26-Jun-2020 09:33:53

600 Views

Given a string, our task is to generate some strings using the random combination of characters, special characters, numbers etc.ExampleInput PP Output AK AK . . . . .AlgorithmStep 1: Input a string. Step2: Here we store all possible combination of lowercase, uppercase and special characters in a variable. Step3: Use two loops and use random function. From this, we can get all the possible combinations of characters, symbols. Step4: At the end display same string which is same as an input string and it matches each random string with given input string. Step5: If both index values are same ... Read More

A single neuron neural network in Python

karthikeya Boyini
Updated on 26-Jun-2020 09:35:04

830 Views

Neural networks are very important core of deep learning; it has many practical applications in many different areas. Now a days these networks are used for image classification, speech recognition, object detection etc.Let’s do understand what is this and how does it work?This network has different components. They are as follows −An input layer, xAn arbitrary amount of hidden layersAn output layer, ŷA set of weights and biases between each layer which is defined by W and bNext is a choice of activation function for each hidden layer, σ.In this diagram 2-layer Neural Network is presented (the input layer is ... Read More

What is the size of an object of an empty class in C++?

Samual Sam
Updated on 11-Apr-2025 17:17:28

370 Views

The size of an object of an empty class in C++ is 1 byte as it allocates one unique address to the object in the memory. The size can not be 0, as the two objects can not have same memory allocation. In this article, we will see an example of checking the size of an object of an empty class in C++. Demonstrating Size of an Empty Class In this example, we have two C++ classes. One class is an empty class while other is not an empty class. We have printed the size of objects of both the ... Read More

How to call a parent class function from derived class function in C++?

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:31:11

11K+ Views

In the OOPs concept of C++, the parent class represents the root of the hierarchy while the derived class is inherited from the parent class. The derived class is presented using the scope resolution operator (::). The derived class is also known as the child class or subclass. What is Parent Class? The parent class is also called a base class used to design the structure of variable and function initialization based on access specifiers (private, public, and protected). Syntax Following is the syntax of parent class in C++: class ParentClass { // Access specifiers: ... Read More

What is a reference variable in C++?

Revathi Satya Kondra
Updated on 21-Apr-2025 19:22:04

23K+ Views

In C++, the reference variable is an alternate name of already existing variable. It cannot be changed to refer another variable and should be initialized at the time of declaration and cannot be NULL. The operator '&' is used to declare reference variable. Reference variables are commonly used for parameter passing in functions, returning values, and aliasing existing variables. Syntax Following is the syntax for the reference variable in c++: datatype &refer_var = variable_name; Here, datatype − The datatype of variable like int, char, float etc. variable_name − This is ... Read More

What is the difference between an int and a long in C++?

Samual Sam
Updated on 26-Jun-2020 09:20:19

2K+ Views

intThe datatype int is used to store the integer values. It could be signed or unsigned. The datatype int is of 32-bit or 4 bytes. It requires less memory area than long to store a value. The keyword “int” is used to declare an integer variable.The following is the syntax of int datatype.int variable_name;Here,variable_name − The name of variable given by user.The following is an example of int datatype.Example Live Demo#include using namespace std; int main() {    int a = 8;    int b = 10;    int c = a+b;    cout

How to convert a single char into an int in C++

Tapas Kumar Ghosh
Updated on 21-Apr-2025 18:07:05

782 Views

In C++, converting a single character into an integer is possible using various techniques like STL functions say atoi() and stoi(). Also, you can solve this with the help of ASCII value or stringstream function. Converting Single Char into Int Here, we have list down of four approaches that help to convert the single character into an integer form as follows: Using ASCII Subtraction Using stoi() Function Using atoi() Function Using stringstream Function Using ASCII Subtraction ASCII subtraction converts a digit character to an integer by subtracting '0' from it. This works because digit characters are stored sequentially ... Read More

Why does C++ require a cast for malloc() but C doesn't?

Samual Sam
Updated on 26-Jun-2020 09:11:25

908 Views

In C language, the void pointers are converted implicitly to the object pointer type. The function malloc() returns void * in C89 standard. In earlier versions of C, malloc() returns char *. In C++ language, by default malloc() returns int value. So, the pointers are converted to object pointers using explicit casting.The following is the syntax of allocating memory in C language.pointer_name = malloc(size);Here, pointer_name − Any name given to the pointer.size − Size of allocated memory in bytes.The following is an example of malloc() in C language.Example Live Demo#include #include int main() {    int n = 4, ... Read More

Variable initialization in C++

Tapas Kumar Ghosh
Updated on 22-Apr-2025 15:17:33

9K+ Views

In C++, variables are name given by the user to store data. While datatype is used to declare and initialize a variable that allocates memory to that variable. There are various ways to initialize the data types such as int, char, float, etc. to allocate the memory to that variable. Syntax Following is the syntax of variable initialization in C++: datatype variable_name = value; Here, datatype : The datatype of variables like int, char, float, etc. variable_name : This is the name of variable given by user. value : Any value to initialize the variable. By default, it ... Read More

Advertisements