code-rag-bench/online-tutorials huggingface dataset:
C# program to multiply two matrices

The program for matrix multiplication is used to multiply two matrices. This procedure is only possible if the number of columns in the first matrix are equal to the number of rows in the second matrix.
A program that demonstrates matrix multiplication in C# is given as follows −
 Live Demo
using System;
namespace MatrixMultiplicationDemo {
   class Example {
      static void Main(string[] args) {
         int m = 2, n = 3, p = 3, q = 3, i, j;
         int[,] a = {{1, 4, 2}, {2, 5, 1}};
         int[,] b = {{3, 4, 2}, {3, 5, 7}, {1, 2, 1}};
         Console.WriteLine("Matrix a:");
         for (i = 0; i < m; i++) {
            for (j = 0; j < n; j++) {
               Console.Write(a[i, j] + " ");
            }
            Console.WriteLine();
         }
         Console.WriteLine("Matrix b:");
         for (i = 0; i < p; i++) {
            for (j = 0; j < q; j++) {
               Console.Write(b[i, j] + " ");
            }
            Console.WriteLine();
         }
         if(n! = p) {
            Console.WriteLine("Matrix multiplication not possible");
         } else {
            int[,] c = new int[m, q];
            for (i = 0; i < m; i++) {
               for (j = 0; j < q; j++) {
                  c[i, j] = 0;
                  for (int k = 0; k < n; k++) {
                     c[i, j] += a[i, k] * b[k, j];
                  }
               }
            }
            Console.WriteLine("The product of the two matrices is :");
            for (i = 0; i < m; i++) {
               for (j = 0; j < n; j++) {
                  Console.Write(c[i, j] + "\t");
               }
               Console.WriteLine();
            }
         }
      }
   }
}
The output of the above program is given as follows.
Matrix a:
1 4 2
2 5 1
Matrix b:
3 4 2
3 5 7
1 2 1
The product of the two matrices is :
172832
223540
Now let us understand the above program.
First, the two matrices a and b are displayed. The code snippet for this is given as follows.
for (i = 0; i < m; i++) {
   for (j = 0; j < n; j++) {
      Console.Write(a[i, j] + " ");
   }
   Console.WriteLine();
}
Console.WriteLine("Matrix b:");
for (i = 0; i < p; i++) {
   for (j = 0; j < q; j++) {
      Console.Write(b[i, j] + " ");
   }
   Console.WriteLine();
}
If the number of columns in the first matrix are not equal to the number of rows in the second matrix then the matrices cannot be multiplied and this is displayed. The code snippet for this is given as follows .
if(n! = p) {
   Console.WriteLine("Matrix multiplication not possible");
}
Otherwise, a nested for loop is used to obtain the product of matrices a and b i.e. matrix c. Then the matrix c is displayed. The code snippet for this is given as follows −
for (i = 0; i < m; i++) {
   for (j = 0; j < q; j++) {
      c[i, j] = 0;
      for (int k = 0; k < n; k++) {
         c[i, j] += a[i, k] * b[k, j];
      }
   }
}
Console.WriteLine("The product of the two matrices is :");
for (i = 0; i < m; i++) {
   for (j = 0; j < n; j++) {
      Console.Write(c[i, j] + "\t");
   }
   Console.WriteLine();
}
Read an image with OpenCV and display it with Tkinter

OpenCV is an Open Source Computer Vision library in Python which is widely used for Research purposes in Artificial Intelligence and Machine Learning. Computer Vision Library such as OpenCV deals with image processing. We can use OpenCV to read an image and further use it for development.
Let us suppose that we want to create an application that reads an image and displays it in the window using OpenCV.
Install OpenCV by using the following command −
pip install opencv-python
Next, follow the steps given below −
Install OpenCV in the environment and import the library using import cv2.
Install OpenCV in the environment and import the library using import cv2.
Import NumPy and PIL (Pillow Package) for image calculation.
Import NumPy and PIL (Pillow Package) for image calculation.
Load the Image using imread(image_location) function.
Load the Image using imread(image_location) function.
Split the RGB Color of the image using the split(image) function.
Split the RGB Color of the image using the split(image) function.
Merge the Image colors using merge(rgb) function.
Merge the Image colors using merge(rgb) function.
Convert the multidimensional matrix into an image.
Convert the multidimensional matrix into an image.
Convert the given image using PhotoImage(image= file) function.
Convert the given image using PhotoImage(image= file) function.
Initialize a label and display the Image.
Initialize a label and display the Image.
#Import the tkinter library
from tkinter import *
import numpy as np
import cv2
from PIL import Image, ImageTk

#Create an instance of tkinter frame
win = Tk()
win.geometry("700x550")
#Load the image
img = cv2.imread('tutorialspoint.png')

#Rearrange colors
blue,green,red = cv2.split(img)
img = cv2.merge((red,green,blue))
im = Image.fromarray(img)
imgtk = ImageTk.PhotoImage(image=im)

#Create a Label to display the image
Label(win, image= imgtk).pack()
win.mainloop()
Running the above code will load and display an image in the window.
Make sure the image 'tutorialspoint.png' is located in the same folder as the program.
ChronoUnit values() method in Java with Examples - GeeksforGeeks

29 Jan, 2020
The values() method of ChronoUnit enum is used to an array containing the units of this ChronoUnit, in the order, they are declared.
Syntax:
public static ChronoUnit[] values()

Parameters: This method accepts nothing.
Return value: This method returns an array containing the constants of this enum type, in the order, they are declared.
Below programs illustrate the ChronoUnit.values() method:Program 1:
// Java program to demonstrate// ChronoUnit.values() method  import java.time.temporal.ChronoUnit;  public class GFG {    public static void main(String[] args)    {          // get ChronoUnit        ChronoUnit chronounit            = ChronoUnit.valueOf("FOREVER");          // apply values()        ChronoUnit[] array            = chronounit.values();          // print        for (int i = 0; i < array.length; i++)            System.out.println(array[i]);    }}
Nanos
Micros
Millis
Seconds
Minutes
Hours
HalfDays
Days
Weeks
Months
Years
Decades
Centuries
Millennia
Eras
Forever

Program 2:
// Java program to demonstrate// ChronoUnit.values() method  import java.time.temporal.ChronoUnit;  public class GFG {    public static void main(String[] args)    {          // get ChronoUnit        ChronoUnit chronounit            = ChronoUnit.valueOf("CENTURIES");          // apply values()        ChronoUnit[] array            = chronounit.values();          // print        System.out.println("ChronoUnit length:"                           + array.length);    }}
ChronoUnit length:16

References: https://docs.oracle.com/javase/10/docs/api/java/time/temporal/ChronoUnit.html#values()
Java-ChronoUnit
Java-Functions
java.time.temporal package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
HashMap in Java with Examples
Interfaces in Java
Object Oriented Programming (OOPs) Concept in Java
ArrayList in Java
How to iterate any Map in Java
Initialize an ArrayList in Java
Overriding in Java
Singleton Class in Java
Collections in Java
Multithreading in Java
Assigning values to variables in R programming - assign() Function - GeeksforGeeks

10 May, 2020
In R programming, assign() method is used to assign the value to a variable in an environment.
Syntax : assign(variable, value)Return : Return the variable having value assigned.
Example 1:
# Using assign() methodassign("gfg", 10)  print(gfg)
Output:
[1] 10
Example 2:
# Using assign() methodassign("gfg", 20.12345)  print(gfg)
Output:
[1] 20.12345

R-Variables
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Control Statements in R Programming
How to Replace specific values in column in R DataFrame ?
Loops in R (for, while, repeat)
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
Data Visualization in R
How to change Row Names of DataFrame in R ?
How to Change Axis Scales in R Plots?
Logistic Regression in R Programming
Remove rows with NA in one column of R DataFrame
Count of pairs in an array whose sum is a perfect square in C++

We are given with an array of N elements. The goal is to find the count of all pairs (Arr[i],Arr[j]) which have a sum which is a perfect square such that i!=j. That is Arr[i]+Arr[j] is a perfect square.
We will do this by calculating the sum of pairs and check if the square root of that sum is equal to the floor value of the square root. sqrt(Arr[i]+Arr[j])-floor( sqrt(Arr[i]+Arr[j] )==0.
Let’s understand with examples.
Input − Arr[]= { 4,3,2,1,2,4 } N=6
Output − Count of pairs with sum as perfect square − 2
Explanation −
Arr[1]+Arr[3]=4, sqrt(4)-floor(4)=0 4 is a perfect square.
Arr[2]+Arr[4]=4, sqrt(4)-floor(4)=0 4 is a perfect square.
Rest all pairs have sum 7,6,5,8 which are not perfect squares.
Input − Arr[]= { 3,3,3,3,3} N=5
Output − Count of pairs with sum as perfect square − 0
Explanation − All pairs have sum=6, which is not a perfect square.
We take an integer array Arr[] initialized with random numbers for size of gloves > 0.
We take an integer array Arr[] initialized with random numbers for size of gloves > 0.
Take a variable n which stores the length of Arr[].
Take a variable n which stores the length of Arr[].
Function countPairs(int arr[], int n) takes an array, its length as input and returns the pairs which have sum which is a perfect square.
Function countPairs(int arr[], int n) takes an array, its length as input and returns the pairs which have sum which is a perfect square.
Traverse array using two for loops for each element of the pair.
Traverse array using two for loops for each element of the pair.
Outer Loop from 0<=i<n-1, inner loop i<j<n
Outer Loop from 0<=i<n-1, inner loop i<j<n
Calculate sum of arr[i], arr[j] are positive.
Calculate sum of arr[i], arr[j] are positive.
Calculate square root of sum as sqrt(sum).
Calculate square root of sum as sqrt(sum).
Now check if sqr-floor(sqr)==0. Which means sum is a perfect square. If true increment count.
Now check if sqr-floor(sqr)==0. Which means sum is a perfect square. If true increment count.
At the end of all loops count will have a total number of pairs that have sum which is perfect square.
At the end of all loops count will have a total number of pairs that have sum which is perfect square.
Return the count as result.
Return the count as result.
 Live Demo
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int countPairs(int arr[], int n){
   int count=0;
   int sum=0;
   double sqr=0;
   for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
         sum=arr[i]+arr[j];
         sqr=sqrt(sum);
         if( sqr-floor(sqr)==0 ){
            count++;
            //cout<<endl<<"a :"<<arr[i]<<" b :"<<arr[j]; //to print
         }
      }
   }
   return count;
}
int main(){
   int arr[] = { 1, 2, 4, 8, 5, 6 };
   // Size of arr[]
   int n = sizeof(arr) / sizeof(int);
   cout <<endl<<"Pairs whose sum is perfect square :"<<countPairs(arr, n);
   return 0;
}
If we run the above code it will generate the following output −
Pairs whose sum is perfect square :2
Design and Analysis Strassenâs Matrix Multiplication

In this chapter, first we will discuss the general method of matrix multiplication and later we will discuss Strassen’s matrix multiplication algorithm.
Let us consider two matrices X and Y. We want to calculate the resultant matrix Z by multiplying X and Y.
First, we will discuss naïve method and its complexity. Here, we are calculating Z = X × Y. Using Naïve method, two matrices (X and Y) can be multiplied if the order of these matrices are p × q and q × r. Following is the algorithm.
Algorithm: Matrix-Multiplication (X, Y, Z) 
for i = 1 to p do 
   for j = 1 to r do 
      Z[i,j] := 0 
      for k = 1 to q do 
         Z[i,j] := Z[i,j] + X[i,k] × Y[k,j] 

Here, we assume that integer operations take O(1) time. There are three for loops in this algorithm and one is nested in other. Hence, the algorithm takes O(n3) time to execute.
In this context, using Strassen’s Matrix multiplication algorithm, the time consumption can be improved a little bit.
Strassen’s Matrix multiplication can be performed only on square matrices where n is a power of 2. Order of both of the matrices are n × n.
Divide X, Y and Z into four (n/2)×(n/2) matrices as represented below −
Z=[IJKL] X=[ABCD] and Y=[EFGH]
Using Strassen’s Algorithm compute the following −
M1:=(A+C)×(E+F)
M2:=(B+D)×(G+H)
M3:=(A−D)×(E+H)
M4:=A×(F−H)
M5:=(C+D)×(E)
M6:=(A+B)×(H)
M7:=D×(G−E)
Then,
I:=M2+M3−M6−M7
J:=M4+M6
K:=M5+M7
L:=M1−M3−M4−M5
T(n)={cifn=17xT(n2)+dxn2otherwise where c and d are constants
Using this recurrence relation, we get T(n)=O(nlog7)
Hence, the complexity of Strassen’s matrix multiplication algorithm is O(nlog7).

    102 Lectures 
     10 hours 

 Arnab Chakraborty

    30 Lectures 
     3 hours 

 Arnab Chakraborty

    31 Lectures 
     4 hours 

 Arnab Chakraborty

    43 Lectures 
     1.5 hours 

 Manoj Kumar

    7 Lectures 
     1 hours 

 Zach Miller

    54 Lectures 
     4 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
Explain the evaluation of expressions of stacks in C language

Stack is a linear data structure, where data is inserted and removed only at one end.
Given below is an algorithm for Push ( ) −
Check for stack overflow.
if (top = = n-1)
printf("stack over flow");
Otherwise, insert an element into the stack.
top ++
a[top] = item
Given below is an algorithm for Pop ( ) −
Check for stack underflow.
if ( top = = -1)
printf( "stack under flow");
Otherwise, delete an element from the stack.
item = a[top]
top --
Given below is an algorithm for Display ( ) −
if (top == -1)
printf ("stack is empty");
Otherwise, follow the below mentioned algorithm.
for (i=0; i<top; i++)
printf ("%d", a[i]);
Let us understand the conversions of expressions of stacks in C language.
Expression − It is a legal combination of operands and operations.
There are three types of expressions in C language on which the conversions and valuation can be carried out. They are explained below −
Infix expression − Operator is in between the operands. For example, A+B
Infix expression − Operator is in between the operands. For example, A+B
Prefix expression − Operator is before the operands. For example, +AB
Prefix expression − Operator is before the operands. For example, +AB
Postfix expression − Operator is after the operands. For example, AB+
Postfix expression − Operator is after the operands. For example, AB+
Scan the input string from left to right.
For each input symbol,
If it is a digit then, push it on to the stack.
If it is a digit then, push it on to the stack.
If it is an operator then, pop out the top most two contents from the stack and apply the operator on them. Later on, push the result on to stack.
If it is an operator then, pop out the top most two contents from the stack and apply the operator on them. Later on, push the result on to stack.
If the input symbol is ‘\0’, empty the stack.
If the input symbol is ‘\0’, empty the stack.
Following is the C program for an evaluation of postfix expression −
 Live Demo
#include<stdio.h>
int top = -1, stack [100];
main ( ){
   char a[50], ch;
   int i,op1,op2,res,x;
   void push (int);
   int pop( );
   int eval (char, int, int);
   printf("enter a postfix expression:");
   gets (a);
   for(i=0; a[i]!='\0'; i++){
      ch = a[i];
      if (ch>='0' && ch<='9')
         push('0');
      else{
         op2 = pop ( );
         op1 = pop ( );
         res = eval (ch, op1, op2);
         push (res);
      }
   }
   x = pop ( );
   printf("evaluated value = %d", x);
   getch ( );
}
void push (int n){
   top++;
   stack [top] = n;
}
int pop ( ){
   int res ;
   res = stack [top];
   top--;
   return res;
}
int eval (char ch, int op1, int op2){
   switch (ch){
      case '+' : return (op1+op2);
      case '-' : return (op1-op2);
      case '*' : return (op1*op2);
      case '/' : return (op1/op2);
   }
}
When the above program is executed, it produces the following result −
Run 1:
enter a postfix expression:45+
evaluated value = 9
Run 2:
enter a postfix expression: 3 5 2 * +
evaluated value = 13
Difference Between Constructor Injection and Setter Injection in Spring

Dependency Injection is a practice to pass dependent object to other objects. Spring has two types of Dependency Injection :
Constructor based Injection -When container call the constructor of the class. It should be used for mandatory dependencies.
Constructor based Injection -When container call the constructor of the class. It should be used for mandatory dependencies.
Let’s say Class X is tightly  dependent on Class Y then we should use constructor based injection.  
Setter based Injection - It can be used by calling setter methods on your beans. It should be used for optional dependencies.
Setter based Injection - It can be used by calling setter methods on your beans. It should be used for optional dependencies.
Both types of injection has their own pros and cons. Below is a list of some differences −
public class ConstructorInjectionExample {
   public ConstructorInjectionExample(BaseExmp baseExmp) {
      // ...
   }
}
<beans>
   <bean id = "ConstructorInjectionExample" class = "x.y.ConstructorInjectionExample">
   <constructor-arg ref = "baseExmp"/>
</bean>

<bean id = "baseExmp" class = "x.y.BaseExmp"/>

</beans>
public class SetterInjectionExample {

   public void setBaseExmp(BaseExmp baseExmp) {
      this.baseExmp = baseExmp;
   }
}
<beans>
   <bean id = "setterInjectionExample" class = "x.y.SetterInjectionExample">
   <property name = "baseExmp" ref = "baseExmp"/>
</bean>

</beans>
H2 Database - Truncate

TRUNCATE is a command used to delete the data from the table.  Unlike DELETE FROM without WHERE clause, this command cannot be rolled back. This command commits an open transaction in this connection.
Following is the generic syntax of the truncate command.
TRUNCATE TABLE tableName 

In this example, we will truncate a table named test using the following query.
TRUNCATE TABLE test;

The above query produces the following output.
(6) row (s) effected 


    14 Lectures 
     1 hours 

 Mahesh Kumar

    100 Lectures 
     9.5 hours 

 Hari Om Singh

    108 Lectures 
     8 hours 

 Pavan Lalwani

    10 Lectures 
     1 hours 

 Deepti Trivedi

    20 Lectures 
     2 hours 

 Deepti Trivedi

    14 Lectures 
     1 hours 

 Deepti Trivedi
 Print
 Add Notes
 Bookmark this page
MySQL query to update string field by concatenating to it?

For concatenating a string field, use CONCAT() function. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> SequenceId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> StudentId varchar(100)
   -> );
Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(StudentId) values('STU');
Query OK, 1 row affected (0.14 sec)

mysql> insert into DemoTable(StudentId) values('STU1');
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
+------------+-----------+
| SequenceId | StudentId |
+------------+-----------+
| 1          | STU       |
| 2          | STU1      |
+------------+-----------+
2 rows in set (0.00 sec)
Here is the query to update string field by concatenating to it −
mysql> update DemoTable
   -> set StudentId=concat(StudentId,'-','101');
Query OK, 2 rows affected (0.14 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Let us check all the records once again from the table −
mysql> select *from DemoTable;
+------------+-----------+
| SequenceId | StudentId |
+------------+-----------+
| 1          | STU-101   |
| 2          | STU1-101  |
+------------+-----------+
2 rows in set (0.00 sec)
Python | Check for URL in a String

29 Dec, 2020
Prerequisite : Pattern matching with Regular Expression
In this article, we will need to accept a string and we need to check if the string contains any URL in it. If the URL is present in the string, we will say URL’s been found or not and print the respective URL present in the string. We will use the concept of Regular Expression of Python to solve the problem.
Examples:
Input : string = 'My Profile: 
https://auth.geeksforgeeks.org/user/Chinmoy%20Lenka/articles 
in the portal of https://www.geeksforgeeks.org/'

Output : URLs :  ['https://auth.geeksforgeeks.org/user/Chinmoy%20Lenka/articles',
'https://www.geeksforgeeks.org/']

Input : string = 'I am a blogger at https://geeksforgeeks.org'
Output : URL :  ['https://geeksforgeeks.org']

To find the URLs in a given string we have used the findall() function from the regular expression module of Python. This return all non-overlapping matches of pattern in string, as a list of strings. The string is scanned left-to-right, and matches are returned in the order found.
# Python code to find the URL from an input string# Using the regular expressionimport re  def Find(string):      # findall() has been used     # with valid conditions for urls in string    regex = r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))"    url = re.findall(regex,string)          return [x[0] for x in url]      # Driver Codestring = 'My Profile: https://auth.geeksforgeeks.org/user/Chinmoy%20Lenka/articles in the portal of https://www.geeksforgeeks.org/'print("Urls: ", Find(string))
Output:
Urls:  ['https://auth.geeksforgeeks.org/user/Chinmoy%20Lenka/articles',
'https://www.geeksforgeeks.org/']

rajasekharreddydonthireddy
Python Regex-programs
Python string-programs
python-regex
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.from_array()

13 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.from_array() function construct a Series object from an array. We can also set the name and index of the series at the time of creation.
Syntax: Series.from_array(arr, index=None, name=None, dtype=None, copy=False, fastpath=False)
Parameter :arr : array to be used for construction of seriesindex : set the index of the seriesname : Set the name of the series
Returns : series
Example #1: Use Series.from_array() function to construct a series object from an array.
# importing pandas as pdimport pandas as pd  # Creating an arrayarray = ['New York', 'Chicago', 'Toronto', 'Lisbon', 'Rio']  # Create the Indexindex_ = ['City 1', 'City 2', 'City 3', 'City 4', 'City 5']   # Creating the seriessr = pd.Series.from_array(arr = array, index = index_)  # Print the seriesprint(sr)
Output :
As we can see in the output, the Series.from_array() function has successfully constructed a series object from an array. Example #2: Use Series.from_array() function to construct a series object from an array. Also set the name of the series
# importing pandas as pdimport pandas as pd  # Creating an arrayarray = [11, 21, 8, 18, 65, 84, 32, 10, 5, 24, 32]  # Create the Indexindex_ = pd.date_range('2010-10-09', periods = 11, freq ='M')  # Creating the series# set the index# set the namesr = pd.Series.from_array(arr = array, index = index_, name = 'My_series')  # Print the seriesprint(sr)
Output :
As we can see in the output, the Series.from_array() function has successfully constructed a series object from an array. We have also set the name of the series.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.axes.Axes.get_visible() in Python

30 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.get_visible() function in axes module of matplotlib library is used to get the visibility.
Syntax: Axes.get_visible(self)
Parameters: This method does not accepts any parameter.
Returns: This method return the visibility.
Below examples illustrate the matplotlib.axes.Axes.get_visible() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltfrom mpl_toolkits.axisartist.axislines import Subplot      fig, ax = plt.subplots()  ax.plot([1, 2, 34, 67, 43, 5, 8])  ax.set_title("Visibility : " +str(ax.get_visible()))         fig.suptitle('matplotlib.axes.Axes.get_visible()\ function Example\n', fontweight ="bold")  plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.axisartist.axislines import Subplot    fig = plt.figure()    ax = Subplot(fig, 111)fig.add_subplot(ax)         X = np.arange(-20, 20, 0.5)Y = np.arange(-20, 20, 0.5)U, V = np.meshgrid(X, Y)     ax.quiver(X, Y, U, V)  ax.axis["bottom"].set_visible(False)ax.axis["top"].set_visible(False)    print("Visibilities of Axis")print("Bottom :", ax.axis["bottom"].get_visible(),      "\nTop :", ax.axis["top"].get_visible(),      "\nLeft :", ax.axis["left"].get_visible(),      "\nRight :", ax.axis["right"].get_visible())         fig.suptitle('matplotlib.axes.Axes.get_visible() \function Example\n', fontweight ="bold")  plt.show()
Output:
Visibilities of Axis
Bottom : False 
Top : False 
Left : True 
Right : True

Matplotlib axes-class
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML | DOM Audio volume Property - GeeksforGeeks

30 Jul, 2019
The HTML DOM Audio volume property is used for set or return the current volume of the Audio element. The volume value 0.0 represents silent and 1.0 represents loudest.
Syntax:
It returns the volume property.audio.volume
It sets the volume property.
audio.volume = number
audio.volume
It sets the volume property.
audio.volume = number
It sets the volume property.
audio.volume = number
audio.volume = number
Property Values: It contains single property value number which represents the value of audio volume. The value of volume are:
1.0: It is the highest volume. It is the default value.
0.5: It is used to specify half volume.
0.0: It is used to specify zero volume/mute/silent.
Return value: It returns a numeric value which represents the current volume of the Audio element.
Below program illustrates the Audio Volume property in HTML DOM:
Example:
<!DOCTYPE html> <html>   <head>     <title>         HTML DOM Audio Volume Property     </title> </head>   <body style="text-align: center">       <h1 style="color: green">         GeeksforGeeks     </h1>           <h2 style="font-family: Impact">         HTML DOM Audio Volume Property     </h2>     <br>       <audio id="Test_Audio" controls>                       <source src= "https://media.geeksforgeeks.org/wp-content/uploads/20190531165842/Recording1514.ogg"                type="audio/ogg">           <source src= "https://media.geeksforgeeks.org/wp-content/uploads/20190531165842/Recording1514.mp3"                type="audio/mpeg">     </audio><br>          <button onclick="volume()" type="button">        Return Volume    </button>          <button onclick="Set_vol1()" type="button">        Set HalfVolume    </button>          <button onclick="Set_vol2()" type="button">        Set Fullvolume     </button><br>           <script>        var gfg = document.getElementById("Test_Audio");                  function volume() {             alert(gfg.volume);        }                   function Set_vol1() {             gfg.volume = 0.2;        }                   function Set_vol2() {             gfg.volume = 1.0;        }     </script> </body>   </html>
Output:
Before Clicking on the Button:
After Clicking on Return Volume Button:
After Clicking on SetHalfVolume Button:
After Clicking on SetFullVolume Button:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-DOM
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Design a web page using HTML and CSS
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
How to stretch elements to fit the whole height of the browser window with CSS?

To stretch elements to fit the whole height of the browser window with CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
   *{
      box-sizing: border-box;
   }
   html, body {
      height: 100%;
      margin: 0;
   }
   .fullHeight{
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      height: 100%;
      background: rgb(135, 27, 207);
      color:white;
      font-size: 40px;
      padding: 40px;
   }
</style>
</head>
<body>
<div class="fullHeight">This div element will stretch to the whole height and width of the
window</div>
</body>
</html>
The above code will produce the following output −
Angular 8 - Building with Bazel

Bazel is an advanced build and test tool. It supports lot of features suitable for large projects.
Some of the features of Bazel are as follows:
Support multiple languages.
Support multiple platforms.
Support multiple repository.
Support high-level build language.
Fast and reliable.
Angular supports building the application using bazel. Let us see how to use bazel to compile Angular application. 
First, install @angular/bazel package. 
npm install -g @angular/bazel 

For existing application, Add @angular/bazel as mentioned below:
ng add @angular/bazel

For new application, use below mentioned command:
ng new --collection=@angular/bazel 

To build an application using bazel, use below command:
ng build --leaveBazelFilesOnDisk

Here,
leaveBazelFilesOnDisk option will leave the bazel files created during build process, which we can use to build the application directly using bazel.
To build application using bazel directly, install @bazel/bazelisk and then, use bazelisk build command.
npm install -g @bazel/bazelisk 
bazelisk build


    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
C++ Operators

Operators are used to perform operations on variables and values.
In the example below, we use the
+ operator to add together two values:
Although the + operator is often used to add together two values, like in the example above, it can also be used to add together a variable and a value, or a variable and another variable:
C++ divides the operators into the following groups:
Arithmetic operators
Assignment operators
Comparison operators
Logical operators
Bitwise operators
Arithmetic operators are used to perform common mathematical operations.
Multiply 10 with 5, and print the result.
cout << 10  5;

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Tryit Editor v3.7

Tryit: Center with position and transform
Pie Charts - Solved Examples

Directions(Q 1 to Q 4): The pie-graph given below shows the breakup of the cost of construction of a house. Assuming that the total cost of construction is Rs 600000, answer the question given below:
Q 1 - The sum spent on cement is:
A - Rs 200000 
B - Rs 160000 
C - Rs 120000 
D - Rs 100000 
Answer - C
Explanation
Amount spent on cement= Rs (72/360*600000) = Rs 120000 

Q 2 - The sum spent on work surpasses the sum spent on steel by
A - 5% of the aggregate expense 
B - 10% of the aggregate expense 
C - 12% of the aggregate expense
D - 15% of the aggregate expense 
Answer - B
Explanation
Amount spent on labor=Rs (90/360*600000)=Rs 150000. 
Sum spent on steel =Rs (54/360*600000) =Rs 90000 
Excess=Rs (150000-90000=Rs 60000 
Let 60000=x% of 600000. At that point x/100*600000=60000. 
∴ x=10% of aggregate expense. 

Q 3 - The sum spent on cement, steel and supervision is the thing that percent of the aggregate expense of development?
A - 40%
B - 45%
C - half
D - 55%
Answer - C
Explanation
Amount spent on concrete, steel and supervision 
=Rs {72+54+54/360*600000} =Rs 300000 
= half of aggregate expense of development. 

Q 4 - The sum spent on work surpasses the sum spent on supervision by:
A - Rs 200000 
B - Rs 160000 
C - Rs 120000 
D - Rs 60000 
Answer - D
Explanation
(Amount spent on work)- (Amount spent on supervision) 
=Rs (90/360*600000) - Rs (54/360*6000000) 
=Rs (150000-90000) =Rs 60000.

Directions(Q 5 to Q 9): Study the following information to answer the question given below:
Q 5 - What is the distinction in direct enlists and promotee Assistants?
A - 210 
B - 280 
C - 180 
D - None of these 
Answer - A
Explanation
Total number of assistant= 15% of 7000 = (15/100*7000) =1050. 
Number of direct recruits= 40% of 1050= (40/100*1050) =420 
Number of promotee associates = (1050-420) =630. 
Required contrast = (630-420) =210 

Q 6 - The promotee representative - I is roughly what percent of that of that of direct enlist clerk - I?
A - 10% 
B - 9% 
C - 10.8% 
D - 10.5% 
Answer - C
Explanation
) Number of clerk I =19% of 7000= (7000*19/100) =1330. 
Number of direct selects =90% of 1330= (90/100*1330) =1197. 
Number of promotes= (1330-1197) =133 
∴ required % = (133/1197*100) %= 13300/1197%=10.8%

Q 7 - What numbers of workers are supervisors?
A - 1190
B - 1019
C - 1109
D - 1290
Answer - A
Explanation
Number of supervisors=17% of 7000=(7000*17/100)=1190. 

Q 8 - What number of aggregate direct enrolls among a wide range of workers arrive? 
A - 4000
B - 3885
C - 3000
D - 3115
Answer - A
Explanation
Average rate of direct selects = 1/3 (30+40+50+90+30+90+70)=400/7%. 
Required total=400/7% of 7000= (7000*400/7*1/100) =4000 

Q 9 - Which sort of workers has most extreme number of direct enrolls?  
A - Clerk I & Officer I 
B - Officer I 
C - Clerk I
D - Clerk II
Answer - A
Explanation
Total rate of clerk I and officer I= (19+8)%=27%. 
Rate of direct Recruits=90% each. 
Hence, clerk I and Officer I together have most extreme number of direct enrolls.


    87 Lectures 
     22.5 hours 

 Programming Line
 Print
 Add Notes
 Bookmark this page
How to get text with selenium web driver in python?

We can extract text of an element with a selenium webdriver. This is done with the help of a text method. It fetches the text in an element which can be later validated.
First we need to identify the element with the help of any locators. Suppose we want to get the text of an element in below page.
Code Implementation.
from selenium import webdriver
driver = webdriver.Chrome (executable_path="C:\\chromedriver.exe")
# maximize with maximize_window()
driver.maximize_window()
driver.get("https://www.tutorialspoint.com/index.htm")
# identify element
l=driver.find_element_by_css_selector("h4")
# get text and print
print("Text is: " + l.text)
driver.close()
TimeSpan.Add() Method in C#

30 Sep, 2019
This method is used to a get new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance.
Syntax public TimeSpan Add (TimeSpan t);
Parameter:t: This parameter specifies the time interval to be added.
Return Value: It returns a new TimeSpan object whose value is the sum current instance and the value of t.
Exception:OverflowException:It occurs when the resulting TimeSpan is smaller than smallest possible value or greater than the largest possible value.
Below programs illustrate the use of TimeSpan.Add(TimeSpan) Method:
Example 1:
// C# program to demonstrate the// TimeSpan.Add(TimeSpan) Methodusing System;  class GFG {      // Main Method    public static void Main()    {        try {              // creating the TimeSpan object            TimeSpan t1 = new TimeSpan(3, 22, 35, 33);            TimeSpan t2 = new TimeSpan(1, 11, 15, 16);            TimeSpan variable = t1.Add(t2);              Console.WriteLine("The Timespan is : {0}",                                            variable);        }          catch (OverflowException e)         {            Console.Write("Exception Thrown: ");            Console.Write("{0}", e.GetType(), e.Message);        }    }}
The Timespan is : 5:09:50:49

Example 2: For Overflow Exception
// C# program to demonstrate the// TimeSpan.Add(TimeSpan) Methodusing System;  class GFG {      // Main Method    public static void Main()    {        try {              // the TimeSpan object            TimeSpan t1 = new TimeSpan(3, 22, 35, 33);            TimeSpan t2 = TimeSpan.MaxValue;            TimeSpan variable = t1.Add(t2);              Console.WriteLine("The Timespan is : {0}",                                            variable);        }          catch (OverflowException e)        {            Console.Write("Exception Thrown: ");            Console.Write("{0}", e.GetType(), e.Message);        }    }}
Exception Thrown: System.OverflowException

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.timespan.add?view=netframework-4.7.2
shubham_singh
CSharp-method
CSharp-TimeSpan-Struct
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Multiple inheritance using interfaces
Introduction to .NET Framework
C# | Delegates
Differences Between .NET Core and .NET Framework
C# | Data Types
C# | Method Overriding
C# | String.IndexOf( ) Method | Set - 1
C# | Constructors
C# | Class and Object
Reference to a pointer in C++ with examples and applications

10 Sep, 2018
Like references to simple data types, we can have references to pointers.
// CPP program to demonstrate references to pointers.#include <iostream>using namespace std;  int main(){    int x = 10;      // ptr1 holds address of x    int* ptr1 = &x;      // Now ptr2 also holds address of x.    // But note that pt2 is an alias of ptr1.    // So if we change any of these two to    // hold some other address, the other    // pointer will also change.    int*& ptr2 = ptr1;      int y = 20;    ptr2 = &y;      // Below line prints 20, 20, 10, 20    // Note that ptr1 also starts pointing    // to y.    cout << *ptr1 << " " << *ptr2 << " "         << x << " " << y;      return 0;}
20 20 10 20

What is application of above?Consider a situation where we pass a pointer to a function and we want the function to modify the pointer to point to something else and we want these changes to reflect in caller. For example, writing a linked list function that changes head of it, we pass reference to pointer to head so that the function can change the head (An alternative is to return the head). We can also achieve same thing using double pointers.
// A C++ program to demonstrate application// of reference to a pointer.#include <iostream>using namespace std;  // A linked list nodestruct Node {    int data;    struct Node* next;};  /* Given a reference to pointer to the head of   a list, insert a new value x at head */void push(struct Node *&head, int x){    struct Node* new_node = new Node;    new_node->data = x;    new_node->next = head;    head = new_node;}  // This function prints contents of linked// list starting from headvoid printList(struct Node* node){    while (node != NULL) {        cout << node->data << " ";        node = node->next;    }}  /* Driver program to test above functions*/int main(){    /* Start with the empty list */    struct Node* head = NULL;    push(head, 1);    push(head, 2);    push(head, 3);      printList(head);      return 0;}
3 2 1

cpp-pointer
cpp-references
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
std::string class in C++
Queue in C++ Standard Template Library (STL)
Unordered Sets in C++ Standard Template Library
std::find in C++
List in C++ Standard Template Library (STL)
Inline Functions in C++
scipy.stats.expon() | Python

20 Mar, 2019
scipy.stats.expon() is an exponential continuous random variable that is defined with a standard format and some shape parameters to complete its specification.
Parameters :q : lower and upper tail probabilityx : quantilesloc : [optional] location parameter. Default = 0scale : [optional] scale parameter. Default = 1size : [tuple of ints, optional] shape or random variates.moments : [optional] composed of letters [‘mvsk’]; ‘m’ = mean, ‘v’ = variance, ‘s’ = Fisher’s skew and ‘k’ = Fisher’s kurtosis. (default = ‘mv’).
Results : exponential continuous random variable
Code #1 : Creating exponential continuous random variable
   from scipy.stats import expon   numargs = expon.numargs[ ] = [0.6, ] * numargsrv = expon( )  print ("RV : \n", rv) 
Output :
RV : 
 <scipy.stats._distn_infrastructure.rv_frozen object at 0x0000018D56531CC0>

Code #2 : exponential random variates and probability distribution.
import numpy as npquantile = np.arange (0.01, 1, 0.1)   # Random VariatesR = expon.rvs(scale = 2,  size = 10)print ("Random Variates : \n", R)  # PDFR = expon.pdf(quantile, loc = 0, scale = 1)print ("\nProbability Distribution : \n", R)
Output :
Random Variates : 
 [2.50259466e-04 4.32311862e+00 8.22833503e-01 1.63374263e+00
 4.46784023e+00 3.56781485e+00 3.95381396e+00 1.17623772e+00
 3.21834266e-02 4.14778445e+00]

Probability Distribution : 
 [0.99004983 0.89583414 0.81058425 0.73344696 0.66365025 0.60049558
 0.54335087 0.4916442  0.44485807 0.40252422]
 
Code #3 : Graphical Representation.
import numpy as npimport matplotlib.pyplot as plt  distribution = np.linspace(0, np.minimum(rv.dist.b, 5))print("Distribution : \n", distribution)  plot = plt.plot(distribution, rv.pdf(distribution))
Output :
Distribution : 
 [0.         0.10204082 0.20408163 0.30612245 0.40816327 0.51020408
 0.6122449  0.71428571 0.81632653 0.91836735 1.02040816 1.12244898
 1.2244898  1.32653061 1.42857143 1.53061224 1.63265306 1.73469388
 1.83673469 1.93877551 2.04081633 2.14285714 2.24489796 2.34693878
 2.44897959 2.55102041 2.65306122 2.75510204 2.85714286 2.95918367
 3.06122449 3.16326531 3.26530612 3.36734694 3.46938776 3.57142857
 3.67346939 3.7755102  3.87755102 3.97959184 4.08163265 4.18367347
 4.28571429 4.3877551  4.48979592 4.59183673 4.69387755 4.79591837
 4.89795918 5.        ]
Code #4 : Varying Positional Arguments
import matplotlib.pyplot as pltimport numpy as np  x = np.linspace(0, 5, 100)  # Varying positional argumentsy1 = expon.pdf(x, 2, 6)y2 = expon.pdf(x, 1, 4)plt.plot(x, y1, "*", x, y2, "r--")
Output :
Python scipy-stats-functions
Python-scipy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Convert integer to string in Python
PHP | imageresolution() Function

06 Jan, 2022
The imageresolution() function is an inbuilt function in PHP which is used to set and return the resolution of an image in DPI (dots per inch). If none of the optional parameters is given, the current resolution is returned as an indexed array. If one of the optional parameters is given it will set both width and height to that parameter. The resolution is only used as meta information when images are read from and written to formats supporting this kind of information (currently PNG and JPEG). It does not affect how the image looks. The default resolution for new images is 96 DPI.Syntax: 
mixed imageresolution( resource $image, int $res_x, int $res_y )
Parameters: This function accepts three parameters as mentioned above and described below: 
$image: It specifies the image resource to work on.
$res_x (Optional): It specifies the horizontal resolution in DPI.
$res_y (Optional): It specifies the vertical resolution in DPI.
Return Value: This function returns the indexed array when used as getter and when used as setter returns TRUE on success or FALSE on failure.Below examples illustrate the imageresolution() function in PHP:Example 1: In this example we will get the resolution of the image. 
php
<?php // Load the png image$image = imagecreatefrompng('https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Get the image resolution$imageresolution = imageresolution($image);print("<pre>".print_r($imageresolution, true)."</pre>");?>
Output: 
Array
(
    [0] => 96
    [1] => 96
)
Example 2: In this example we will set the resolution of the image, 
php
<?php // Load the png image$image = imagecreatefrompng('https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Set the resolutionimageresolution($image, 400, 200); // Get the image resolution$imageresolution = imageresolution($image);print("<pre>".print_r($imageresolution, true)."</pre>");?>
Output: 
Array
(
    [0] => 400
    [1] => 200
)
Reference: https://www.php.net/manual/en/function.imageresolution.php
gulshankumarar231
PHP-function
PHP-image-functions
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.