Found 34472 Articles for Programming

Docopt module in Python

Rohan Singh
Updated on 10-Jul-2023 11:50:46

620 Views

Docopt module in Python is used to create command-line interfaces. Similar to other command line arguments and options docopt allows us to define command line arguments and options and also generate help messages and usage strings for the Program. In this article, we will understand how the Docopt module is defined and how it is used to create a command line interface. Installation You can install the Docopt module before using it with the help of the pip command in Python. To install the Docopt module type the following command on your terminal or command prompt. pip install docopt ... Read More

dllist class of llist module in Python

Rohan Singh
Updated on 10-Jul-2023 11:42:47

67 Views

The dllist is a class of the llist module in Python that is used to implement a doubly linked list that has the functionality for insertion, deletion, and traversal of elements. The dllist class provides methods for adding, removing, and iterating over the list in both directions. In this article, we will understand the dllist class in detail and its methods. Creating dllist object To create a dllist object, we need to first import the llist module from the pyllist package. We can then use the dllist class constructor to create a new instance of a doubly-linked list. The ... Read More

Adam Optimizer in Tensorflow

Rohan Singh
Updated on 06-Jul-2023 17:24:01

904 Views

Adam optimizer in Tensorflow is an algorithm used in deep learning models. Optimization algorithms are used in deep learning models to minimize the loss function and improve performance. Adam stands for Adaptive Moment Estimation, which is a stochastic gradient descent algorithm. It combines the advantages of both RMSprop and AdaGrad algorithms to achieve a better optimization result. In this article, we will understand the Adam Optimizer in Tensorflow and how it works. Working principle of Adam Optimizer Adam optimizer is an iterative optimization algorithm. It uses first and second-order moments of the gradient to adaptively adjust the learning rate ... Read More

Accessing Web Resources using Factory Method Design Pattern in Python

Rohan Singh
Updated on 06-Jul-2023 17:07:07

103 Views

The Factory Method Design Pattern of Python is a creational pattern that provides an interface for creating objects in a superclass but allows subclasses to alter the type of objects that will be created. It is used to define a generic interface for creating objects while allowing subclasses to decide which class to instantiate. In this article, we will explore how to use the Factory Method Design Pattern to access web resources in Python. Accessing Web Resources Python provides several libraries for accessing web resources such as HTTP requests, urllib, and Requests. These libraries allow us to send HTTP requests ... Read More

Golang program of two struct types with identical fields, with having one "JSON" tag on each field

Akhil Sharma
Updated on 06-Jul-2023 12:48:47

896 Views

Struct types are used to construct custom data structures consist of fields. These fields reflect the structure's characteristics or attributes. The ability to add tags to fields, such as "JSON" tags, which offer additional metadata about the field when serializing or deserializing the struct to/from JSON format, is a valuable feature of struct types. In this article, we will write Go language programs to represent structs with one JSON tag in each field. type StructName struct { Field1 DataType1 `Tag1:"Value1" Tag2:"Value2"` Field2 DataType2 `Tag3:"Value3" Tag4:"Value4"` // ... ... Read More

How do you compare two struct instances that have pointers as fields in Golang

Akhil Sharma
Updated on 06-Jul-2023 12:40:48

696 Views

In golang, Pointers are the variables which store the address of other variables. A struct is a counterpart to class in object-oriented programming where different fields can be placed in the struct, where these fields can be implemented later on and they have a type like int, float, string etc. In this article, we will write a Go language program to compare two struct instances that have pointers as fields. Mathematical representation for assigning the address of variable “b” to variable “a” − a = &b & denotes the address of operator, and receives the memory address of ... Read More

Golang program to compare two instances of this struct for equality, taking into account the values in the slice

Akhil Sharma
Updated on 06-Jul-2023 12:35:58

164 Views

A struct is a counterpart to class in object-oriented programming where different fields can be placed in the struct, where these fields can be implemented later on and they have a type like int, float, string etc.In this article, we will write a Go language program to compare the equality of two structs. Syntax func len(v Type) int The len() method returns the length of any parameter. It accepts one input, the data type variable whose length we want to know. func range(variable) The range function iterates through any data type. To utilize this, we must first put ... Read More

How to find the capacity of the pointers pointing at a map in Golang?

Akhil Sharma
Updated on 06-Jul-2023 12:32:23

68 Views

A pointer is a variable which holds the address of another variable and can be used to point to the content of another variable. A pointer does not have its capacity just like slices, it can be used to point to the map whose length of elements can be calculated.In this article, we will write a Go language program to find the capacity of a pointer pointing to a map. Syntax func make ([] type, size, capacity) The make function in go language is used to create an array/map it accepts the type of variable to be created, its ... Read More

Golang program to find the longest path in a weighted directed acyclic graph using Bellman-Ford algorithm

Akhil Sharma
Updated on 06-Jul-2023 12:30:54

334 Views

In this article, we will write a Go language program to find the longest path in a weighted directed acyclic graph using Bellman-ford-algorithm. Bellman-Ford-Algorithm is a popular algorithm used to find the longest path from source vertex to other vertices in a weighted directed graph. Syntax func range(variable) Any data type may be iterated over using the range function. This may be used by first writing the range keyword, then the data type to which we wish to iterate. func make ([] type, size, capacity) When creating an array or map in the Go programming language, the ... Read More

Golang program to find the minimum number of edges in a weighted directed graph that connects all nodes

Akhil Sharma
Updated on 06-Jul-2023 12:24:12

103 Views

In this article, we will write Go language programs to find the minimum no. of edges in a weighted directed graph that connects all nodes. We will use Prim’s algorithm to perform this operation. It is a greedy algorithm which is used to find the minimum spanning tree for a graph. Syntax func range(variable) Any data type may be iterated over using the range function. This may be used by first writing the range keyword, then the data type to which we wish to iterate func make ([] type, size, capacity) The go language's make function is used ... Read More

Advertisements