In this article , we will learn some useful basic Python examples for beginners in this article.This article also includes some basic questions that are asked in the python interview. Lets get started!!! How can I Make a Tuple out of a List? Using the Python tuple() method, we may convert a list to a tuple. We can't update the list after it's been converted to a tuple since tuples are immutable. Example The following program returns the converts the list into a tuple using tuple() function − # input list inputList = ['hello', 'tutorialspoint', 'python', 'codes'] # ... Read More
When a method is overridden in Go, a new method with the same name and receiver type as an existing method is created and used in place of the existing one. As a result, Golang may provide polymorphism, allowing different implementations of a same method to be used depending on the type of receiver. Let’ see the execution in examples. Method 1: Using shape struct Here, this shape struct will contain an area field and an area method which will return the value of area field. Rectangle and square both inherit the area () method. The output will be their ... Read More
In this article, we will learn how to overload the method in class using different example. Go programming language does not have concept of a class so function overloading will be used to execute the program. As a result, code can be more flexible and readable. As an illustration, you could create a function that accepts an interface as a parameter and then call it with several types that implement the interface. Let’s see it execution. Method 1: using custom type MyInt Here, it contains two methods Print() and PrintWithNumber() where values can be sent in these functions of MyInt ... Read More
String in Golang is a collection of characters. Since strings in Go are immutable, they cannot be modified after they have been produced. Concatenating or adding to an existing string, however, enables the creation of new strings. A built-in type in Go, the string type can be used in a variety of ways much like any other data type. Syntax strings.TrimSpace() To eliminate leading and trailing white space from a string, use the strings.TrimSpace() function. Algorithm Step 1 − Create a package main and declare fmt(format package) package. Step 2 − Create a main function. Step 3 − Using internal ... Read More
String in Golang is a collection of characters. Since strings in Go are immutable, they cannot be modified after they have been produced. Concatenating or adding to an existing string, however, enables the creation of new strings. The frequency of a character means the number of times a character is appearing. Syntax map() To keep track of how frequently each character appears in the input string, the built-in map data structure in Go is used in example below. The map is an unsorted collection of key-value pairs with unique keys and variable types of values for the values. func ... Read More
A string in Golang is a collection of characters. Since strings in Go are immutable, they cannot be modified after they have been produced. Concatenating or adding to an existing string, however, enables the creation of new strings. A built-in type in Go, the string type can be used in a variety of ways much like any other data type. Syntax func len(v Type) int The len() function is used to get the length of any parameter. It takes one parameter as the data type variable whose length we wish to find and returns the integer value which is ... Read More
A string in Golang is a collection of characters. Since strings in Go are immutable, they cannot be modified after they have been produced. Concatenating or adding to an existing string, however, enables the creation of new strings. A built-in type in Go, the string type can be used in a variety of ways much like any other data type. Syntax strings.Join(words, ” ”) A slice of strings can be joined together with a separator using the join method. Two arguments are required by the function: a slice of strings, and a separator string. It gives back a single ... Read More
When a string buffer is cleared, all of the data that was previously stored inside the buffer is deleted. This can be done for a variety of reasons, including when you want to reuse the buffer for fresh data or when the data that is currently in the buffer is no longer required. Here we will understand different techniques of clear a string buffer using go programming language Syntax Reset() Any accumulated data is discarded and the buffer is reset to zero using the Reset() method. The old buffer is essentially replaced with a new one and the old ... Read More
A substring is a small string in a string and string in Golang is a collection of characters. Since strings in Go are immutable, they cannot be modified after they have been produced. Concatenating or adding to an existing string, however, enables the creation of new strings. A built-in type in Go, the string type can be used in a variety of ways much like any other data type. Syntax strings.Contains(str, substring string) To determine whether a string contains a particular substring, use the Contains(s, substr string) bool function. If the substring is found in the supplied string, a ... Read More
In Golang, data hiding is a practice of preventing external code from accessing or changing a class’s members. This is accomplished by designating the class's members as private, which restricts access to or modification of them to the class's methods only. This is a crucial idea in object-oriented programming since it ensures the data's integrity and the class's proper operation. Syntax struct A struct is a composite data type used in the Go programming language that enables you to bring together related values of various types, such as a collection of fields or a collection of methods. Similar to ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP