code-rag-bench/online-tutorials huggingface dataset:
Early binding and Late binding in C++ - GeeksforGeeks

05 Feb, 2018
Binding refers to the process of converting identifiers (such as variable and performance names) into addresses. Binding is done for each variable and functions. For functions, it means that matching the call with the right function definition by the compiler. It takes place either at compile time or at runtime.
Early Binding (compile-time time polymorphism) As the name indicates, compiler (or linker) directly associate an address to the function call. It replaces the call with a machine language instruction that tells the mainframe to leap to the address of the function.
By default early binding happens in C++. Late binding (discussed below) is achieved with the help of virtual keyword)
// CPP Program to illustrate early binding.// Any normal function call (without virtual)// is binded early. Here we have taken base// and derived class example so that readers// can easily compare and see difference in// outputs.#include<iostream>using namespace std;    class Base{public:    void show() { cout<<" In Base \n"; }};    class Derived: public Base{public:    void show() { cout<<"In Derived \n"; }};    int main(void){    Base *bp = new Derived;      // The function call decided at     // compile time (compiler sees type    // of pointer and calls base class    // function.    bp->show();        return 0;}
Output:
In Base
Late Binding : (Run time polymorphism) In this, the compiler adds code that identifies the kind of object at runtime then matches the call with the right function definition (Refer this for details). This can be achieved by declaring a virtual function.
// CPP Program to illustrate late binding#include<iostream>using namespace std;    class Base{public:    virtual void show() { cout<<" In Base \n"; }};    class Derived: public Base{public:    void show() { cout<<"In Derived \n"; }};    int main(void){    Base *bp = new Derived;    bp->show();  // RUN-TIME POLYMORPHISM    return 0;}
Output:
In Derived
cpp-inheritance
cpp-virtual
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Operator Overloading in C++
Sorting a vector in C++
Polymorphism in C++
Friend class and function in C++
List in C++ Standard Template Library (STL)
Pair in C++ Standard Template Library (STL)
Convert string to char array in C++
new and delete operators in C++ for dynamic memory
Destructors in C++
Queue in C++ Standard Template Library (STL)
Python dictionary str() Method

Python dictionary  method str() produces a printable string representation of a dictionary.
Following is the syntax for str() method −
str(dict)

dict − This is the dictionary.
dict − This is the dictionary.
This method returns string representation.
The following example shows the usage of str() method.
#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7};
print "Equivalent String : %s" % str (dict)
When we run above program, it produces following result −
Equivalent String : {'Age': 7, 'Name': 'Zara'}


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Explain the pointers to unions in C language

A union is a memory location that is shared by several variables of different data types.
The syntax for the pointers to unions in C programming is as follows −
union uniontag{
   datatype member 1;
   datatype member 2;
   ----
   ----
   datatype member n;
};
The following example shows the usage of union of structure.
union sample{
   int a;
   float b;
   char c;
};
Following is the declaration for union variable. It is of three types as follows −
union sample{
   int a;
   float b;
   char c;
}s;
union{
   int a;
   float b;
   char c;
}s;
union sample{
   int a;
   float b;
   char c;
};
union sample s;
When union is declared, the compiler automatically creates largest size variable type to hold variables in the union.
When union is declared, the compiler automatically creates largest size variable type to hold variables in the union.
At any time only one variable can be referred.
At any time only one variable can be referred.
Same syntax of structure is used to access a union member.
Same syntax of structure is used to access a union member.
The dot operator is for accessing members.
The dot operator is for accessing members.
The arrow operator ( ->) is used for accessing the members using pointer.
The arrow operator ( ->) is used for accessing the members using pointer.
We have pointers to unions and can access members using the arrow operator (->) just like structures.
The following program shows the usage of pointers to union in C programming −
 Live Demo
#include <stdio.h>
union pointer {
   int num;
   char a;
};
int main(){
   union pointer p1;
   p1.num = 75;
   // p2 is a pointer to union p1
   union pointer* p2 = &p1;
   // Accessing union members using pointer
   printf("%d %c", p2->num, p2->a);
   return 0;
}
When the above program is executed, it produces the following result −
75 K
Consider the same example with different input.
 Live Demo
#include <stdio.h>
union pointer {
   int num;
   char a;
};
int main(){
   union pointer p1;
   p1.num = 90;
   // p2 is a pointer to union p1
   union pointer* p2 = &p1;
   // Accessing union members using pointer
   printf("%d %c", p2->num, p2->a);
   return 0;
}
When the above program is executed, it produces the following result −
90 Z
Program for Celsius To Fahrenheit conversion in C++

Given with temperature ‘n’ in Celsius the challenge is to convert the given temperature to Fahrenheit and display it.
Input 1-: 100.00
   Output -: 212.00
Input 2-: -40
   Output-: -40
For converting the temperature from Celsius to Fahrenheit there is a formula which is given below
T(°F) = T(°C) × 9/5 + 32
Where, T(°C) is temperature in Celsius and T(°F) is temperature in Fahrenheit
Input temperature in a float variable let’s say Celsius
Apply the formula to convert the temperature into Fahrenheit
Print Fahrenheit
Start
Step 1 -> Declare a function to convert Celsius to Fahrenheit
   void cal(float cel)
      use formula float fahr = (cel * 9 / 5) + 32
      print cel fahr
Step 2 -> In main()
   Declare variable as float Celsius
   Call function cal(Celsius)
Stop
 Live Demo
#include <stdio.h>
//convert Celsius to fahrenheit
void cal(float cel){
   float fahr = (cel * 9 / 5) + 32;
   printf("%.2f Celsius = %.2f Fahrenheit", cel, fahr);
}
int main(){
   float Celsius=100.00;
   cal(Celsius);
   return 0;
}
100.00 Celsius = 212.00 Fahrenheit
 Live Demo
#include <bits/stdc++.h>
using namespace std;
float cel(float n){
   return ((n * 9.0 / 5.0) + 32.0);
}
int main(){
   float n = 20.0;
   cout << cel(n);
   return 0;
}
68
MomentJS - Days in Month

This method will give the numbers of days in the current month.
moment().daysInMonth();

var a = moment().daysInMonth();
Let us check the days in a month for a given date using this method. Use the following code for this purpose −
var a = moment([2016, 1]).daysInMonth();
For February in 2016, it displays days as 29.
 Print
 Add Notes
 Bookmark this page
How can we return a tuple from a Python function?

We can return a tuple from a python function in many ways. For the given tuple, we define a  function as shown below.
def foo():
    str = "tutorialspoint"
    x   = 30
    return (str, x);            
print foo()
('tutorialspoint', 30)
3Sum Smaller in C++

Suppose we have an array of n integers called nums and we also have a target, we have to find the number of index triplets (i, j, k) here i, j, k all are in range 0 to n - 1 and that satisfy the condition nums[i] + nums[j] + nums[k] < target.
So, if the input is like nums = [-2,0,1,3], and target = 2, then the output will be 2, as there are two triplets which sums are less than 2: [-2,0,1] and [-2,0,3].
To solve this, we will follow these steps −
ret := 0
ret := 0
sort the array a
sort the array a
n := size of a
n := size of a
for initialize i := 0, when i < n - 2, update (increase i by 1), do −left := i + 1, right := n - 1while left < right, do −sum := a[i] + a[left] + a[right]if sum < t, then −ret := ret + right - left(increase left by 1)Otherwise(decrease right by 1)
for initialize i := 0, when i < n - 2, update (increase i by 1), do −
left := i + 1, right := n - 1
left := i + 1, right := n - 1
while left < right, do −sum := a[i] + a[left] + a[right]if sum < t, then −ret := ret + right - left(increase left by 1)Otherwise(decrease right by 1)
while left < right, do −
sum := a[i] + a[left] + a[right]
sum := a[i] + a[left] + a[right]
if sum < t, then −ret := ret + right - left(increase left by 1)
if sum < t, then −
ret := ret + right - left
ret := ret + right - left
(increase left by 1)
(increase left by 1)
Otherwise(decrease right by 1)
Otherwise
(decrease right by 1)
(decrease right by 1)
return ret
return ret
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   int threeSumSmaller(vector<int<& a, int t) {
      int ret = 0;
      sort(a.begin(), a.end());
      int n = a.size();
      for (int i = 0; i < n - 2; i++) {
         int left = i + 1;
         int right = n - 1;
         while (left < right) {
            int sum = a[i] + a[left] + a[right];
            if (sum < t) {
               ret += right - left;
               left++;
            }
            else
               right--;
         }
      }
      return ret;
   }
};
main(){
   Solution ob;
   vector<int< v = {-2,0,1,3};
   cout << (ob.threeSumSmaller(v,2));
}
[-2,0,1,3] 2
2
System.exit() in Java

10 Jul, 2016
The java.lang.System.exit() method exits current program by terminating running Java virtual machine. This method takes a status code. A non-zero value of status code is generally used to indicate abnormal termination. This is similar exit in C/C++.
Following is the declaration for java.lang.System.exit() method:
public static void exit(int status)
exit(0) : Generally used to indicate successful termination.exit(1) or exit(-1) or any other non-zero value – Generally indicates unsuccessful termination.
Note : This method does not return any value.
The following example shows the usage of java.lang.System.exit() method.
// A Java program to demonstrate working of exit()import java.util.*;import java.lang.*;  class GfG{    public static void main(String[] args)    {        int arr[] = {1, 2, 3, 4, 5, 6, 7, 8};          for (int i = 0; i < arr.length; i++)        {            if (arr[i] >= 5)            {                System.out.println("exit...");                  // Terminate JVM                System.exit(0);            }            else                System.out.println("arr["+i+"] = " +                                  arr[i]);        }        System.out.println("End of Program");    }}
Output:
arr[0] = 1
arr[1] = 2
arr[2] = 3
arr[3] = 4
exit...

Reference :https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html
This article is contributed by Amit Khandelwal .If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Program to Get the Size of a Directory

27 Apr, 2021
The size of files in Java can be obtained using the File class. The in-built function of ‘fileName.length()’ is used to find size of file in Bytes. The directory may contain ‘N’ number of files, for calculating the size of the directory summation of the size of all the files is required.
length() Method:
length() method in the object of the file class is returning the file size in long(datatype) format. The file size is in a unit of Byte.
Return Type: long
Syntax:
java.io.File file = new java.io.File("file_name.txt");
file.length();
Working:
If the file exists then the function return the size of the fileElse the function returns null.
If the file exists then the function return the size of the file
Else the function returns null.
However, the size of the file can be display in Mega, Kilo units using unit conversion.
Java
// Java program to Get the size of a directory import java.io.File; class GFG {    private static long getFolderSize(File folder)    {        long length = 0;               // listFiles() is used to list the        // contents of the given folder        File[] files = folder.listFiles();         int count = files.length;         // loop for traversing the directory        for (int i = 0; i < count; i++) {            if (files[i].isFile()) {                length += files[i].length();            }            else {                length += getFolderSize(files[i]);            }        }        return length;    }     // Driver Code    public static void main(String[] args)    {        // Creating an instances of file class        File file1 = new File("/home/mayur/Downloads");         long size = getFolderSize(file1);        // Size of folder in Bytes        System.out.println("Size of " + file1 + " is "                           + size + " B");        // Size of folder in Kilobytes        System.out.println("Size of " + file1 + " is "                           + (double)size / 1024 + " KB");        // Size of folder in Megabytes        System.out.println("Size of " + file1 + " is "                           + (double)size / (1024 * 1024)                           + " MB");    }}
sweetyty
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Introduction to Java
Exceptions in Java
Java Programming Examples
Java Programming Examples
Implementing a Linked List in Java using Class
Program to print ASCII Value of a character
Traverse Through a HashMap in Java
Convert Double to Integer in Java
SQL Query to Filter a Table using Another Table

28 Oct, 2021
In this article, we will see, how to filter a table using another table. We can perform the function by using a subquery in place of the condition in WHERE Clause. A query inside another query is called subquery. It can also be called a nested query. One SQL code can have one or more than one nested query.
Syntax:
SELECT * FROM table_name WHERE
column_name=( SELECT column_name FROM table_name);
Query written after the WHERE clause is the subquery in above syntax.
Now, for the demonstration follow the below steps:
Step 1: Create a database
we can use the following command to create a database called geeks.
Query:
CREATE DATABASE geeks;
Step 2: Use database
Use the below SQL statement to switch the database context to geeks:
Query:
USE geeks;
Step 3: Table definition
We have two tables named ‘demo_table1’ and ‘demo_table2’ in our geek’s database.
Query(demo_table1):
CREATE TABLE demo_table1(
NAME VARCHAR(20),
AGE int,
CITY VARCHAR(10),
INCOME int);
Query(demo_table2):
CREATE TABLE demo_table2(
NAME VARCHAR(20),
AGE int,
INCOME int);
Step 4: Insert data into a table
Query (demo_table1):
INSERT INTO demo_table1 VALUES
('Romy',23,'Delhi',400000),
('Pushkar',23,'Delhi',700000),
('Nikhil',24,'Punjab',350000),
('Rinkle',23,'Punjab',600000),
('Samiksha',23,'Banglore',800000),
('Ashtha',24,'Banglore',300000),
('Satish',30,'Patna',450000),
('Girish',30,'Patna',5500000),
('Ram', 20 , 'Patna',650000),
('Raj', 12, 'Delhi',380000);
Query(demo_table2):
INSERT INTO demo_table2 VALUES
('Fanny',25,600000 ),
('Prem', 30,450000),
('Preeti',21,250000 ),
('Samita',32,440000),
('Ozymandias',34,650000);
Step 5: View the content of the table.
Execute the below query to see the content of the table.
Query:
SELECT * FROM demo_table1;
Output:
Query:
SELECT * FROM demo_table2;
Output:
Step 6: Filter table using another table
For the demonstration, we will filter demo_table1 data whose INCOME is greater than maximum INCOME in semo_table2.
 To get the maximum salary from demo_table2:
Query:
SELECT MAX(INCOME) FROM demo_table2;
Above query used will be used as subquery to filter the demo_table1.
Final Query:
SELECT * FROM demo_table WHERE INCOME > (SELECT MAX(INCOME) FROM demo_table2);
Output:
From image you can see that data from demo_table1 is filtered out having INCOME more than the 650000 (maximum income value in demo_table2 ).
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Sub queries in From Clause
Window functions in SQL
What is Temporary Table in SQL?
SQL using Python
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
RANK() Function in SQL Server
SQL Query to Compare Two Dates
SQL Query to Convert Rows to Columns in SQL Server
Create Primary Key on an existing table in PostgreSQL?

Although quite infrequent, you may come across situations wherein you need to define the primary key on an existing table. This can be achieved using the ALTER TABLE statement.
The syntax is −
ALTER TABLE table_name ADD PRIMARY KEY (column_name1,
column_name2,...., columns_nameN)
As can be seen from the above syntax, you can define PRIMARY KEY on multiple columns. When you have defined the PRIMARY KEY on multiple columns, the condition is that the column pairs should have unique and non-null values. Thus, if the PRIMARY KEY is defined on (column1, column2), the values (value1, value2), (value3, value2), and (value1,value4) are allowed. Even though column1 has value1 repeated and column2 has value2 repeated, the pair of columns have unique values when considered together.
Let us consider an example to understand this. Let us create a table marks and populate it as follows −
CREATE TABLE marks(
   name VARCHAR,
   roll_no INTEGER,
   marks_obtained INTEGER,
   perc_marks DOUBLE PRECISION,
   max_marks INTEGER,
   date_of_entry DATE
);
INSERT INTO marks(name, roll_no, marks_obtained, perc_marks,
max_marks, date_of_entry)
VALUES ('Yash', 26, 42, 42.0, 100, current_date),
('Isha', 56, 175, 87.5, 200, current_date),
('Yash', 35, 12, 24, 50, current_date);
If you query the table (SELECT * from marks2), you will see output similar to the following −
This table has no primary key set so far. Now, let us try to define the name column as the primary key.
ALTER TABLE marks ADD PRIMARY KEY (name)
PostgreSQL will return an error −
ERROR: could not create unique index "marks_pkey" DETAIL: Key (name)=(Yash) is
duplicated. SQL state: 23505
This is as expected. PRIMARY KEY can’t have duplicate values. Now, let us try to set the PRIMARY KEY on the (name, roll_no) pair.
ALTER TABLE marks ADD PRIMARY KEY (name, roll_no)
This will work because no combination of (name, roll_no) is duplicate.
How can we create a custom exception in Java?

Sometimes it is required to develop meaningful exceptions based on the application requirements. We can create our own exceptions by extending Exception class in Java
User-defined exceptions in Java are also known as Custom Exceptions.
CustomException class is the custom exception class this class is extending Exception class.
Create one local variable message to store the exception message locally in the class object.
We are passing a string argument to the constructor of the custom exception object. The constructor set the argument string to the private string message.
toString() method is used to print out the exception message.
We are simply throwing a CustomException using one try-catch block in the main method and observe how the string is passed while creating a custom exception. Inside the catch block, we are printing out the message.
class CustomException extends Exception {
   String message;
   CustomException(String str) {
      message = str;
   }
   public String toString() {
      return ("Custom Exception Occurred : " + message);
   }
}
public class MainException {
   public static void main(String args[]) {
      try {
         throw new CustomException("This is a custom message");
      } catch(CustomException e) {
         System.out.println(e);
      }
   }
}
Custom Exception Occurred : This is a custom message
C# | UInt16 Struct - GeeksforGeeks

01 May, 2019
In C#, UInt16 struct is used to represent 16-bit unsigned integers(also termed as ushort data type) starting from range 0 to 65535. It provides different types of method to perform various actions like to compare instances of this type, convert the value of an instance to its string representation, convert the string representation of a number to an instance of this type, etc. This struct is defined under System namespace. UInt16 struct inherits the ValueType class which inherits the Object class.
Example:
// C# program to illustrate the // fields of UInt16 structusing System;  class GFG {      // Main Method    static public void Main()    {          // Unsigned 16-bit integer        ushort val = 295;          // Checking the unsigned integer        if (val.Equals(UInt16.MinValue))         {            Console.WriteLine("Equal to MinValue..!");        }          else if (val.Equals(UInt16.MaxValue))         {            Console.WriteLine("Equal to MaxValue");        }          else         {            Console.WriteLine("Not equal");        }    }}
Not equal

Example:
// C# program to illustrate how to get the hash // code of the 16-bit Unsigned integerusing System;  class GFG {      // Main Method    static public void Main()    {          // UInt16 variable        ulong myval = 545;          // Get the hash code        // Using GetHashCode Method        int res = myval.GetHashCode();          Console.WriteLine("The hash code of myval is: {0}", res);    }}
The hash code of myval is: 545

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.uint16?view=netframework-4.8
CSharp-UInt16-Struct
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Delegates
C# | Abstract Classes
Extension Method in C#
Difference between Ref and Out keywords in C#
C# | Replace() Method
C# | Class and Object
C# | Constructors
C# | String.IndexOf( ) Method | Set - 1
Introduction to .NET Framework
C# | Data Types
Ext.js - Fonts

Ext.js provides the facility to use different font packages. Font packages are used to add different classes for icons available in the package.
Font-Awesome
Font-Pictos
ExtJS new theme, Triton, has an inbuilt font family font-awesome included in the framework itself, hence we do not need any explicit requirement for the font-awesome stylesheet.
Following is an example of using Font-Awesome classes in the Triton theme.
Font-Awesome with Triton theme
When we are using any other theme apart from Triton, we need or require to add a stylesheet for font-awesome explicitly.
Following is an example of using Font-Awesome classes without the Triton theme.
Font-Awesome with normal theme(Any theme other then Triton theme)
Font-pictos is not included in the framework for ExtJS, hence we have to require the same. Only licenced users of Sencha will have the benefit to use font-pictos.
Step 1 − Require font-pictos class using the following command.
"requires": ["font-pictos"]

Step 2 − Now add pictos classes as −
iconCls: 'pictos pictos-home'

 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: HTML image
Reverse a string using the pointer in C++

This article reverse a string using the pointer in C++ coding, First, it calculates the length of a pointer to string then run a for loop in decrement order to display the reverse string as follows;
 Live Demo
#include <string.h>
#include <iostream>
using namespace std;
int main(){
   char *str="ajaykumar";
   cout<<"original string::"<<str;
   cout<<endl<<"String after reverse::";
   for(int i=(strlen(str)-1);i>=0;i--){
      cout<<str[i];
   }
   return 0;
}
This above program prints the to be supplied string “ajaykumar” in reverse order as follows.
Original string::ajaykumar
String after reverse::ramukyaja
Google Charts - Basic Line Chart

Following is an example of a basic line chart. We've already seen the configuration used to draw this chart in Google Charts Configuration Syntax chapter. So, let's see the complete example.
googlecharts_line_basic.htm
<html>
   <head>
      <title>Google Charts Tutorial</title>
      <script type = "text/javascript" src = "https://www.gstatic.com/charts/loader.js">
      </script>
      <script type = "text/javascript">
         google.charts.load('current', {packages: ['corechart','line']});  
      </script>
   </head>
   
   <body>
      <div id = "container" style = "width: 550px; height: 400px; margin: 0 auto">
      </div>
      <script language = "JavaScript">
         function drawChart() {
            // Define the chart to be drawn.
            var data = new google.visualization.DataTable();
            data.addColumn('string', 'Month');
            data.addColumn('number', 'Tokyo');
            data.addColumn('number', 'New York');
            data.addColumn('number', 'Berlin');
            data.addColumn('number', 'London');
            data.addRows([
               ['Jan',  7.0, -0.2, -0.9, 3.9],
               ['Feb',  6.9, 0.8, 0.6, 4.2],
               ['Mar',  9.5,  5.7, 3.5, 5.7],
               ['Apr',  14.5, 11.3, 8.4, 8.5],
               ['May',  18.2, 17.0, 13.5, 11.9],
               ['Jun',  21.5, 22.0, 17.0, 15.2],
               
               ['Jul',  25.2, 24.8, 18.6, 17.0],
               ['Aug',  26.5, 24.1, 17.9, 16.6],
               ['Sep',  23.3, 20.1, 14.3, 14.2],
               ['Oct',  18.3, 14.1, 9.0, 10.3],
               ['Nov',  13.9,  8.6, 3.9, 6.6],
               ['Dec',  9.6,  2.5,  1.0, 4.8]
            ]);
               
            // Set chart options
            var options = {'title' : 'Average Temperatures of Cities',
               hAxis: {
                  title: 'Month'
               },
               vAxis: {
                  title: 'Temperature'
               },   
               'width':550,
               'height':400	  
            };

            // Instantiate and draw the chart.
            var chart = new google.visualization.LineChart(document.getElementById('container'));
            chart.draw(data, options);
         }
         google.charts.setOnLoadCallback(drawChart);
      </script>
   </body>
</html>
Verify the result.
 Print
 Add Notes
 Bookmark this page
Calculate Arithmetic mean in R Programming - mean() Function - GeeksforGeeks

05 Jun, 2020
mean() function in R Language is used to calculate the arithmetic mean of the elements of the numeric vector passed to it as argument.
Syntax: mean(x, na.rm)
Parameters:x: Numeric Vectorna.rm: Boolean value to ignore NA value
Example 1:
# R program to calculate# Arithmetic mean of a vector  # Creating a numeric vectorx1 <- c(1, 2, 3, 4, 5, 6)x2 <-c(1.2, 2.3, 3.4, 4.5)x3 <- c(-1, -2, -3, -4, -5, -6)  # Calling mean() functionmean(x1)mean(x2)mean(x3)
Output:
[1] 3.5
[1] 2.85
[1] -3.5

Example 2:
# R program to calculate# Arithmetic mean of a vector  # Creating a numeric vectorx1 <- c(1, 2, 3, NA, 5, NA, NA)  # Calling mean() function# including NA valuesmean(x1, na.rm = FALSE)  # Calling mean() function# excluding NA valuesmean(x1, na.rm = TRUE)
Output:
[1] NA
[1] 2.75

R Math-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Replace specific values in column in R DataFrame ?
How to change Row Names of DataFrame in R ?
Filter data by multiple conditions in R using Dplyr
Change Color of Bars in Barchart using ggplot2 in R
Loops in R (for, while, repeat)
Printing Output of an R Program
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
K-Means Clustering in R Programming
Powershell - Get-ChildItem Cmdlet

Get-ChildItem cmdlet can be used to get the items or child items in one or more specific locations.
In these examples, we're see the Get-ChildItem cmdlet in action.
In this example, first we've a file test.txt in D:\temp\test with content "Welcome to TutorialsPoint.Com" and test1.txt with content "Hello World!" and "Welcome to TutorialsPoint.Com" in two lines.
Get the file details in a variable.
$A = Get-ChildItem D:\temp\test\*.txt
Get the file details using Format-Wide cmdlet.
Format-Wide -InputObject $A
You can see following output in PowerShell console.
    Directory: D:\temp\test
test.txt                                         test1.txt           

Get the names of the items in current directory.
Type the following command in PowerShell ISE Console
Get-ChildItem -Name
You can see following output in PowerShell console consider being in D:\temp\Test directory.
test.csv
test.txt
test.xml
test1.txt


    15 Lectures 
     3.5 hours 

 Fabrice Chrzanowski

    35 Lectures 
     2.5 hours 

 Vijay Saini

    145 Lectures 
     12.5 hours 

 Fettah Ben
 Print
 Add Notes
 Bookmark this page
NavigableString class – Python Beautifulsoup

25 Oct, 2020
NavigableString class is provided by Beautiful Soup which is a web scraping framework for Python. Web scraping is the process of extracting data from the website using automated tools to make the process faster. A string corresponds to a bit of text within a tag. Beautiful Soup uses the NavigableString class to contain these bits of text.
Syntax: 
<tag> String here </tag>

Below given examples explain the concept of NavigableString class in Beautiful Soup. Example 1: In this example, we are going to see the type of a string.
Python3
# Import Beautiful Soupfrom bs4 import BeautifulSoup  # Initialize the object with a HTML pagesoup = BeautifulSoup('''    <html>        <h2> Heading 1 </h2>        <h1> Heading 2 </h1>    </html>    ''', "lxml")  # Get the whole h2 tagtag = soup.h2  # Get the string inside the tagstring = tag.string  # Print the typeprint(type(string))
Output: 
<class 'bs4.element.NavigableString'>

Example 2: In this example we are going to convert the NavigableString to a Unicode string.
Python3
# Import Beautiful Soupfrom bs4 import BeautifulSoup  # Initialize the object with a HTML pagesoup = BeautifulSoup('''    <html>        <h2> Heading 1 </h2>        <h1> Heading 2 </h1>    </html>    ''', "lxml")  # Get the whole h2 tagtag = soup.h2  # Get the string inside the tag and convert # it into stringstring = str(tag.string)  # Print the typeprint(type(string))
Output: 
<type 'str'>

Web-scraping
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – tensorflow.eye()

10 Jul, 2020
TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. 
tensorflow.eye() is used to generate identity matrix.
Syntax: tensorflow.eye( num_rows, num_columns, batch_shape, dtype, name)
Parameters:
num_rows: It is int32 scalar Tensor which defines the number of rows to be present in resulting matrix.
num_columns(optional): It is int32 scalar Tensor which defines the number of columns to be present in resulting matrix. It’s default value is num_rows.
batch_shape(optional): It is list or tuple of Python integers or a 1-D int32 Tensor. If it’s not none  the returned Tensor will have leading batch dimensions of this shape. 
dtype(optional): It defines the dtype of returned tensor. Default value is float32.
name(optional): It defines the name for the operation.
Return : It returns a Tensor of shape batch_shape + [num_rows, num_columns].
Example 1:
Python3
# Importing the libraryimport tensorflow as tf  # Initializing the inputnum_rows = 5  # Printing the inputprint('num_rows:', num_rows)  # Calculating resultres = tf.eye(num_rows)  # Printing the resultprint('res: ', res)
Output:

num_rows: 5
res:  tf.Tensor(
[[1. 0. 0. 0. 0.]
 [0. 1. 0. 0. 0.]
 [0. 0. 1. 0. 0.]
 [0. 0. 0. 1. 0.]
 [0. 0. 0. 0. 1.]], shape=(5, 5), dtype=float32)

Example 2:
Python3
# Importing the libraryimport tensorflow as tf  # Initializing the inputnum_rows = 5num_columns = 6batch_shape = [3]  # Printing the inputprint('num_rows:', num_rows)print('num_columns:', num_columns)print('batch_shape:', batch_shape)  # Calculating resultres = tf.eye(num_rows, num_columns, batch_shape)  # Printing the resultprint('res: ', res)
Output:

num_rows: 5
num_columns: 6
batch_shape: [3]
res:  tf.Tensor(
[[[1. 0. 0. 0. 0. 0.]
  [0. 1. 0. 0. 0. 0.]
  [0. 0. 1. 0. 0. 0.]
  [0. 0. 0. 1. 0. 0.]
  [0. 0. 0. 0. 1. 0.]]

 [[1. 0. 0. 0. 0. 0.]
  [0. 1. 0. 0. 0. 0.]
  [0. 0. 1. 0. 0. 0.]
  [0. 0. 0. 1. 0. 0.]
  [0. 0. 0. 0. 1. 0.]]

 [[1. 0. 0. 0. 0. 0.]
  [0. 1. 0. 0. 0. 0.]
  [0. 0. 1. 0. 0. 0.]
  [0. 0. 0. 1. 0. 0.]
  [0. 0. 0. 0. 1. 0.]]], shape=(3, 5, 6), dtype=float32)


Python-Tensorflow
Tensorflow
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
numpy.ones_like() in Python

22 Oct, 2020
The numpy.one_like() function returns an array of given shape and type as a given array, with ones.
Syntax: numpy.ones_like(array, dtype = None, order = 'K', subok = True)
Parameters :
array : array_like input
subok  : [optional, boolean]If true, then newly created array will be sub-class of array; 
                 otherwise, a base-class array
order  : C_contiguous or F_contiguous
         C-contiguous order in memory(last index varies the fastest)
         C order means that operating row-wise on the array will be slightly quicker
         FORTRAN-contiguous order in memory (first index varies the fastest).
         F order means that column-wise operations will be faster. 
dtype  : [optional, float(byDefault)] Data type of returned array.  

Returns :
ndarray of ones having given shape, order and datatype.
# Python Programming illustrating# numpy.ones_like method  import numpy as geek  array = geek.arange(10).reshape(5, 2)print("Original array : \n", array)    b = geek.ones_like(array, float)print("\nMatrix b : \n", b)  array = geek.arange(8)c = geek.ones_like(array)print("\nMatrix c : \n", c)
Output:
Original array : 
 [[0 1]
 [2 3]
 [4 5]
 [6 7]
 [8 9]]

Matrix b : 
 [[ 1.  1.]
 [ 1.  1.]
 [ 1.  1.]
 [ 1.  1.]
 [ 1.  1.]]

Matrix c : 
 [1 1 1 1 1 1 1 1]

References :https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.ones_like.htmlNote :Also, these codes won’t run on online-ID. Please run them on your systems to explore the working
This article is contributed by Mohit Gupta_OMG . If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
nidhi_biet
10frazier
Python numpy-arrayCreation
Python-numpy
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
Python OOPs Concepts
How to get character array from string in JavaScript?

20 Jul, 2021
The string in JavaScript can be converted into a character array by using the split() and Array.from() functions.
Using String split() Function: The str.split() function is used to split the given string into array of strings by separating it into substrings using a specified separator provided in the argument.Syntax:
str.split(separator, limit)
Example:
<!DOCTYPE html><html>  <head>    <title>        String to a character array    </title></head>  <body style="text-align:center;">      <h1>GeeksforGeeks</h1>              <p id = "one" >GeeksforGeeks: A computer science portal</p>          <input type="button" value="Click Here!" onclick="myGeeks()">          <script>        function myGeeks() {            var str = document.getElementById("one").innerHTML;            document.getElementById("one").innerHTML = str.split("");        }    </script></body>  </html>                    
Output:Before Clicking the button:After Clicking the button:
Using Array.from() Function: The Array.from() function is an inbuilt function in JavaScript which creates a new array instance from a given array. In case of a string, every alphabet of the string is converted to an element of the new array instance and in case of integer values, new array instance simple take the elements of the given array.Syntax:
Array.from(str)
Example:
<!DOCTYPE html><html>  <head>    <title>        String to a character array    </title></head>  <body style="text-align:center;">      <h1>GeeksforGeeks</h1>              <p id = "one" >GeeksforGeeks: A computer science portal</p>          <input type="button" value="Click Here!" onclick="myGeeks()">          <script>        function myGeeks() {            var str = document.getElementById("one").innerHTML;            document.getElementById("one").innerHTML = Array.from(str);        }    </script></body>  </html>                    
Output:Before Clicking the button:After Clicking the button:
JavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples.
javascript-array
javascript-string
Picked
JavaScript
Web Technologies
Web technologies Questions
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
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to append HTML code to a div using JavaScript ?
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 ?
p5.js Keyboard | keyIsPressed

15 Apr, 2019
The keyIsPressed variable in p5.js is true if any key is pressed and false if no keys are pressed.
Syntax:
keyIsPressed

Below program illustrates the keyIsPressed variable in p5.js:Example-1:
let valueX;let valueY;  function setup() {    // Create Canvas of size 500*500    createCanvas(1000, 500);}  function draw() {        // set background color    background(200);    fill('green');        // set text and text size    textSize(25);        text('Press Key to change the figure '+         'from Circle To Keyboard', 30, 30);        // use of keyIsPressed Variable    if (keyIsPressed) {        // draw ellipse          ellipse(mouseX, mouseY, 115, 115);        fill('red');        text("Key Is Pressed", 100, 300);    } else {        rect(mouseX / 2, mouseY / 2, 300, 200);    }  }
Output:Before:After:
Example-2:
let valueX;let valueY;  function setup() {        // Create Canvas of size 500*500    createCanvas(500, 500);}  function draw() {        // set background color    background(200);        fill('green');        // set text and text size    textSize(25);    text('Click to flip the the figure', 30, 30);        // use of KeyIsPressed    if (keyIsPressed) {        fill(valueX, 255 - valueY, 255 - valueX);                // draw rectangle         rect(mouseX, mouseY, 115, 115);        fill(valueY, 255 - valueX, 255 - valueX);          rect(mouseX, mouseY + 115, 115, 115);        fill(255 - valueY, 255 - valueX, 255 - valueY);    } else {        rect(mouseX - 115, mouseY, 115, 115);        fill(255 - valueY, 255 - valueY, 255 - valueY);          rect(mouseX - 115, mouseY + 115, 115, 115);    }}
Output:Before:After:Reference: https://p5js.org/reference/#/p5/keyIsPressed
JavaScript-p5.js
JavaScript
Web Technologies
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
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
How to append HTML code to a div using JavaScript ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
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 ?
How to install a Python Module?

The best and recommended way to install Python modules is to use pip, the Python package manager.
If you have Python 2 >=2.7.9 or Python 3 >=3.4 installed from python.org, you will already have pip and setuptools, but will need to upgrade to the latest version:
On Linux or macOS:
pip install -U pip setuptools
On Windows:
python -m pip install -U pip setuptools
If you’re using a Python install on Linux that’s managed by the system package manager (e.g "yum", "apt-get" etc...), and you want to use the system package manager to install or upgrade pip, then see: https://packaging.python.org/guides/installing-using-linux-tools/
Otherwise:
Download get-pip.py from https://bootstrap.pypa.io/get-pip.py. Run python get-pip.py. This will install or upgrade pip.
Now you can use pip to install python packages. For example, To install the latest version of "SomeProject":
$ pip install 'SomeProject'
To install a specific version:
$ pip install 'SomeProject==1.4'
To install greater than or equal to one version and less than another:
$ pip install 'SomeProject>=1,<2'
Java program to swap two numbers using XOR operator

Following is a program to swap two numbers using XOR operator.
public class ab31_SwapTwoNumberUsingXOR {
   public static void main(String args[]){
      int a,b;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter a value :");
      a = sc.nextInt();
      System.out.println("Enter b value :");
      b = sc.nextInt();
      a = a^b;
      b = a^b;
      a = a^b;
      System.out.println("Value of the variable a after swapping : "+a);
      System.out.println("Value of the variable b after swapping : "+b);
   }
}
Enter a value :
55
Enter b value :
64
Value of the variable a after swapping : 64
Value of the variable b after swapping : 55
Python EasyGUI – Enter Box

05 Sep, 2020
Enter Box : It is used to get the input from the user, input can be any keyboard input, it takes input in form of string. It displays the title, message to be displayed, place to enter a text and a pair of “Ok”, “Cancel” button which is used confirm the input. Also we can set some default text to the place where user enter text, below is how the enter box looks like
In order to do this we will use enterbox method
Syntax : enterbox(message, title, default_text)
Argument : It takes 3 arguments, first string i.e message/information to be displayed, second string i.e title of the window and third is string which is default text
Return : It returns the entered text and None if cancel is pressed
Example :In this we will create a enter box with default text, and will show the specific message on the screen according to the entered text, below is the implementation
# importing easygui modulefrom easygui import *  # message to be displayedtext = "Enter your Geek name !!"  # window titletitle = "Window Title GfG"  # default textd_text = "Enter here.."  # creating a enter boxoutput = enterbox(text, title, d_text)  # title for the message boxtitle = "Message Box"  # creating a messagemessage = "Enterted Name : " + str(output)  # creating a message boxmsg = msgbox(message, title)
Output :
Another Example :In this we will create a enter box, and will show the specific message on the screen according to the entered text, below is the implementation
# importing easygui modulefrom easygui import *  # message to be displayedtext = "Enter Something"  # window titletitle = "Window Title GfG"    # creating a enter boxoutput = enterbox(text, title)  # title for the message boxtitle = "Message Box"  # creating a messagemessage = "Enterted string : " + str(output)  # creating a message boxmsg = msgbox(message, title)
Output :
Python-EasyGUI
Python-gui
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Fix() and Format() Function in MS Access

02 Sep, 2020
1. Fix() Function :In MS Access, the fix() function returns the integer part of a number. In this function, a number will be pass as a parameter and it will return the integer part of that number.
Syntax :
Fix(number) 
Example-1 :
SELECT Fix(-75.43) AS FixNum;
Output –
Example-2 :
SELECT Fix(23.93) AS FixNum;
Output –
2. Format() function :In MS Access, the format function will return a number in a specified format. In this function, the value will be passed as the first parameter and the format will be pass as second parameter. And it will return the converted format.
Syntax :
Format(value, format) 
Example-1 :
SELECT Format(0.55, "Percent") 
AS FormattedPercentage;
Output –
Example-2 :
SELECT Format(0.0000000004500121424255, "Scientific") 
AS FormattedScientific;
Output –
DBMS-SQL
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to make sliders in Plotly?

01 Oct, 2020
A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library. 
In plotly, a slider is a Tkinter object with which a user can set the values by moving an indicator. A slider can be vertically and horizontally arranged. In plotly, the slider can be formed by using the Scale method(). 
Example 1:
Python3
import plotly.graph_objects as pximport plotly.express as goimport numpy as np  df = go.data.tips()  x = df['total_bill']y = df['day']  plot = px.Figure(data=[px.Scatter(    x=x,    y=y,    mode='lines',)])  plot.update_layout(    xaxis=dict(        rangeselector=dict(            buttons=list([                dict(count=1,                     step="day",                     stepmode="backward"),            ])        ),        rangeslider=dict(            visible=True        ),    ))  plot.show()
Output:
Example 2:
Python3
import plotly.express as px  df = px.data.tips()  fig = px.scatter(df, x="total_bill", y="tip",                  animation_frame="day",                 color="sex",)  fig["layout"].pop("updatemenus")fig.show()
Output: 
 
Python-Plotly
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function