Pass an Array to a Function in Golang

Aman Sharma
Updated on 10-Jul-2023 17:04:40

1K+ Views

In programming, to make the code more modular, usable, and readable we break the code into different functions. For example, we have to sort some set of numbers for which we will create a separate function. For this, we have a data structure called arrays in programming that is nothing but a collection of multiple values of the same type. Once the array of numbers is sorted then at the end of that function we have to return the sorted elements so in this article we will see how to return the array. Syntax The syntax to declare a function ... Read More

Find Frequency of Common Elements in a List of Strings

Saba Hilal
Updated on 10-Jul-2023 17:03:58

198 Views

In this Python article, the given task is to get the frequency of the elements which are common in a list of strings. Sometimes the list to be analyzed using Python is available in an Excel file. To get this list from Excel, a module called openpyxl is used. In this Python article, using three different examples, the ways of getting the frequency of the items which are repeated in a list of strings are given. In example 1, the frequency of the characters which are common in a list of strings is found. In the next two examples, ... Read More

Pass a String to a Function in Golang

Aman Sharma
Updated on 10-Jul-2023 16:59:44

2K+ Views

In this tutorial, we are going to learn about how to pass a string in function as an argument in Golang. In programming, to make the code more modular, usable, and readable we break the code into different small blocks and these blocks are known as functions. If you have created a string of alphabets and you want to perform some operations on the string then you need to pass that string to the function by passing it as an argument. This tutorial will explain this concept with the help of two examples. In the first example, we will ... Read More

Find Sum of First and Last Digit in Python

Saba Hilal
Updated on 10-Jul-2023 16:51:14

1K+ Views

In this article, the given task is to add the first and the last digit of an integer. Now the integer can be very small or it can be a big number. So, these programs will have two parts. First, we need to find how big the integer is and then get the first digit from it. The second part will be to get the last number from the given integer which can be done easily by dividing the number by ten and finding the remainder. In this Python article, using four different examples, the approaches to adding the first ... Read More

Find Whether a Number is Prime Using Recursion in Golang

Aman Sharma
Updated on 10-Jul-2023 16:48:16

287 Views

In mathematics, there are numbers that can be divisible by 1 or by itself, and such numbers are called Prime numbers. For example, 2, 3, 5, 7 … etc. In programming, we can create a program to check number is prime or not. In this article, we will use the concept of recursion which we call the function within the function to create a program to check number is prime or not. Example 1 In this example, we are going to create a recursive function with two parameters one is the number and another one is the divisor. The ... Read More

Find Tangent of a Given Radian Value in Golang

Aman Sharma
Updated on 10-Jul-2023 16:40:12

112 Views

The ratio of the radian’s adjacent side and the opposite side is known as the tangent of the given radian. Golang language has many packages with predefined functions that the developer can use without writing the complete logic. To perform the mathematical operations and logic we have a math package in Golang. We will use this package only to find the Tangent of a given radian value. We will also see how to import the package and also how to call a function this package consists of by writing a Golang code. Tangent Definition Tangent is a function that ... Read More

Print Positive Numbers in a List using Python

Saba Hilal
Updated on 10-Jul-2023 16:23:30

586 Views

In this article, the task is to print the positive numbers from a list of integers. Here, in this Python article, this task is done using the different methods in 4 different examples. Then these positive numbers are printed. In example 1, the positive numbers are picked and separated into another list. In the example 2, all the elements that are not positive are removed. In example 3, the sorted list is split up to zero and only positives are retained. In example 4, filter is used to select the positive numbers. Example 1 - Select only the positive numbers ... Read More

Check Whether a Number is Even or Odd in Golang

Aman Sharma
Updated on 10-Jul-2023 16:08:51

5K+ Views

In this tutorial, we are going to learn how we can check whether the number is even or odd. The number that can be divisible by 2 is an even number and the number that is not divisible by two is an odd number. This tutorial includes three different ways to achieve this Moulous Operator − In the first method, we are using the modulus (%) operator. This operator is used to find the remainder of two numbers. In our case, we will do the modulus of the number with 2 and if it returns 0 then ... Read More

Install pip in a Docker Container Using a Dockerfile

Aman Sharma
Updated on 10-Jul-2023 15:59:34

9K+ Views

In this tutorial, we are going to learn how we can install pip in a Docker container using a Dockerfile. This tutorial will cover the creation of the Dockerfile and then we will see the docker command to build a docker image from the Dockerfile, and in last we will see the docker command to run a container based on that image and see whether PIP is installed properly or not. Prerequisites There are some prerequisites to creating and building the Dockerfile as mentioned below. The stable version of Docker should be installed. Create a file in any folder ... Read More

Find Unique Lines from Two Text Files in Python

Saba Hilal
Updated on 10-Jul-2023 15:52:36

486 Views

Many times we see two files that look similar but had certain differences. If the files are big or have lots of content, searching for that difference or finding the uniqueness in that file manually is not easy. However, this problem of finding the unique lines in two text files can be done easily using Python programs. In this article, using three different examples, three different ways of finding the unique lines in two text files are given. The text files used are a.txt and b.txt while in the end the result is stored in another txt file. For these ... Read More

Advertisements