code-rag-bench/online-tutorials huggingface dataset:
How to change MySQL timezone?

To change the timezone in MySQL, we can use the SET command. The following is the syntax.
SET time_zone=’someValue’;

Let us now use the above syntax and apply it in the below query.
mysql > SET time_zone = '+8:00';
Query OK, 0 rows affected (0.00 sec)
Above, the time_zone is changed by a value equivalent to 8. To change the timezone globally, use the GLOBAL command. Here is the syntax.
SET GLOBAL time_zone = 'someValue';

Here is an example.
mysql> SET GLOBAL time_zone = '+8:00';
Query OK, 0 rows affected (0.00 sec)
The above query will change the timezone globally.
Java | Inheritance | Question 4

28 Jun, 2021
Which of the following is true about inheritance in Java?

1) Private methods are final.
2) Protected members are accessible within a package and 
   inherited classes outside the package.
3) Protected methods are final.
4) We cannot override private methods. 
(A) 1, 2 and 4(B) Only 1 and 2(C) 1, 2 and 3(D) 2, 3 and 4Answer: (A)Explanation: See https://www.geeksforgeeks.org/can-override-private-methods-java/ and https://www.geeksforgeeks.org/comparison-of-inheritance-in-c-and-java/Quiz of this Question
Inheritance
java-inheritance
Java Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java | Constructors | Question 3
Java | Exception Handling | Question 2
Java | Functions | Question 1
Java | Exception Handling | Question 3
Java | Exception Handling | Question 8
Java | Exception Handling | Question 4
Java | Abstract Class and Interface | Question 2
Java | Exception Handling | Question 7
Java | Exception Handling | Question 6
Java | Class and Object | Question 1
Tryit Editor v3.7

Tryit: HTML section element
How to Perform Basic Linear Algebra on Arduino?

The BasicLinearAlgebra library helps represent matrices and perform matrix math on Arduino. To install it, search for 'BasicLinearAlgebra' in the Library Manager.
Once installed, go to: File → Examples → BasicLinearAlgebra → HowToUse
As the name suggests, this example shows how to use this library. While the comments in this example do much of the explanation, here are a few pointers that help illustrate the use of this library −
You need to include the library and define the BLA namespace before getting started, as all the functions are wrapped up inside the BLA namespace.
#include <BasicLinearAlgebra.h>
using namespace BLA;
A matrix is defined using the following syntax −
BLA::Matrix<3,3> A;
A vector is defined using the following syntax:
BLA::Matrix<3> v;
To set every element of the matric/vector to a specific value, use the Fill() function.
v.Fill(0);
The row and column counts can be obtained using the .getRowCount() and .getColCount() respectively.
The inverse of a matrix is calculated using .Inverse() function.
To get the transpose, use the ~ operator. A_T = ~A.
A matrix can be initialized with the following syntax −
BLA::Matrix<3,3> B = {6.54, 3.66, 2.95,
                     3.22, 7.54, 5.12,
                     8.98, 9.99, 1.56};
Or using the Eigen-style comma notation −
A << 3.25, 5.67, 8.67,
      4.55, 7.23, 9.00,
      2.35, 5.73, 10.56;
You can horizontally concatenate two matrices using the || operator, and vertically using the && operator.
BLA::Matrix<3,6> AleftOfB = A || B;
BLA::Matrix<6,3> AonTopOfB = A && B;
There are several other operations (multiplication, addition, subtraction, etc.). You are encouraged to go through the entire example (it is heavily commented) to understand the syntax for these various operations. Also, you are strongly encouraged to go through the other examples that come along with this library. Several complex calculations are now possible onboard the Arduino, thanks to this library.
The purpose of this article was to make you aware that this library exists and what all is possible with this library. Also, needless to say, this library also allows printing of matrices on the Serial Monitor.
If you run this example, your Serial Monitor output looks like
Orthogonal Array Testing

Orthogonal array testing is a systematic and statistical way of a black box testing technique used when number of inputs to the application under test is small but too complex for an exhaustive testing.
OAT, is a systematic and statistical approach to pairwise interactions.
OAT, is a systematic and statistical approach to pairwise interactions.
Executing a well-defined and a precise test is likely to uncover most of the defects.
Executing a well-defined and a precise test is likely to uncover most of the defects.
100% Orthogonal Array Testing implies 100% pairwise testing.
100% Orthogonal Array Testing implies 100% pairwise testing.
If we have 3 parameters, each can have 3 values then the possible Number of tests using conventional method is 3^3 = 27
While the same using OAT, it boils down to 9 test cases.

    80 Lectures 
     7.5 hours 

 Arnab Chakraborty

    10 Lectures 
     1 hours 

 Zach Miller

    17 Lectures 
     1.5 hours 

 Zach Miller

    60 Lectures 
     5 hours 

 John Shea

    99 Lectures 
     10 hours 

 Daniel IT

    62 Lectures 
     5 hours 

 GlobalETraining
 Print
 Add Notes
 Bookmark this page
How to concatenate two strings in C#?

To concatenate two strings, use the String.Concat method.
Let’s say you want to concatenate two strings in C#, str1 and str2, then add it as arguments in the Concat method −
string str3 = string.Concat(str1, str2);
The following is the example −
 Live Demo
using System;

class Program {
   static void Main() {

      string str1 = "Brad";
      string str2 = "Pitt";

      // Concat strings
      string str3 = string.Concat(str1, str2);
      Console.WriteLine(str3);
   }
}
BradPitt
Can interfaces have constructors in Java?

No, interfaces can’t have constructors for the following reasons −
All the members of an interface are abstract, and since a constructor cannot be abstract.
Still, if you try to write a constructor within an interface it will generate a compile time error.
public interface InterfaceTest {
   InterfaceTest(){
   }
   public abstract void display();
   public abstract void show();
}
C:\Sample>javac InterfaceTest.java
InterfaceTest.java:2: error: <dentifier> expected
public InterfaceTest(){
                     ^
1 error
Change grid interval and specify tick labels in Matplotlib

Using plt.figure() method, we can create a figure and thereafter, we can create an axis. Using set_xticks and set_yticks, we can change the ticks format and ax.grid could help to specify the grid interval.
Create a new figure, or activate an existing figure, using fig = plt.figure() method.
Create a new figure, or activate an existing figure, using fig = plt.figure() method.
Add an `~.axes.Axes` to the figure as part of a subplot arrangement, where nrow = 1, ncols = 1 and index = 1.
Add an `~.axes.Axes` to the figure as part of a subplot arrangement, where nrow = 1, ncols = 1 and index = 1.
Get or set the current tick locations and labels of the X-axis.
Get or set the current tick locations and labels of the X-axis.
Get or set the current tick locations and labels of the X-axis. With minor = True, Grid.
Get or set the current tick locations and labels of the X-axis. With minor = True, Grid.
Get or set the current tick locations and labels of the Y-axis.
Get or set the current tick locations and labels of the Y-axis.
Get or set the current tick locations and labels of the Y-axis. With minor = True, Grid.
Get or set the current tick locations and labels of the Y-axis. With minor = True, Grid.
Lay out a grid in current line style, using grid() method.
Lay out a grid in current line style, using grid() method.
To show the figure we can use the plt.show() method.
To show the figure we can use the plt.show() method.
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
major_tick = [10, 20, 30, 40, 50]
minor_tick = [5, 15, 25, 35, 45]
ax.set_xticks(major_tick) # Grid
ax.set_xticks(minor_tick, minor=True)
ax.set_yticks(major_tick) # Grid
ax.set_yticks(minor_tick, minor=True)

ax.grid(which='both')

ax.grid(which='minor', alpha=1)
ax.grid(which='major', alpha=2)

plt.show()
PHP: Remove object from array

The unset function can be used to remove array object from a specific index in PHP −
 Live Demo
$index = 2;
$objectarray = array(
   0 => array('label' => 'abc', 'value' => 'n23'),
   1 => array('label' => 'def', 'value' => '2n13'),
   2 => array('label' => 'abcdef', 'value' => 'n214'),
   3 => array('label' => 'defabc', 'value' => '03n2')
);
var_dump($objectarray);
foreach ($objectarray as $key => $object) {
   if ($key == $index) {
      unset($objectarray[$index]);
   }
}
var_dump($objectarray);
This will produce the following output −
array(4) { [0]=> array(2) { ["label"]=> string(3) "abc" ["value"]=> string(3) "n23" } [1]=> array(2) 
{ ["label"]=> string(3) "def" ["value"]=> string(4) "2n13" } [2]=> array(2) { ["label"]=> string(6) 
"abcdef" ["value"]=> string(5) "n214" } [3]=> array(2) { ["label"]=> string(6) "defabc" ["value"]=> 
string(5) "03n2" } } array(3) { [0]=> array(2) { ["label"]=> string(3) "abc" ["value"]=> string(3) 
"n23" } [1]=> array(2) { ["label"]=> string(3) "def" ["value"]=> string(4) "2n13" } [3]=> array(2) 
{ ["label"]=> string(6) "defabc" ["value"]=> string(5) "03n2" } }
An array with 4 objects is declared and assigned to variable ‘objectarray’. Here, we wish to remove the object from index 2, that is also declared with variable named ‘index’. The foreach loop is used to traverse through the array and when the index value in the traversal matches the index from where the value needs to be removed, the ‘unset’ function is called on that element and the remaining elements are returned as output.
Metasploit - Import Data

Metasploit is a powerful security framework which allows you to import scan results from other third-party tools. You can import NMAP scan results in XML format that you might have created earlier. Metasploit also allows you to import scan results from Nessus, which is a vulnerability scanner.
Let’s see how it works. At first, perform an NMAP scan and save the result in XML format on your desktop, as shown in the following screenshot.
Next, open Metasploit or Armitage to import the scan results. Thereafter, use the following command to import all the host.
Msf > db_import "path of xml file"  

The following screenshot shows what the output will look like.
To test whether the import file was correct or not, we can run specific commands on these two hosts and see how they respond. For example, in our case, we have listed all the hosts having the port 445 running on them.
 Print
 Add Notes
 Bookmark this page
How to find the critical value of F for regression anova in R?

To find the critical value of F for regression anova in R, we can follow the below steps −
First of all, create a data frame.
Then, create the regression model.
After that, find the critical value of F statistic using qf function.
Let's create a data frame as shown below −
 Live Demo
> x<-rpois(20,2)
> y<-rpois(20,5)
> df<-data.frame(x,y)
> df
On executing, the above script generates the below output(this output will vary on your system due to randomization) −
   x y
1  5 5
2  0 9
3  1 3
4  3 5
5  2 5
6  2 4
7  3 6
8  4 6
9  2 5
10 0 6
11 5 8
12 1 7
13 3 2
14 0 4
15 1 4
16 2 4
17 1 7
18 2 8
19 2 6
20 1 4
Using lm function to create the regression model between y and x and anova function to find the ANOVA table −
 Live Demo
> x<-rpois(20,2)
> y<-rpois(20,5)
> df<-data.frame(x,y)
> RegM<-lm(y~x,data=df)
> RegM_ANOVA<-anova(RegM)
> RegM_ANOVA
Analysis of Variance Table
Response: y
   Df Sum  Sq Mean Sq F value Pr(>F)
x  1  0.024 0.0238 0.0071 0.934
Residuals 18 60.776 3.3765
Using qf function to find the critical value of F for regression anova −
 Live Demo
> x<-rpois(20,2)
> y<-rpois(20,5)
> df<-data.frame(x,y)
> RegM<-lm(y~x,data=df)
> RegM_ANOVA<-anova(RegM)
> qf(1-0.05,RegM_ANOVA[1,1],RegM_ANOVA[2,1])
[1] 4.413873
What is a Pytest framework?

Pytest is a test framework in python. To install pytest, we need to use the command pip install pytest. After installation, we can verify if python has been installed by the command pytest –version. The version of pytest shall be
known.
Pytest can be used for creating and executing test cases. It can be used in a wide range of testing API, UI, database, and so on. The test file of pytest has a naming convention that it starts with test_ or ends with _test keyword and every line of
code should be inside a method that should have a name starting with test keyword. Also, each method should have a unique name.
Syntax
def test_f():
   print("Tutorialspoint")
To run the above code, we need to move to the terminal and use the command py.test. However, this will not give many details from an execution point of view. To get information on execution we should use the command py.test –v. Here v
stands for verbose.
In order to print the console logs, we need to use the command py.test –v –s. Again, if we want to run tests from a specific pytest file, the command is py.test
<filename> -v.
The advantages of pytest framework are listed below −
Pytest is capable of executing multiple test cases simultaneously, thereby reducing the execution duration.
Pytest is capable of executing multiple test cases simultaneously, thereby reducing the execution duration.
Pytest is capable of skipping a test method from a group of test methods during execution.
Pytest is capable of skipping a test method from a group of test methods during execution.
Pytest is free and does not have to license costs.
Pytest is free and does not have to license costs.
Pytest is quick and easy to learn.
Pytest is quick and easy to learn.
Pytest can choose to run a particular test method or all the test methods of a particular test file based on conditions.
Pytest can choose to run a particular test method or all the test methods of a particular test file based on conditions.
Pytest is capable of skipping a few test methods out of all the test methods during test execution.
Pytest is capable of skipping a few test methods out of all the test methods during test execution.
Pytest can be used to test a wide range of applications on API, database, and so on.
Pytest can be used to test a wide range of applications on API, database, and so on.
How to Create GUID / UUID in JavaScript?

We can create GUID or UUID in JavaScript using the following methods −
To create or generate UUID or GUID in javascript use the following code with Math.Random() function
function createUUID() {
   return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
      var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
      return v.toString(16);
   });
}
Note − This should not be used in production as GUID or UUID generated by Math.Random() may not be unique.
We can use npm's uuid module for generation of RFC4122 UUIDS. First install it using −
$ npm install uuid
Then create a js file(script.js) with the following contents −
const uuid = require('uuid')
console.log(uuid())
console.log(uuid())
console.log(uuid())
You can run it using the following command −
node script.js
Examples of created UUIDs −
a85a8e6b-348b-4011-a1ec-1e78e9620782
03ea49f8-1d96-4cd0-b279-0684e3eec3a9
7289708e-b17a-477c-8a77-9ab575c4b4d8
WebDriver click() vs JavaScript click().

We can click a link with the webdriver click and Javascript click. For the Selenium webdriver click of a link we can use link text and partial link text locator. We can use the methods driver.findElement(By.linkText()) and driver.findElement(By.partialLinkText()) to click.
The links in an html code are enclosed in an anchor tag. The link text enclosed within the anchor tag is passed as argument to the driver.findElement(By.linkText(<link text>)) method. The partial matching link text enclosed within the anchor tag is passed as argument to the driver.findElement(By.partialLinkText(<partial link text>)) method. Finally to click on the link the click method is used.
Let us see the html code of a link having the anchor tag.
Code Implementation.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.By;
public class DriverClick{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
      // identify link with link text locator
      driver.findElement(By.linkText("Write for us")).click();
      System.out.println("Page title after click: " + driver.getTitle());
   }
}
We can also perform web operations like clicking on a link with Javascript Executor in Selenium. We shall use the executeScript method and pass argument index.click() and webelement to be clicked as arguments to the method.
Code Implementation with Javascript executor.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.By;
public class DriverClickJs{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
      // identify link
      WebElement l = driver.findElement(By.linkText("Write for us"));
      //click link with Javascript Executor
      JavascriptExecutor j = (JavascriptExecutor) driver;
      j.executeScript("arguments[0].click();", l);
      System.out.println("Page title after click: " + driver.getTitle());
   }
}
Jackson Annotations - @JsonFilter

@JsonFilter is used to apply filter during serialization/de-serialization like which properties are to be used or not.
import java.io.IOException;
import java.text.ParseException;

import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;

public class JacksonTester {
   public static void main(String args[]) throws IOException, ParseException {
      ObjectMapper mapper = new ObjectMapper();     
      Student student = new Student(1,13, "Mark");
      
      FilterProvider filters = new SimpleFilterProvider() .addFilter(
         "nameFilter", SimpleBeanPropertyFilter.filterOutAllExcept("name"));
      
      String jsonString = mapper.writer(filters)             
         .withDefaultPrettyPrinter()
         .writeValueAsString(student);
      System.out.println(jsonString);
   }
}
@JsonFilter("nameFilter")
class Student {
   public int id;
   public int rollNo;
   public String name;

   Student(int id, int rollNo, String name) {
      this.id = id;
      this.rollNo = rollNo;
      this.name = name;
   }   
}
{
   "name" : "Mark"
}

 Print
 Add Notes
 Bookmark this page
Python Program for Program to find area of a circle - GeeksforGeeks

12 Apr, 2022
Area of a circle can simply be evaluated using following formula.
Area = pi * r2
where r is radius of circle 
Python3
# Python program to find Area of a circle  def findArea(r):    PI = 3.142    return PI * (r*r);  # Driver methodprint("Area is %.6f" % findArea(5));      # This code is contributed by Chinmoy Lenka
Python3
# Python program to find Area of a circle using inbuild library  import mathdef area(r): area = math.pi* pow(r,2) return print('Area of circle is:' ,area)area(4)    # This code is contributed by Sejal Pol
Please refer complete article on Program to find area of a circle for more details!
sejalpol2
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for factorial of a number
Python | Convert string dictionary to dictionary
Python program to add two numbers
Python Program for Binary Search (Recursive and Iterative)
Python Program for Bubble Sort
Iterate over characters of a string in Python
Python | Check if a variable is string
Python | Convert set into a list
CSS - list-style-type

The list-style-type property sets the counting (or bullet) style used in the marker for a list item.
Here are the values which can be used for an unordered list −
none
NA
disc (default)
A filled-in circle
circle
An empty circle
square
A filled-in square
Here are the values which can be used for an ordered list −
All the elements with a display of list-item.
object.style.listStyleType = "decimal"

Here is the example −
<html>
   <head>
   </head>
   
   <body>
      <ul style = "list-style-type:circle;">
         <li>Maths</li>
         <li>Social Science</li>
         <li>Physics</li>
      </ul>
      
      <ul style = "list-style-type:square;">
         <li>Maths</li>
         <li>Social Science</li>
         <li>Physics</li>
      </ul>
      
      <ol style = "list-style-type:decimal;">
         <li>Maths</li>
         <li>Social Science</li>
         <li>Physics</li>
      </ol>
      
      <ol style = "list-style-type:lower-alpha;">
         <li>Maths</li>
         <li>Social Science</li>
         <li>Physics</li>
      </ol>
      
      <ol style = "list-style-type:lower-roman;">
         <li>Maths</li>
         <li>Social Science</li>
         <li>Physics</li>
      </ol>
   
   </body>
</html> 
This will produce following result −
Maths
Social Science
Physics
Maths
Social Science
Physics

Maths
Social Science
Physics

Maths
Social Science
Physics

Maths
Social Science
Physics

Maths
Social Science
Physics

Maths
Social Science
Physics

Maths
Social Science
Physics

    33 Lectures 
     2.5 hours 

 Anadi Sharma

    26 Lectures 
     2.5 hours 

 Frahaan Hussain

    44 Lectures 
     4.5 hours 

 DigiFisk (Programming Is Fun)

    21 Lectures 
     2.5 hours 

 DigiFisk (Programming Is Fun)

    51 Lectures 
     7.5 hours 

 DigiFisk (Programming Is Fun)

    52 Lectures 
     4 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
SQL Query to Get a Financial Year Using a Given Date

17 Jun, 2021
Here, we are going to  Get a Financial Year Using a Given Date in SQL. In this article, we will be making use of the Microsoft SQL Server as our database.
For example, finding the Financial year for the give dates in the table. Here, we will first create a database named “geeks” then we will create a table “department” in that database. After, that we will execute our query on that table.
CREATE DATABASE geeks;
USE geeks;
CREATE TABLE [dbo].[department](
[ID] [int] NULL,
[SALARY] [int] NULL,
[NAME] [varchar](20) NULL,
[JoinDate] [datetime] NULL
) ON [PRIMARY]
GO
INSERT INTO [dbo].[department] VALUES  ( 1, 34000, 'Neha', '2013-09-24')  
INSERT INTO [dbo].[department] VALUES  ( 2, 33000, 'Hema', '2015-02-0' )
INSERT INTO [dbo].[department] VALUES  ( 3, 36000, 'Jaya', '2017-09-09' )
INSERT INTO [dbo].[department] VALUES  ( 4, 35000, 'Priya', '2018-05-18' )
INSERT INTO [dbo].[department] VALUES  ( 5, 34000, 'Ketan', '2019-02-25' )
GO
This is our data inside the table:
SELECT * FROM department;
To check the current financial year using SQL query:
DECLARE @FIYear VARCHAR(20)    
  SELECT @FIYear = (CASE WHEN (MONTH(GETDATE()))
  <= 3 THEN convert(varchar(4), YEAR(GETDATE())-1) + '-' + convert(varchar(4), YEAR(GETDATE())%100)
  ELSE convert(varchar(4),YEAR(GETDATE()))+ '-' + convert(varchar(4),(YEAR(GETDATE())%100)+1)END)    
  SELECT @FIYear AS F_YEAR    
Output:
To Get a Financial Year Using a Given Date in Table: 
 SELECT  (CASE WHEN (MONTH(JoinDate))  <=3 THEN convert(varchar(4),
  YEAR(JoinDate)-1)  + '-' + convert(varchar(4), YEAR(JoinDate)%100)    
   ELSE convert(varchar(4),YEAR(JoinDate))+ '-' + convert(varchar(4),
(YEAR(JoinDate)%100)+1)END) AS FinancialYear ,
*  FROM [test].[dbo].[department]   
Output:
surinderdawra388
Picked
SQL-Query
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Microsoft Azure – Graph Query to Get Properties of Azure VM Resource

29 Dec, 2021
The following are the Azure Resource Graph Queries where we will be used to fetch the static JSON data using azure KQL Queries. You can run the below queries in Azure Resource Graph Explorer in Azure Portal to fetch the results based on Query.
Example 1:
To get the complete properties of Azure VMs –
resources
| where type == "microsoft.compute/virtualmachines"
This query returns the details and the total number of results.
id
name
type
tenantId
kind
location
resourceGroup
subscriptionId
managedBy
sku
plan
properties
tags
identity
zones
extendedLocation
Sample Output:
Example 2: To get the properties of Azure VM Name, Resource Group, VM Admin User Name of all the VMs from the select scope.
resources
| where type == "microsoft.compute/virtualmachines"
| project name,resourceGroup,AdminUserName=tostring(properties.osProfile.adminUsername)
This query returns the output of VM Computer Name, Resource Group, and VM Admin Admin User Name of all the Azure VMs from the scope selected.
Sample Output:
Example 3: To get the properties of Azure VM Name, Resource Group, VM Admin User Name of a specific Azure VM from the select scope.
resources
| where type == "microsoft.compute/virtualmachines"
| where name == "CloudOpsVM"
| project name,resourceGroup,AdminUserName=tostring(properties.osProfile.adminUsername)
this query returns the output of VM Computer Name, Resource Group, and VM Admin Admin User Name of a Specific select VM.
Sample Output:
azure-virtual-machine
Cloud-Computing
Microsoft Azure
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Path getFileName() method in Java with Examples

16 Jul, 2019
The Path interface was added to Java NIO in Java 7. The Path interface is located in the java.nio.file package, so the fully qualified name of the Java Path interface is java.nio.file.Path. A Java Path instance represents a path in the file system. A path can use to locate either a file or a directory.path of an entity could be of two types one is an absolute path and other is a relative path. The absolute path is the location address from the root to the entity while the relative path is the location address which is relative to some other path.
getFileName() method of java.nio.file.Path used to return the name of the file or directory pointed by this path object. The file name is the farthest element from the root in the directory hierarchy.
Syntax:
Path getFileName()

Parameters: This method accepts nothing.
Return value: This method returns the name of the file or directory pointed by this path object.
Below programs illustrate getFileName() method:Program 1:
// Java program to demonstrate// java.nio.file.Path.getFileName() method  import java.io.IOException;import java.nio.file.Path;import java.nio.file.Paths;public class GFG {    public static void main(String[] args)        throws IOException    {          // create object of Path        Path path = Paths.get("D:/workspace/AmanCV.docx");          // call getFileName() and get FileName path object        Path fileName = path.getFileName();          // print FileName        System.out.println("FileName: "                           + fileName.toString());    }}
FileName: AmanCV.docx

Program 2:
// Java program to demonstrate// java.nio.file.Path.getFileName() method  import java.io.IOException;import java.nio.file.Path;import java.nio.file.Paths;public class GFG {    public static void main(String[] args)        throws IOException    {          // create object of Path        Path path = Paths.get("D:/Resume.pdf");          // call getFileName() and get FileName path object        Path fileName = path.getFileName();          // print FileName        System.out.println("FileName: "                           + fileName.toString());    }}
FileName: Resume.pdf

References: https://docs.oracle.com/javase/10/docs/api/java/nio/file/Path.html#getFileName()
Java-Functions
Java-Path
java.nio.file package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PHP | number_format() Function

03 Jul, 2018
The number_format() function is an inbuilt function in PHP which is used to format a number with grouped thousands. It returns the formatted number on success otherwise it gives E_WARNING on failure.
Syntax:
string number_format ( $number, $decimals, $decimalpoint, $sep )
Parameters: This function accepts four parameters as mentioned above and described below:
$number: It is required parameter which specified the number to be formatted. If no other parameters are set, the number will be formatted without decimals and with the comma (, ) as the thousands separator.
$decimals: It is optional parameter and used to specifies decimals. If this parameter is set, the number will be formatted with a dot (.) as the decimal point.
$decimalpoint: It is optional parameter and used to specifies the string to use for the decimal point.
$sep: It is optional parameter and used to specifies string to use for thousands separator. If this parameter is given, then all other parameters are required.
Return Value: It returns Formatted Number in case success, otherwise it gives E_WARNING in failure.
Examples:
Input: $number = 100000
Output: 10, 000

Input: $number = 10000 
       $decimals = 3 
       $decimalpoints = "." $sep =,
Output: 10, 0000.000 

Below programs illustrate The number_format() function in PHP:
Program 1:
<?php$num1 = "999999.49";  // With out decimal point parameterecho number_format($num1)."\n";  // With decimal Point parameterecho number_format($num1, 3)."\n";   $num2 = "9999999.99";  // With out decimal point parameter// return Round valueecho number_format($num2)."\n";  // With decimal Point parameterecho number_format($num2, 3)."\n";   // With All four parametersecho number_format("1000000.99", 3, "#", "GGG");     ?>
999,999
999,999.490
10,000,000
9,999,999.990
1GGG000GGG000#990

Program 2: If pass anything instead of numbers it gives warning.
<?php$num = "GFG";  // With out decimal point parameterecho number_format($num)."\n\n";  // With decimal Point parameterecho number_format($num, 3);   ?>
PHP Warning:  number_format() expects parameter 1 to be float,
string given in /home/ac476aaecea758334cb8ed146bcbb8f6.php on line 5

PHP Warning:  number_format() expects parameter 1 to be float, 
string given in /home/ac476aaecea758334cb8ed146bcbb8f6.php on line 8

Program 3: This function does not accept three parameters, only accept 1, 2 or 4 parameters.
<?php$num = 1000000;  // passing 3 parameters It gives errors because function// accepting only 1, 2 or 4 parametersecho number_format($num, 3, ", ");?>
PHP Warning:  Wrong parameter count for number_format() 
in /home/e426108b066d9a86366249bf7b626d19.php on line 6

Reference: http://php.net/manual/en/function.number-format.php
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Draw Hexagon Using Turtle Graphics

16 Oct, 2020
In this article, we will learn how to make a Hexagon using Turtle Graphics in Python. For that lets first know what is Turtle Graphics.
Turtle is a Python feature like a drawing board, which let us command a turtle to draw all over it! We can use many turtle functions which can move the turtle around. Turtle comes in the turtle library.The turtle module can be used in both object-oriented and procedure-oriented ways.
Some of the commonly used methods are:
forward(length): moves the pen in the forward direction by x unit.
backward(length): moves the pen in the backward direction by x unit.
right(angle): rotate the pen in the clockwise direction by an angle x.
left(angle): rotate the pen in the anticlockwise direction by an angle x.
penup(): stop drawing of the turtle pen.
pendown(): start drawing of the turtle pen.
Define an instance for turtle.
For a hexagon execute a loop 6 times.
In every iteration move turtle 90 units forward and move it left 300 degrees.
This will make up Hexagon .
Below is the python implementation of above approach.
Python3
# import the turtle modulesimport turtle # Start a work Screenws = turtle.Screen() # Define a Turtle InstancegeekyTurtle = turtle.Turtle() # executing loop 6 times for 6 sidesfor i in range(6):     # Move forward by 90 units    geekyTurtle.forward(90)     # Turn left the turtle by 300 degrees    geekyTurtle.left(300)
  
Turtle Making Hexagon
 
anshitaagarwal
Python-turtle
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala Type Hierarchy

01 Apr, 2019
There are no primitive types in Scala(unlike java). All data types in Scala are objects that have methods to operate on their data. All of Scala’s types exist as part of a type hierarchy.
Every class that we define in Scala will also belong to this hierarchy automatically.
Any is the superclass of all classes, also called the top class. It defines certain universal methods such as equals, hashCode, and toString. Any has two direct subclasses:
AnyVal
AnyRef
.Example:
// Scala program of Scala Type hierarchy   // Creating objectobject Geeks {      // Main method    def main(args: Array[String])     {        val list: List[Any] = List(                false,                66677,                732,                 'a',                 "abs"                    )          list.foreach(element => println(element))    }}
false
66677
732
a
abs

 AnyVal represents value classes. All value classes are predefined; they correspond to the primitive types of Java-like languages. There are nine predefined value types and they are non-null able: Double, Float, Long, Int, Short, Byte, Char, Unit, and Boolean. Scala has both numeric (e.g., Int and Double) and non-numeric types (e.g., String) that can be used to define values and variables. Boolean variables can only be true or false. Char literals are written with single-quotes.
Example:
// Scala program of Scala Type hierarchy// Using AnyVal.   // Creating Objectobject Geeks {      // Main method    def main(args: Array[String])     {        val list: List[AnyVal] = List(            333, true, false            )          list.foreach(element => println(element))    }}
333
true
false

 AnyRef represents reference classes. All non-value types are defined as reference types. User-defined classes define reference types by default; i.e. they always (indirectly) subclass scala.AnyRef. scala.AnyRef in java programming corresponds to java.lang.Object.
Example:
// Scala program of Scala Type hierarchy // Using AnyRef  // Creating objectobject Geeks{      // Main method    def main(args: Array[String])    {        val list: List[AnyRef] = List(        "GFG", "GEEKSFORGEEKS"            )          list.foreach(element => println(element))    }}
GFG
GEEKSFORGEEKS

 Nothing and Null:Nothing is a subclassify of all value types, it is also called the bottom type. Type Nothing That has no value. we can use Nothing to signal non-termination such as a thrown exception, program exit, or an infinite loop .
Null is a subclassify of all reference types. the keyword literal null can identify a single value. Null is provided mostly for interoperability with other JVM languages.
Picked
Scala
scala-parameterized-type
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to draw a circle in R?

There is no direct function in R to draw a circle but we can make use of plotrix package for this purpose. The plotrix package has a function called draw.cirlce which is can be used to draw a circle but we first need to draw a plot in base R then pass the correct arguments in draw.circle. The first and second arguments of draw.circle takes x and y coordinates, and the third one is for radius, hence these should be properly chosen based on the chart in base R.
Loading plotrix package:
> library(plotrix)
Creating different circles using draw.circle:
Live Demo
> plot(1:10,type="n")
> draw.circle(2,4,1)
Live Demo
> plot(1:10,type="n")
> draw.circle(5,6,1)
Types of Gradients in CSS

Gradients display the combination of two or more colors.
The following are the types of gradients:
Linear Gradients(down/up/left/right/diagonally)
Radial Gradients
Let us see an example of radial gradients:
Live Demo
<html>
   <head>
      <style>
         #grad1 {
            height: 100px;
            width: 550px;
            background: -webkit-radial-gradient(red 5%, green 15%, pink 60%);
            background: -o-radial-gradient(red 5%, green 15%, pink 60%);
            background: -moz-radial-gradient(red 5%, green 15%, pink 60%);
            background: radial-gradient(red 5%, green 15%, pink 60%);
         }
      </style>
   </head>
   <body>
      <div id = "grad1"></div>
   </body>
</html>
Difference between NumPy.dot() and '*' operation in Python - GeeksforGeeks

09 Jul, 2021
In Python if we have two numpy arrays which are often referred as a vector. The ‘*’ operator and numpy.dot() work differently on them. It’s important to know especially when you are dealing with data science or competitive programming problem. 
‘*’ operation caries out element-wise multiplication on array elements. The element at a[i][j] is multiplied with b[i][j] .This happens for all elements of array.Example:  
Let the two 2D array are v1 and v2:-
v1 = [[1, 2], [3, 4]]
v2 = [[1, 2], [3, 4]]

Output:
[[1, 4]
[9, 16]]
From below picture it would be clear.
 
 
It carries of normal matrix multiplication . Where the condition of number of columns of first array should be equal to number of rows of second array is checked than only numpy.dot() function take place else it shows an error. Example:  
Let the two 2D array are v1 and v2:-
v1=[[1, 2], [3, 4]]
v2=[[1, 2], [3, 4]]
Than numpy.dot(v1, v2)  gives output of :-
[[ 7 10]
 [15 22]]
Examples 1:  
Python3
import numpy as np  # vector v1 of dimension (2, 2)v1 = np.array([[1, 2], [1, 2]]) # vector v2 of dimension (2, 2)v2 = np.array([[1, 2], [1, 2]]) print("vector multiplication")print(np.dot(v1, v2)) print("\nElementwise multiplication of two vector")print(v1 * v2)
Output :
vector multiplication
[[3 6]
 [3 6]]

Elementwise multiplication of two vector
[[1 4]
 [1 4]]
Examples 2:  
Python3
import numpy as np  v1 = np.array([[1, 2, 3], [1, 2, 3], [1, 2, 3]]) v2 = np.array([[[1, 2, 3], [1, 2, 3], [1, 2, 3]]]) print("vector multiplication")print(np.dot(v1, v2)) print("\nElementwise multiplication of two vector")print(v1 * v2)
Output :
vector multiplication
[[ 6 12 18]
 [ 6 12 18]
 [ 6 12 18]]

Elementwise multiplication of two vector
[[1 4 9]
 [1 4 9]
 [1 4 9]]
singghakshay
sumitgumber28
Python-numpy
Difference Between
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Difference between Process and Thread
Stack vs Heap Memory Allocation
Difference Between Method Overloading and Method Overriding in Java
Difference between Clustered and Non-clustered index
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
GATE | GATE-CS-2015 (Set 1) | Question 64 - GeeksforGeeks

17 Sep, 2021
The least number of temporary variables required to create a three-address code in static single assignment form for the expression q + r/3 + s – t * 5 + u * v/w is(A) 4(B) 8(C) 7(D) 9Answer: (B)Explanation:
The correct answer is 8. This question was asked as a fill in the blank type question in the exam.
 
Three address code is an intermediate code generated by compilers while optimizing the code. Each three address code instruction can have atmost three operands (constants and variables) combined with an assignment and a binary operator. The point to be noted in three address code is that the variables used on the left hand side (LHS) of the assignment cannot be repeated again in the LHS side. Static single assignment (SSA) is nothing but a refinement of the three address code.
So, in this question, we have
t1 = r / 3;

t2 = t * 5;

t3 = u * v;

t4 = t3 / w;

t5 = q + t1;

t6 = t5 + s;

t7 = t6 - t2; 

t8 = t7 + t4;
Therefore, we require 8 temporary variables (t1 to t8) to create the three address code in static single assignment form.
YouTubeGeeksforGeeks GATE Computer Science16.1K subscribersGATE PYQ - Code Generation and Optimization | Joyojyoti Acharya | GeeksforGeeks GATE |Watch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0050:30 / 59:20•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=4ab8S2Qs7h8" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2015 (Set 1)
GATE-GATE-CS-2015 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE-IT-2004 | Question 83
GATE | GATE CS 2018 | Question 37
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 63
GATE | GATE-CS-2007 | Question 17
GATE | GATE-IT-2004 | Question 12
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2007 | Question 64
Get the list of all declared fields in Java

The list of all declared fields can be obtained using the java.lang.Class.getDeclaredFields() method as it returns an array of field objects. These field objects include the objects with the public, private, protected and default access but not the inherited fields.
Also, the getDeclaredFields() method returns a zero length array if the class or interface has no declared fields or if a primitive type, array class or void is represented in the Class object.
A program that demonstrates this is given as follows −
 Live Demo
import java.lang.reflect.*;
public class Demo {
   public static void main(String[] argv) throws Exception {
      Class c = java.lang.String.class;
      Field[] fields = c.getDeclaredFields();
      for(int i = 0; i < fields.length; i++) {
         System.out.println("The Field is: " + fields[i].toString());
      }
   }
}
The Field is: private final char[] java.lang.String.value The Field is: private int java.lang.String.hash The Field is: private static final long java.lang.String.serialVersionUID The Field is: private static final java.io.ObjectStreamField[] java.lang.String.serialPersistentFields The Field is: public static final java.util.Comparator java.lang.String.CASE_INSENSITIVE_ORDER
Now let us understand the above program.
The class c holds the java.lang.String.class.. Then the array fields[] stores the field objects of this class that are obtained using the method getDeclaredFields(). Then the fields are displayed using the for loop. A code snippet which demonstrates this is as follows −
Class c = java.lang.String.class;
Field[] fields = c.getDeclaredFields();
for(int i = 0; i < fields.length; i++) {
   System.out.println("The Field is: " + fields[i].toString());
}
ReactJS Fragments

04 Feb, 2021
We know that we make use of the render method inside a component whenever we want to render something to the screen. We may render a single element or multiple elements, though rendering multiple elements will require a ‘div’ tag around the content as the render method will only render a single root node inside it at a time.  
Example: Create a React app and edit the App.js file from the src folder as:
Filename- App.js:
javascript
import React from "react";  // Simple rendering with divclass App extends React.Component {  render() {    return (      // Extraneous div element      <div>        <h2>Hello</h2>          <p>How you doin'?</p>      </div>    );  }}  export default App;
Output:
Reason to use Fragments: As we saw in the above code when we are trying to render more than one root element we have to put the entire content inside the ‘div’ tag which is not loved by many developers. So in React 16.2 version, Fragments were introduced, and we use them instead of the extraneous ‘div’ tag. 
Syntax:
<React.Fragment>  
      <h2>Child-1</h2>   
      <p> Child-2</p>   
</React.Fragment>  
Example: Open App.js and replace the code with the below code.
javascript
import React from "react";  // Simple rendering with fragment syntaxclass App extends React.Component {  render() {    return (      <React.Fragment>        <h2>Hello</h2>          <p>How you doin'?</p>      </React.Fragment>    );  }}  export default App;
Output:
Shorthand Fragment: The output of the first code and the code above is the same but the main reason for using is that it is a tiny bit faster when compared to the one with the ‘div’ tag inside it, as we didn’t create any DOM node. Also, it takes less memory. Another shorthand also exists for the above method in which we make use of ‘<>’ and ‘</>’ instead of the ‘React.Fragment’. 
Note: The shorthand syntax does not accept key attributes in that case you have to use the <React.Fragments> tag.Syntax:
<>  
      <h2>Child-1</h2>   
      <p> Child-2</p>   
</> 
Example: Open App.js and replace the code with the below code.
javascript
import React from "react";  // Simple rendering with short syntaxclass App extends React.Component {  render() {    return (      <>        <h2>Hello</h2>          <p>How you doin'?</p>      </>    );  }}  export default App;
Output:
shubhamyadav4
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
Axios in React: A Guide for Beginners
ReactJS setState()
How to pass data from one component to other component in ReactJS ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?