code-rag-bench/online-tutorials huggingface dataset:
HTML | DOM Location hash Property

05 Jul, 2022
The Location Hash property in HTML is used to return the anchor part of a URL. It can also be used to set the anchor part of the URL. It returns the string which represents the anchor part of a URL including the hash ‘#’ sign.Syntax:  
It returns the hash property.  
location.hash
It is used to set the hash property.  
location.hash = anchorname
Property Value
anchorname: It contains a string value which specify the anchor part of an URL’S.
Return Value: It returns a string value which represents the anchor part of a URL. 
Below program illustrates the Location hash property in HTML:Example:  
html
<!DOCTYPE html><html> <head>    <title>DOM Location hash property</title>    <style>        h1 {            color: green;        }                 h2 {            font-family: Impact;        }                 body {            text-align: center;        }    </style></head> <body>    <h1>GeeksforGeeks</h1>    <h2>DOM Location hash Property</h2>      <p>      For setting the anchor part to      'newlocationhash', double click      the "Set Anchor" button:    </p>      <button ondblclick="mylocation()">      Set Anchor    </button>    <p id="hash"></p>      <script>        function mylocation() {            location.hash = "newlocationhash";            var h =                "The anchor part is now: " + location.hash;            document.getElementById("hash").innerHTML = h;        }    </script></body> </html>  
Output:  
After click on the button:  
Supported Browsers: The browsers supported by Location hash property are listed below:  
Google Chrome 1
Edge 12
Internet Explorer 3
Firefox 1
Opera 12.1
Safari 1
 
ManasChhabra2
geeksr3ap
HTML-DOM
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
C Sharp with Selenium - How to Switch one tab to another tab in Csharp Selenium?

We can switch one tab to another tab with Selenium webdriver in C#.
Sometimes on clicking a link or a button, we can have multiple tabs opened in the same browser.
By default, the webdriver can access only the parent tab. To access the second tab, we have to switch the driver focus with the help of the SwitchTo().Window() method. The window handle id of the tab where we want to switch to is passed as a parameter..
The method CurrentWindowHandle yields the window handle id of the tab which is in focus. The WindowHandles method returns all the window handle ids of the opened tabs in the browser.
Let us try to switch the tabs opened in browser as shown in below image −
driver.SwitchTo().Window(driver.WindowHandles[1]);
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System;
using OpenQA.Selenium;
namespace NUnitTestProject2{
   public class Tests{
      String url =" https://www.tutorialspoint.com/index.htm";
      IWebDriver driver;
      [SetUp]
      public void Setup(){
         //creating object of FirefoxDriver
         driver = new FirefoxDriver("");
      }
      [Test]
      public void Test2(){
         //implicit wait
         driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
         //URL launch
         driver.Navigate().GoToUrl(url);
         //identify element then click
         IWebElement l = driver.FindElement(By.XPath("//*[text()='Jobs']"));
         l.Click();
         //switch to second tab
         driver.SwitchTo().Window(driver.WindowHandles[1]);
         //get current window handle id
         Console.WriteLine
         ("Current window id: " + driver.CurrentWindowHandle);
         Console.WriteLine("Page title in second tab is: " + driver.Title);
         //close second tab
         driver.Close();
         //switch to first tab
         driver.SwitchTo().Window(driver.WindowHandles[0]);
         IWebElement m = driver.FindElement(By.TagName("h4"));
         Console.WriteLine("Element in first tab is: " + m.Text);
      }
      [TearDown]
      public void close_Browser(){
         driver.Quit();
      }
   }
}
DateTime.ToShortDateString() Method in C#

30 Jan, 2019
This method is used to convert the value of the current DateTime object to its equivalent short date string representation.
Syntax: public string ToShortDateString ();
Return Value: This method returns a string that contains the short date string representation of the current DateTime object.
Below programs illustrate the use of DateTime.ToShortDateString() Method:
Example 1:
// C# program to demonstrate the// DateTime.ToShortDateString()// Methodusing System;  class GFG {      // Main Method    public static void Main()    {        try {              // creating object of DateTime            DateTime date = new DateTime(2010, 1,                                    1, 4, 0, 15);              // getting ShortTime from DateTime            // using ToShortDateString() method;            string value = date.ToShortDateString();              // Display the ShortTime            Console.WriteLine("date is {0}", value);        }          catch (FormatException e)         {            Console.Write("Exception Thrown: ");            Console.Write("{0}", e.GetType(), e.Message);        }    }}
date is 01/01/2010

Example 2:
// C# program to demonstrate the// DateTime.ToShortDateString()// Methodusing System;  class GFG {      // Main Method    public static void Main()    {          // calling check() method        check(new DateTime(2010, 1, 3, 4, 0, 15));          check(new DateTime(2010, 1, 5, 4, 0, 15));          check(new DateTime(2010, 1, 5, 4, 0, 15));    }      public static void check(DateTime date)    {          // getting ShortTime from DateTime        // using ToShortDateString() method;        string value = date.ToShortDateString();          // Display the date        Console.WriteLine("date of {0} is "+                        "{1}", date, value);    }}
date of 01/03/2010 04:00:15 is 01/03/2010
date of 01/05/2010 04:00:15 is 01/05/2010
date of 01/05/2010 04:00:15 is 01/05/2010

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.toshortdatestring?view=netframework-4.7.2
CSharp DateTime Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Multiple inheritance using interfaces
Introduction to .NET Framework
C# | Delegates
Differences Between .NET Core and .NET Framework
C# | Data Types
C# | Constructors
C# | Class and Object
C# | Replace() Method
Extension Method in C#
Difference between Ref and Out keywords in C#
Python | Pandas isnull() and notnull()

08 Jun, 2022
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.While making a Data Frame from a csv file, many blank columns are imported as null value into the Data Frame which later creates problems while operating that data frame. Pandas isnull() and notnull() methods are used to check and manage NULL values in a data frame. 
 
Syntax: Pandas.isnull(“DataFrame Name”) or DataFrame.isnull()Parameters: Object to check null values forReturn Type: Dataframe of Boolean values which are True for NaN values  
To download the CSV file used, Click Here.Example #1: Using isnull() In the following example, Team column is checked for NULL values and a boolean series is returned by the isnull() method which stores True for ever NaN value and False for a Not null value.  
Python
# importing pandas packageimport pandas as pd # making data frame from csv filedata = pd.read_csv("employees.csv") # creating bool series True for NaN valuesbool_series = pd.isnull(data["Team"]) # filtering data# displaying data only with team = NaNdata[bool_series]
Output: As shown in output image, only the rows having Team=NULL are displayed.  
 
 
Syntax: Pandas.notnull(“DataFrame Name”) or DataFrame.notnull()Parameters: Object to check null values forReturn Type: Dataframe of Boolean values which are False for NaN values  
Example #1: Using notnull() In the following example, Gender column is checked for NULL values and a boolean series is returned by the notnull() method which stores True for ever NON-NULL value and False for a null value. 
Python
# importing pandas packageimport pandas as pd # making data frame from csv filedata = pd.read_csv("employees.csv") # creating bool series False for NaN valuesbool_series = pd.notnull(data["Gender"]) # displayed data only with team = NaNdata[bool_series]
Output: As shown in output image, only the rows having some value in Gender are displayed.  
 
swapnil159
user_ocpa
simmytarika5
Python pandas-dataFrame
Python pandas-dataFrame-methods
python-modules
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Remove duplicates from nested list

15 Apr, 2019
The task of removing duplicates many times in recent past, but sometimes when we deal with the complex data structure, in those cases we need different techniques to handle this type of problem. Let’s discuss certain ways in which this task can be achieved.
Method #1 : Using sorted() + set()This particular problem can be solved using the above functions. The idea here is to sort the sublist and then removing the like elements using the set operations which removes duplicates.
# Python3 code to demonstrate# removing duplicate sublist # using set() + sorted()  # initializing listtest_list = [[1, 0, -1], [-1, 0, 1], [-1, 0, 1],                           [1, 2, 3], [3, 4, 1]]  # printing original listprint("The original list : " + str(test_list))  # using set() + sorted()# removing duplicate sublistres = list(set(tuple(sorted(sub)) for sub in test_list))  # print resultprint("The list after duplicate removal : " + str(res))  
The original list : [[1, 0, -1], [-1, 0, 1], [-1, 0, 1], [1, 2, 3], [3, 4, 1]]
The list after duplicate removal : [(-1, 0, 1), (1, 3, 4), (1, 2, 3)]

 
Method #2 : Using set() + map() + sorted()The task performed by the list comprehension in the above method can be modified using the map function using lambda functions to extend the logic to each and every sublist.
# Python3 code to demonstrate# removing duplicate sublist # using set() + map() + sorted()  # initializing listtest_list = [[1, 0, -1], [-1, 0, 1], [-1, 0, 1],                           [1, 2, 3], [3, 4, 1]]  # printing original listprint("The original list : " + str(test_list))  # using set() + map() + sorted()# removing duplicate sublistres = list(set(map(lambda i: tuple(sorted(i)), test_list)))  # print resultprint("The list after duplicate removal : " + str(res))
The original list : [[1, 0, -1], [-1, 0, 1], [-1, 0, 1], [1, 2, 3], [3, 4, 1]]
The list after duplicate removal : [(-1, 0, 1), (1, 3, 4), (1, 2, 3)]

Python list-programs
Python
Python Programs
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()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Get the fully-qualified name of an inner class in Java

A fully-qualified class name in Java contains the package that the class originated from. Also, an inner class is a class that is another class member. So, the fully-qualified name of an inner class can be obtained using the getName() method.
A program that demonstrates this is given as follows −
 Live Demo
public class Main {
   public static void main(String[] argv) throws Exception {
      Class c = java.lang.Character.Subset.class;
      String innerClassName = c.getName();
      System.out.println("The fully qualified name of the inner class is: " + innerClassName);
   }
}
The fully qualified name of the inner class is: java.lang.Character$Subset
Now let us understand the above program.
The getName() method is used to get the fully-qualified name of the inner class i.e. the Subset class and this is stored in className. Then this is displayed. A code snippet which demonstrates this is as follows −
Class c = java.lang.Character.Subset.class;
String innerClassName = c.getName();
System.out.println("The fully qualified name of the inner class is: " + innerClassName);
HTML DOM Style backgroundColor Property

The backgroundColor property is used for setting or returning background color for an element. We can specify values by standard names, rgb(), rgba(), hsl() or hsla().
Following is the syntax for −
Setting the backgroundColor property −
object.style.backgroundColor = "color|transparent
The above property values are explained as follows −
Let us look at the example for the backgroundColor property −
Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
   #DIV1{
      background-color: rgba(10,122,102,0.1);
   }
</style>
<script>
   function changeBackColor(){
      document.getElementById("DIV1").style.backgroundColor="rgba(1,200,55,0.5)";
      document.getElementById("Sample").innerHTML="The background color is now changed";
   }
</script>
</head>
<body>
<div id="DIV1">Duis tincidunt urna a interdum consectetur. Pellentesque nec pretium ante.
In nisl magna, vestibulum non vulputate vel, feugiat ac tellus. Sed tincidunt id leo at mollis.
Praesent pellentesque purus vitae scelerisque gravida. Pellentesque pulvinar scelerisque sem,
at euismod sapien tristique et.</div>
<p>Change the above div background color by clicking the below button</p>
<button onclick="changeBackColor()">CHANGE COLOR</button>
<p id="Sample"></p>
</body>
</html>
This will produce the following output −
On clicking the CHANGE CLIP button −
JSON Formatting in Python

The JSON (Java Script Object Notation) is light weight, well accepted data interchange format. Using JSON formatting techniques in Python, we can convert JSON strings to Python objects, and also convert Python Objects to JSON strings.
To use these functionalities, we need to use the json module of Python. The json module comes with the Python standard library. So at first we have to import it first.
import json
In the json module, there are some methods like dump(), and dumps() to convert Python objects to JSON strings. The dump() method takes two arguments, the first one is the object, and second one is file object. This method serialize the object as JSON formatted stream to file objects. Similarly the dumps() method takes only one argument. The argument is object. It converts the objects to JSON string.
import json
from io import StringIO
str_io_obj = StringIO()
#Use JSON Dump to make StringIO
json.dump(["India", "Australia", "Brazil"], str_io_obj)
print('StringIO Object value: ' + str(str_io_obj.getvalue()))
my_json = {
   "name" : "Kalyan",
   "age" : 25,
   "city" : 'Delhi'
}
print(json.dumps(my_json, indent=4))
StringIO Object value: ["India", "Australia", "Brazil"] {
   "name": "Kalyan",
   "age": 25,
   "city": "Delhi"
}
In this case we are De-serializing the JSON strings. There are two different methods. These are load() and loads(). Both of these methods takes the JSON file as argument. load() converts to python objects from file objects data, and loads() converts from string type data.
import json
from io import StringIO
str_io_obj = StringIO('["xyz", "abc", "xyz", "pqr"]')
#load from StringIO
print('Load: ' + str(json.load(str_io_obj)))
print('String to Json: ' + str(json.loads('{"xyz" : 1, "abc" : 2, "xyz" : 3, "pqr" : 4}')))
Load: ['xyz', 'abc', 'xyz', 'pqr']
String to Json: {'xyz': 3, 'abc': 2, 'pqr': 4}
The JSONEncoder class is used to convert Python Objects to JSON format. Here in this example we will see how a complex number object can be converted as JSON type object using the JSONEncoder.
import json
class Comp_Encoder(json.JSONEncoder):
   def default(self, comp_obj):
      if isinstance(comp_obj, complex):
      return [comp_obj.real, comp_obj.imag]
      return json.JSONEncoder.default(self, comp_obj)
      print(json.dumps(5+8j, cls=Comp_Encoder))
[5.0, 8.0]
The JSONDecoder class performs the reverse action.
import json
my_str = '{"Asim" : 25, "Priyesh" : 23, "Asim" : "28"}'
#Decode JSON using the JSONDecoder
print(json.JSONDecoder().decode(my_str))
print(json.JSONDecoder().raw_decode(my_str))
{'Asim': '28', 'Priyesh': 23}
({'Asim': '28', 'Priyesh': 23}, 44)
C# Object Creation of Inherited Class

A class can be derived from more than one class or interface, which means that it can inherit data and functions from multiple base classes or interfaces.
The derived class inherits the base class member variables and member methods. Therefore, the super class object should be created before the subclass is created. You can give instructions for superclass initialization in the member initialization list.
Here you can see object is created for the inherited class.
 Live Demo
using System;
namespace Demo {
   class Rectangle {
      protected double length;
      protected double width;
      public Rectangle(double l, double w) {
         length = l;
         width = w;
      }
      public double GetArea() {
         return length * width;
      }
      public void Display() {
         Console.WriteLine("Length: {0}", length);
         Console.WriteLine("Width: {0}", width);
         Console.WriteLine("Area: {0}", GetArea());
      }
   }
   class Tabletop : Rectangle {
      private double cost;
      public Tabletop(double l, double w) : base(l, w) { }
      public double GetCost() {
         double cost;
         cost = GetArea() * 70;
         return cost;
      }
      public void Display() {
         base.Display();
         Console.WriteLine("Cost: {0}", GetCost());
      }
   }
   class ExecuteRectangle {
      static void Main(string[] args) {
         Tabletop t = new Tabletop(3, 8);
         t.Display();
         Console.ReadLine();
      }
   }
}
Length: 3
Width: 8
Area: 24
Cost: 1680
HTTP headers | Access-Control-Allow-Headers. - GeeksforGeeks

19 Nov, 2019
The HTTP Access-Control-Allow-Headers header is a response-type header that is used to indicate the HTTP headers. It can be used during a request and is used in response to a CORS preflight request, that checks to see if the CORS protocol is understood and a server is aware using specific methods and headers, which includes the Access-Control-Request-Headers HTTP header.
Syntax:
Access-Control-Allow-Headers: <header-name>
Note:Multiple headers can be used.
Directives: This header accepts two directives described below:
<header-name>: It specifies the supported request header. If there are multiple headers in use we separate them using commas.
*(wildcard): It is used for requests without HTTP cookies or HTTP authentication information. It should be noted that the Authorization header cannot be wild-carded and needs explicit mentioning.
Examples:
When there is just one headerAccess-Control-Allow-Headers: Proxy-Authorization
Access-Control-Allow-Headers: Proxy-Authorization
When there are multiple headersAccess-Control-Allow-Headers: Proxy-Authorization, Max-ForwardsTo check the Access-Control-Allow-Headers header, go to Inspect Element -> Network. Check the response header like below Access-Control-Allow-Headers is highlightedSupported Browsers: The browsers are compatible with HTTP Access-Control-Allow-Headers header are listed below:Google Chrome 4.0Internet Explorer 12.0Firefox 3.5Opera 12.0Safari 4.0Note: *(wildcard) directive may not supported on Safari and Internet Explorer.My Personal Notes
arrow_drop_upSave
Access-Control-Allow-Headers: Proxy-Authorization, Max-Forwards
To check the Access-Control-Allow-Headers header, go to Inspect Element -> Network. Check the response header like below Access-Control-Allow-Headers is highlighted
Supported Browsers: The browsers are compatible with HTTP Access-Control-Allow-Headers header are listed below:
Google Chrome 4.0
Internet Explorer 12.0
Firefox 3.5
Opera 12.0
Safari 4.0
Note: *(wildcard) directive may not supported on Safari and Internet Explorer.
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Express.js express.Router() Function
Top 10 Angular Libraries For Web Developers
Convert a string to an integer in JavaScript
How to set the default value for an HTML <select> element ?
Set the value of an input field in JavaScript
How to Insert Form Data into Database using PHP ?
Client-Server Model
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
How to create footer to stay at the bottom of a Web page?
Set find() function in C++ programming STL

In this article we are going to discuss the set::find() function in C++ STL, their syntax, working and their return values.
Sets in C++ STL are the containers which must have unique elements in a general order. Sets must have unique elements because the value of the element identifies the element. Once added a value in a set container later can’t be modified, although we can still remove or add the values to the set. Sets are used as binary search trees.
find() function is an inbuilt function in C++ STL, which is defined in header file. This function is used to find an element or a value in a set container. find() returns an iterator which points to the position of the element which is searched. If the element is not present in the set, then it returns the element just after the last element of the set container.
Set1.find(const type_t& element);
This function accepts one parameter, i.e., element which is to be found.
This function returns an iterator which points to the element which is to be found.
Input: set<int> myset = {10, 20, 40, 80, 90};
myset.find(40);
Output: element found
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int main(){
   set<int> mySet;
   mySet.insert(10);
   mySet.insert(20);
   mySet.insert(90);
   mySet.insert(80);
   mySet.insert(40);
   auto temp = mySet.find(40);
   cout<<"Elements after 40 are: ";
   for (auto i = temp; i != mySet.end(); i++)
      cout << *i << " ";
   return 0;
}
If we run the above code then it will generate the following output −
Elements after 40 are: 40 80 90
 Live Demo
#include <iostream>
#include <set>
int main (){
   std::set<int> mySet;
   std::set<int>::iterator i;
   for(int i=1; i<=4; i++)
      mySet.insert(i*2);
   i = mySet.find(6);
   mySet.erase(i);
   mySet.erase(mySet.find(4));
   std::cout<<"elements are : ";
   for (i = mySet.begin(); i != mySet.end(); ++i)
      std::cout << ' ' << *i;
   std::cout << '\n';
   return 0;
}
If we run the above code then it will generate the following output −
Elements are : 2 8
Access to file download dialog in Firefox in Selenium.

We can access file download dialog in Firefox in Selenium. For this we have to first modify the default directory where the downloaded file gets stored. This is done by the addpreference method.
p.addPreference("browser.download.folderList", 2);
Then, define the new path of the download directory.
Finally, we shall ignore the save to disk and open file options in dialog for the file types via their MIME code. The addPreference method can be called with the help of FirefoxOptions class.
Code Implementation.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import java.util.concurrent.TimeUnit;
public class FileDwnloadWithoutDialg{
   public static void main(String[] args) {
      System.setProperty("webdriver.gecko.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe");
      // instance of FirefoxOptions class
      FirefoxOptions profile = new FirefoxOptions();
      // adding browser preferences with addPreference method profile.addPreference("browser.download.folderList", 2);
      // location of downloaded file
      profile.addPreference("browser.download.dir", "C:\\Users\\ghs6kor\\Documents\\Download");
      profile.addPreference("browser.helperApps.neverAsk.openFile", "text/csv,application/x-msexcel,application/excel," + "application/x-excel,application/vnd.ms-excel," + "image/png,image/jpeg,text/html,text/plain," + "application/msword,application/xml");
profile.addPreference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/x-msexcel," + "application/excel," + "application/x-excel," +"application/vnd.ms excel,image/png,image/jpeg,text/html," +"text/plain,application/msword,application/xml");
      // connecting browser options to webdriver
      WebDriver driver = new FirefoxDriver(profile);
      driver.get("https://the-internet.herokuapp.com/download");
      //maximize window
      driver.manage().window().maximize();
      // identify element and start download
      driver.findElement(By.linkText("xls-sample3.xls")).click();
   }
}
Difference Between Constructor and Destructor in C++ - GeeksforGeeks

29 Dec, 2021
Constructor: A constructor is a member function of a class that has the same name as the class name. It helps to initialize the object of a class. It can either accept the arguments or not. It is used to allocate the memory to an object of the class. It is called whenever an instance of the class is created. It can be defined manually with arguments or without arguments. There can be many constructors in a class. It can be overloaded but it can not be inherited or virtual. There is a concept of copy constructor which is used to initialize an object from another object. 
Syntax:  
  ClassName()
   {
     //Constructor's Body 
   } 
Destructor: Like a constructor, Destructor is also a member function of a class that has the same name as the class name preceded by a tilde(~) operator. It helps to deallocate the memory of an object. It is called while the object of the class is freed or deleted. In a class, there is always a single destructor without any parameters so it can’t be overloaded. It is always called in the reverse order of the constructor. if a class is inherited by another class and both the classes have a destructor then the destructor of the child class is called first, followed by the destructor of the parent or base class. 
Syntax:  
  ~ClassName()
   { 
       //Destuctor's Body
   }
Note: If we do not specify any access modifiers for the members inside the class then by default the access modifier for the members will be Private. 
Example/Implementation of Constructor and Destructor: 
C++
#include <iostream>using namespace std; class Z{public:    // constructor    Z()    {        cout<<"Constructor called"<<endl;    }     // destructor    ~Z()    {        cout<<"Destructor called"<<endl;    }}; int main(){    Z z1;   // Constructor Called    int a = 1;    if(a==1)    {        Z z2;  // Constructor Called    }  // Destructor Called for z2} //  Destructor called for z1
Output:  
Constructor called
Constructor called
Destructor called
Destructor called 
Difference between Constructor and Destructor in C++ : 
Aniket Ray
vinaygb456
anantverma2001
sagar0719kumar
geeky01adarsh
C++-Constructors
C++-Destructors
C++
Difference Between
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Operator Overloading in C++
Iterators in C++ STL
Friend class and function in C++
Polymorphism in C++
Sorting a vector in C++
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Stack vs Heap Memory Allocation
Difference between Process and Thread
How to Use Reserved Words as Column Names in SQL? - GeeksforGeeks

28 Oct, 2021
In SQL, certain words are reserved. These are called Keywords or Reserved Words. These words cannot be used as identifiers i.e. as column names in SQL. But, there is an exception to this rule too. In this article, we will discuss how to use Reserved Words as column names in SQL. For this article, we will be using the Microsoft SQL Server as our database.
Step 1: Create a Database. For this use the below command to create a database named GeeksForGeeks
Query:
CREATE DATABASE GeeksForGeeks
Output:
Step 2: Use the GeeksForGeeks database. For this use the below command
Query:
USE GeeksForGeeks
Output:
Step 3: Create a table inside the database GeeksForGeeks. We will name the table BIKE. It will contain 2 columns named SELECT and TABLE. Both these are keywords in SQL. The trick here is to type the column names inside the square brackets ‘[]’ so that they are not read as a Reserved Word by the compiler.
Query:
CREATE TABLE BIKE(
[SELECT] VARCHAR(10),
[TABLE] INT);
Output:
Note: Here, the SELECT column stores the names of the bikes, and the TABLE column stores the cost of the bikes.
Step 4: Add data to the BIKE table.
Query:
INSERT INTO BIKE VALUES('HERO',10000);
INSERT INTO BIKE VALUES('TVS',20000);
INSERT INTO BIKE VALUES('YAMAHA',30000);
INSERT INTO BIKE VALUES('HONDA',40000);
INSERT INTO BIKE VALUES('BAJAJ',50000);
Output:
Step 4: Display the SELECT column from the BIKE table.
Query:
SELECT [SELECT] FROM BIKE;
Output:
Step 5: Display the TABLE column from the BIKE table.
Query:
SELECT [TABLE] FROM BIKE;
Output:
Step 5: We can even display both the columns using the comma separator.
Query:
SELECT [SELECT],[TABLE] FROM BIKE;
Output:
Hence, in a similar fashion, we can use any of the reserved names in SQL as a column name.
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?
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL | Subquery
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
How to convert a matrix to a data frame with column names and row names as new columns in R?

Sometimes we want to create a factor column of the column names and row names of a matrix so that we can use them in the analysis. It is required in situations where we want to know the effect of factor variables on the response and the factor variables were recorded as column names and row names in a matrix. To do this, we can convert the matrix into table and the table obtained is converted to data frame.
Consider the below matrix −
M1<-matrix(1:25,nrow=5,dimnames=list(c("R1","R2","R3","R4","R5"),c("S1","S2","S3","S4","S5")))
M1
S1 S2 S3 S4 S5
R1 1 6 11 16 21
R2 2 7 12 17 22
R3 3 8 13 18 23
R4 4 9 14 19 24
R5 5 10 15 20 25
as.data.frame(as.table(M1))
Var1 Var2 Freq
1 R1 S1 1
2 R2 S1 2
3 R3 S1 3
4 R4 S1 4
5 R5 S1 5
6 R1 S2 6
7 R2 S2 7
8 R3 S2 8
9 R4 S2 9
10 R5 S2 10
11 R1 S3 11
12 R2 S3 12
13 R3 S3 13
14 R4 S3 14
15 R5 S3 15
16 R1 S4 16
17 R2 S4 17
18 R3 S4 18
19 R4 S4 19
20 R5 S4 20
21 R1 S5 21
22 R2 S5 22
23 R3 S5 23
24 R4 S5 24
25 R5 S5 25
Let’s have a look at two more examples −
M2<-matrix(sample(1:50,16),nrow=4,dimnames=list(c("R1","R2","R3","R4"),c("C1","C2","C3","C4")))
M2
C1 C2 C3 C4
R1 38 23 30 34
R2 17 19 32 10
R3 9 26 47 1
R4 39 43 29 44
as.data.frame(as.table(M2))
Var1 Var2 Freq
1 R1 C1 38
2 R2 C1 17
3 R3 C1 9
4 R4 C1 39
5 R1 C2 23
6 R2 C2 19
7 R3 C2 26
8 R4 C2 43
9 R1 C3 30
10 R2 C3 32
11 R3 C3 47
12 R4 C3 29
13 R1 C4 34
14 R2 C4 10
15 R3 C4 1
16 R4 C4 44
M3 <-matrix(sample(1:100,16),ncol=4,dimnames=list(c("Cold","Hot","Sweet","Bitter"),c("Winter","Autumn","Rainy","Summer")))
> M3
Winter Autumn Rainy Summer
Cold 15 42 97 83
Hot 58 48 53 35
Sweet 29 76 86 43
Bitter 24 39 40 1
as.data.frame(as.table(M3))
Var1 Var2 Freq
1 Cold Winter 15
2 Hot Winter 58
3 Sweet Winter 29
4 Bitter Winter 24
5 Cold Autumn 42
6 Hot Autumn 48
7 Sweet Autumn 76
8 Bitter Autumn 39
9 Cold Rainy 97
10 Hot Rainy 53
11 Sweet Rainy 86
12 Bitter Rainy 40
13 Cold Summer 83
14 Hot Summer 35
15 Sweet Summer 43
16 Bitter Summer 1
Dart Programming - floor Method

This method returns the largest integer less than or equal to a number.
Number.floor()

Returns the largest integer less than or equal to a number x.
void main() { 
   var a = 2.9; 
   print("The floor value of 2.9 = ${a.floor()}"); 
} 
It will produce the following output −.
The floor value of 2.9 = 2


    44 Lectures 
     4.5 hours 

 Sriyank Siddhartha

    34 Lectures 
     4 hours 

 Sriyank Siddhartha

    69 Lectures 
     4 hours 

 Frahaan Hussain

    117 Lectures 
     10 hours 

 Frahaan Hussain

    22 Lectures 
     1.5 hours 

 Pranjal Srivastava

    34 Lectures 
     3 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page
Elm - Package Manager

A package manager is a command-line tool that automates the process of installing, upgrading, configuring, and removing packages in your application.
Just like JavaScript has a package manager called npm, elm has a package manager called elm-package.
The package manager performs the following three tasks −
Installs all dependencies that an elm application need
Publishes custom packages
Determines the version of your package when you are ready to publish and update.
The following table lists down the various Elm package manager commands −
In order to publish your package, you need to host source code on GitHub and have the version properly labeled with a git tag. Following illustration shows how to use elm-package manager to pull an external dependency.
In this example, we will see how to integrate Scalable Vector Graphics(SVG) into an elm application.
Step 1 − Create a folder elmSvgApp
Step 2 − Install svg package using the following command −
elm-package install elm-lang/svg

Step 3 − Install Create a SvgDemo.elm file and type the content given below. We import Svg module to draw a rectangle of 100x100 dimension and fill the colour red.
import Svg exposing (..)
import Svg.Attributes exposing (..)

main =
   svg
   [ width "120"
   , height "120"
   , viewBox "0 0 120 120"
   ]
   [ rect
      [ x "10"
      , y "10"
      , width "100"
      , height "100"
      , rx "15"
      , ry "15"
      ,fill "red"
      ]
      []
   ]
Step 4 − Now build the project using elm make .\SvgDemo.elm. This will generate an index.html as shown below −

    27 Lectures 
     2.5 hours 

 Ahmed Elfakharany
 Print
 Add Notes
 Bookmark this page
C++ Program to find whether a number is the power of two?

Check if a given number is a power of 2. First check below which numbers are the power of two or not. This code checks whether the number is odd and then divide it concurrently until it becomes 0 or odd. If it becomes 0 then it is a power 2 else it is not.
A better choice is to take the log of the number. If it is an integer, then n is a power of 2 else not. Numbers that are powers of 2:
2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 ...
22 = 4
25 = 32
210 = 1024
Input: 8
Output: Number is power of 2
A simple method for this is to simply take the log of the number on base 2 and if you get an integer then the number is the power of 2.
By simply repeatedly dividing N by 2 if N is an even number. If it end up at 1 then N is a power of 2
#include <iostream>
using namespace std;
int main() {
   int n=8;
   if(n>0) {
      while(n%2 == 0) {
         n/=2;
      }
      if(n == 1) {
         cout<<"Number is power of 2"<<endl;
      }
   }
   if(n == 0 || n != 1) {
      cout<<"Number is not power of 2"<<endl;
   }
   return 0;
}
Access objects from the nested objects structure in MongoDB

Access objects using dot notation. Let us first create a collection with documents
> db.nestedObjectDemo.insertOne({"Student" : { "StudentDetails" : { "StudentPersonalDetails" : { "StudentName" : [ "John" ],
... "StudentCountryName" : [ "US" ],
... "StudentCoreSubject" : [ "C", "Java" ],
... "StudentProject" : [ "Online Book Store", "Pig Dice Game" ] } } } });
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c99dfc2863d6ffd454bb650")
}
Following is the query to display all documents from a collection with the help of find() method
> db.nestedObjectDemo.find().pretty();
This will produce the following output
{
   "_id" : ObjectId("5c99dfc2863d6ffd454bb650"),
   "Student" : {
      "StudentDetails" : {
         "StudentPersonalDetails" : {
            "StudentName" : [
               "John"
            ],
            "StudentCountryName" : [
               "US"
            ],
            "StudentCoreSubject" : [
               "C",
               "Java"
            ],
            "StudentProject" : [
               "Online Book Store",
               "Pig Dice Game"
            ]
         }
      }
   }
}
Following is the query to access nested objects using dot notation
>db.nestedObjectDemo.find({"Student.StudentDetails.StudentPersonalDetails.StudentName":"John"}).pretty();
This will produce the following output
{
   "_id" : ObjectId("5c99dfc2863d6ffd454bb650"),
   "Student" : {
      "StudentDetails" : {
         "StudentPersonalDetails" : {
            "StudentName" : [
               "John"
            ],
            "StudentCountryName" : [
               "US"
            ],
            "StudentCoreSubject" : [
               "C",
               "Java"
            ],
            "StudentProject" : [
               "Online Book Store",
               "Pig Dice Game"
            ]
         }
      }
   }
}
How to display a float with two decimal places in Python?

You can use string formatting to format floating point numbers to a fixed width in Python.For example, if you want the decimal points to be aligned with width of 12 characters and 2 digits on the right of the decimal, you can use the following:
 >>>x = 12.35874
>>>print "{:12.2f}".format(x)
     12.36
 You can also achieve this result using string interpolation and formatting. For example:
>>>x = 12.35874
>>>print "% 12.2f" % x
     12.36
How to get the size of a JavaScript object?

21 Jun, 2019
We can get size of java script object with the help of Object.keys() method.
Syntax:
Object.keys(object_name)
object_name
Return Value: an array of all the object’s own enumerable property keys.
Approach-1:Create an object variable and assign values to itCreate an variable which shows the sizeCall the Object.keys(object-name).length and assign it to the variable (in step 2).
Create an object variable and assign values to it
Create an variable which shows the size
Call the Object.keys(object-name).length and assign it to the variable (in step 2).
Example-1: To get size of javascript object by Object.keys() method.
<script>var object1= { "rajnish":"singh",               "sanjeev":"sharma",               "suraj":"agrahari",               "yash":"khandelwal"             };var count= Object.keys(object1).length;document.write(count);</script>
Output: 4
Another way to get the size of the javascript object is:
Approach-2:Create an object variable and assign values to itCreate an variable which shows the sizePass the object-name to Object.objsize which further enters to the function which calculates and returns the size and assign it to the variable.
Create an object variable and assign values to it
Create an variable which shows the size
Pass the object-name to Object.objsize which further enters to the function which calculates and returns the size and assign it to the variable.
<script>Object.objsize = function(obj)    {    var size = 0, key;      for (key in obj)        {       if (obj.hasOwnProperty(key))         size++;             }      return size;      };  var object1 = { "rajnish":"singh",            "sanjeev":"sharma",        "suraj":"agrahari",        "yash":"khandelwal"          };  var count = Object.objsize(object1);document.write(count);                    </script>
Output: 4
JavaScript-Misc
Picked
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
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 ?
How to customize a button to set text and color in Android?

This example demonstrates how do I customize a button to set text and color in android.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:background="#c0c0c0"
   android:layout_height="match_parent"
   tools:context=".MainActivity">
   <Button
      android:id="@+id/customBtn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerInParent="true"
      android:padding="4dp"
      android:textStyle="bold"
      android:textSize="24sp"/>
   </RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
   Button button;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      button = findViewById(R.id.customBtn);
      button.setText("Red Color Button");
      button.setTextColor(Color.parseColor("#ff0000"));
   }
}
Step 4 - Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  Icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen –
How to recursively iterate a nested Python dictionary?

Given below is a nested directory object
D1={1: {2: {3: 4, 5: 6}, 3: {4: 5, 6: 7}}, 2: {3: {4: 5}, 4: {6: 7}}}
Following recursive function is called repetitively if the value component of each item in directory is a directory itself.
def iterdict(d):
  for k,v in d.items():        
     if isinstance(v, dict):
         iterdict(v)
     else:            
         print (k,":",v)

iterdict(D1)
When the initial dictionary object is passed to this function, all the key-value pairs are traversed. The output is:
3 4
5 6
4 5
6 7
4 5
6 7
Python program to print all negative numbers in a range

01 Jun, 2022
Given the start and end of a range, write a Python program to print all negative numbers in a given range.
 Examples:
Input: a = -4, b = 5
Output: -4, -3, -2, -1

Input: a = -3, b= 4
Output: -3, -2, -1
Method: Print all the negative numbers using a single-line solution.
Print all negative numbers using for loop. Define the start and end limits of the range. Iterate from start range to end range using for loop and check if num is less than 0. If the condition satisfies, then only print the number. 
Python3
# Python code# To print all negative numbers in a given range  def negativenumbers(a,b):  # Checking condition for negative numbers  # single line solution  out=[i for i in range(a,b+1) if i<0]  # print the all negative numbers  print(*out) # driver code# a -> start rangea=-4# b -> end rangeb=5negativenumbers(a,b)
-4 -3 -2 -1
Example #1: Print all negative numbers from given list using for loop Define start and end limit of range. Iterate from start till the range in the list using for loop and check if num is less than 0. If the condition satisfies, then only print the number. 
Python3
# Python program to print negative Numbers in given range start, end = -4, 19 # iterating each number in listfor num in range(start, end + 1):         # checking condition    if num < 0:        print(num, end = " ")
-4 -3 -2 -1 
  Example #2: Taking range limit from user input 
Python3
# Python program to print negative Numbers in given range start = int(input("Enter the start of range: "))end = int(input("Enter the end of range: ")) # iterating each number in listfor num in range(start, end + 1):         # checking condition    if num < 0:        print(num, end = " ")
Output:
Enter the start of range: -15
Enter the end of range: 5
-15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 
laxmigangarajula03
Python list-programs
python-list
Python
Python Programs
School Programming
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
GATE | GATE-CS-2000 | Question 45

28 Jun, 2021
Suppose the time to service a page fault is on the average 10 milliseconds, while a memory access takes 1 microsecond. Then a 99.99% hit ratio results in average memory access time of (GATE CS 2000)
(A) 1.9999 milliseconds(B) 1 millisecond(C) 9.999 microseconds(D) 1.9999 microsecondsAnswer: (D)Explanation: If any page request comes it will first search into page table, if present, then it will directly fetch the page from memory, thus in this case time requires will be only memory access time.
But if required page will not be found, first we have to bring it out and then go for memory access. This extra time is called page fault service time.
Let hit ratio be p , memory access time be t1 , and page fault service time be t2.
Hence, average memory access time = p*t1 + (1-p)*t2
                    =(99.99*1 +  0.01*(10*1000 + 1))/100
                                                             =1.9999 *10^-6 sec


This explanation is contributed by Abhishek Kumar.
Also, see question 1 of https://www.geeksforgeeks.org/operating-systems-set-3/Quiz of this Question
GATE-CS-2000
GATE-GATE-CS-2000
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE CS 2011 | Question 49
GATE | GATE CS 1996 | Question 38
GATE | GATE-CS-2004 | Question 31
GATE | GATE IT 2006 | Question 20
GATE | GATE-CS-2016 (Set 1) | Question 45