code-rag-bench/online-tutorials huggingface dataset:
Constructors in C++

Constructors are functions of a class that are executed when new objects of the class are created. The constructors have the same name as the class and no return type, not even void. They are primarily useful for providing initial values for variables of the class.
The two main types of constructors are default constructors and parameterized constructors. Details about these are given as follows.
Default constructors do not take any parameters. If a default constructor is not provided by the programmer explicitly, then the compiler provides a implicit default constructor. In that case, the default values of the variables are 0.
A program that demonstrates default constructors is given as follows.
 Live Demo
#include <iostream>
using namespace std;
class A {
   private:
   int num1, num2 ;
   public:
   A() {
      num1 = 5;
      num2 = 7;
   }
   void display() {
      cout<<"num1 = "<< num1 <<endl;
      cout<<"num2 = "<< num2 <<endl;
   }
};
int main() {
   A obj;
   obj.display();
   return 0;
}
num1 = 5
num2 = 7
In the above program, the class A contains a default constructor that initialises num1 and num2 as 5 and 7. It also contains a function display() that prints the value of num1 and num2. The code snippet for this is given as follows.
class A {
   private:
   int num1, num2 ;
   public:
   A() {
      num1 = 5;
      num2 = 7;
   }
   void display() {
      cout<<"num1 = "<< num1 <<endl;
      cout<<"num2 = "<< num2 <<endl;
   }
};
The function main() contains the object definition for an object of class type A. Then the function display() is called. This is shown below.
A obj;
obj.display();
The parameterized constructors can take arguments to initialize an object when it is created. Parameters are added to a parameterized constructor just like they are added to a normal function. The parameterized constructors can be called implicitly or explicitly.
A program that demonstrates parameterized constructors is given as follows.
 Live Demo
#include <iostream>
using namespace std;
class A {
   private:
   int num1, num2 ;
   public:
   A(int n1, int n2) {
      num1 = n1;
      num2 = n2;
   }
   void display() {
      cout<<"num1 = "<< num1 <<endl;
      cout<<"num2 = "<< num2 <<endl;
   }
};
int main() {
   A obj(3,8);
   obj.display();
   return 0;
}
num1 = 3
num2 = 8
In the above program, the class A contains a parameterized constructor that initialises num1 and num2 with the values provided by n1 and n2. It also contains a function display() that prints the value of num1 and num2. The code snippet for this is given as follows.
class A {
   private:
   int num1, num2 ;
   public:
   A(int n1, int n2) {
      num1 = n1;
      num2 = n2;
   }
   void display() {
      cout<<"num1 = "<< num1 <<endl;
      cout<<"num2 = "<< num2 <<endl;
   }
};
The function main() contains the object definition for an object of class type A. Then the function display() is called. This is shown below.
A obj(3,8);
obj.display();
Inorder Successor in BST in C++

Suppose we have a binary search tree and a node in it, we have to search the in-order successor of that node in the BST. As we know that the successor of a node p is the node with the smallest key greater than p.val.
So, if the input is like root = [2,1,3], p = 1,
then the output will be 2,
To solve this, we will follow these steps −
Define recursive method inorderSuccessor(), this will take root and p
Define recursive method inorderSuccessor(), this will take root and p
if root null, then −return null
if root null, then −
return null
return null
if val of root <= val of p, then −return inorderSuccessor(right of root , p)
if val of root <= val of p, then −
return inorderSuccessor(right of root , p)
return inorderSuccessor(right of root , p)
Otherwiseoption := inorderSuccessor(left of root , p)return (if option is zero, then root, otherwise option)
Otherwise
option := inorderSuccessor(left of root , p)
option := inorderSuccessor(left of root , p)
return (if option is zero, then root, otherwise option)
return (if option is zero, then root, otherwise option)
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class TreeNode{
public:
   int val;
   TreeNode *left, *right;
   TreeNode(int data){
      val = data;
      left = NULL;
      right = NULL;
   }
};
class Solution {
public:
   TreeNode* inorderSuccessor(TreeNode* root, TreeNode* p) {
      if(!root) return NULL;
      if(root->val <= p->val){
         return inorderSuccessor(root->right, p);
      }
      else{
         TreeNode* option = inorderSuccessor(root->left, p);
         return !option ? root : option;
      }
   }
};
main(){
   TreeNode *root = new TreeNode(2);
   root->left = new TreeNode(1);
   root->right = new TreeNode(3);
   TreeNode *p = root->left;
   Solution ob;
   cout << (ob.inorderSuccessor(root, p))->val;
}
{2,1,3},1
2
How to reduce the space between two plots that are joined with grid.arrange in R?

When we join or combine plots using grid.arrange the scales of the first plot comes in between as X-axis even if the independent variable in both of the plots is same.
Therefore, we might want to remove the space between the plots while joining to get only one X-axis. This can be done by using theme function.
Consider the below data frame −
 Live Demo
set.seed(123)
x<-rnorm(10,1)
y<-rnorm(10,2)
df<-data.frame(x,y)
df
      x          y
1 0.4395244 3.22408180
2 0.7698225 2.35981383
3 2.5587083 2.40077145
4 1.0705084 2.11068272
5 1.1292877 1.44415887
6 2.7150650 3.78691314
7 1.4609162 2.49785048
8 -0.2650612 0.03338284
9 0.3131471 2.70135590
10 0.5543380 1.52720859
Loading ggplot2 and gridExtra package −
library(ggplot2)
library(gridExtra)
Creating scatterplot and line chart between x and y with plot.margin to reduce the space between the plot when joined with grid.arrange −
Plot1<-ggplot(df,aes(x,y))+geom_point()+theme(plot.margin=unit(c(1,1,-0.5,1),"cm"))
Plot1
Plot2<-ggplot(df,aes(x,y))+geom_line()+theme(plot.margin=unit(c(-0.5,1,1,1),"cm"))
Plot2
Joining the two plots −
grid.arrange(Plot1,Plot2)
Python SQLite - Cursor Object - GeeksforGeeks

16 Feb, 2022
In this article, we are going to discuss cursor objects in sqlite3 module of Python.
It is an object that is used to make the connection for executing SQL queries. It acts as middleware between SQLite database connection and SQL query. It is created after giving connection to SQLite database.
Syntax: cursor_object=connection_object.execute(“sql query”);
Example 1: Python code to create a hotel_data database and insert records into the hotel table.
Python3
# importing sqlite3 moduleimport sqlite3  # create connection by using object# to connect with hotel_data databaseconnection = sqlite3.connect('hotel_data.db') # query to create a table named FOOD1connection.execute(''' CREATE TABLE hotel         (FIND INT PRIMARY KEY     NOT NULL,         FNAME           TEXT    NOT NULL,         COST            INT     NOT NULL,         WEIGHT        INT);         ''') # insert query to insert food  details in# the above tableconnection.execute("INSERT INTO hotel VALUES (1, 'cakes',800,10 )")connection.execute("INSERT INTO hotel VALUES (2, 'biscuits',100,20 )")connection.execute("INSERT INTO hotel VALUES (3, 'chocos',1000,30 )")  print("All data in food table\n") # create a cousor object for select querycursor = connection.execute("SELECT * from hotel ") # display all data from hotel tablefor row in cursor:    print(row)
Output:
Now go to your location and see the SQLite database is created.
Example 2: Python code to display data from hotel table.
Python3
# importing sqlite3 moduleimport sqlite3 # create connection by using object# to connect with hotel_data databaseconnection = sqlite3.connect('hotel_data.db')  # insert query to insert food  details# in the above tableconnection.execute("INSERT INTO hotel VALUES (1, 'cakes',800,10 )");connection.execute("INSERT INTO hotel VALUES (2, 'biscuits',100,20 )");connection.execute("INSERT INTO hotel VALUES (3, 'chocos',1000,30 )");  print("Food id and Food Name\n") # create a cousor object for select querycursor = connection.execute("SELECT FIND,FNAME from hotel ") # display all data from FOOD1 tablefor row in cursor:     print(row)
Output:
varshagumber28
Picked
Python-SQLite
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
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 | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
ArgumentNullException in C#

The exception thrown when a null reference is passed to a method that does not accept it as a valid argument.
Let us see an example.
When we set a null parameter to int.Parse() method, then ArgumentNullException is thrown as shown below −
using System;
class Demo {
   static void Main() {
      string val = null;
      int res = int.Parse(val); // error is thrown
   }
}
The following error is thrown when the above program is compiled since we have passed a null value.
Unhandled Exception:
System.ArgumentNullException: Value cannot be null.
ggplot2 - Working with Legends

Axes and legends are collectively called as guides. They allow us to read observations from the plot and map them back with respect to original values. The legend keys and tick labels are both determined by the scale breaks. Legends and axes are produced automatically based on the respective scales and geoms which are needed for plot.
Following steps will be implemented to understand the working of legends in ggplot2 −
Let us create the same plot for focusing on the legend of the graph generated with ggplot2 −
> # Load ggplot
> library(ggplot2)
>
> # Read in dataset
> data(iris)
>
> # Plot
> p <- ggplot(iris, aes(Sepal.Length, Petal.Length, colour=Species)) + geom_point()
> p

If you observe the plot, the legends are created on left most corners as mentioned below −
Here, the legend includes various types of species of the given dataset.
We can remove the legend with the help of property “legend.position” and we get the appropriate output −
> # Remove Legend
> p + theme(legend.position="none")

We can also hide the title of legend with property “element_blank()” as given below −
> # Hide the legend title
> p + theme(legend.title=element_blank())

We can also use the legend position as and when needed. This property is used for generating the accurate plot representation.
> #Change the legend position
> p + theme(legend.position="top")
>
> p + theme(legend.position="bottom")

Top representation
Bottom representation
We can change the font style and font type of title and other attributes of legend as mentioned below −
> #Change the legend title and text font styles
> # legend title
> p + theme(legend.title = element_text(colour = "blue", size = 10, + face = "bold"))
> # legend labels
> p + theme(legend.text = element_text(colour = "red", size = 8, + face = "bold"))

The output generated is given below −
Upcoming chapters will focus on various types of plots with various background properties like color, themes and the importance of each one of them from data science point of view.
 Print
 Add Notes
 Bookmark this page
cal - Unix, Linux Command

cal - To display a calendar.
cal [-mjy] [[month] year]
A single parameter specifies the 4 digit year (1 - 9999) to be displayed. Two parameters denote the Month (1 - 12) and Year (1 - 9999). If arguments are not specified, the current month is displayed. A year starts on 01 Jan.
To display current month's calendar
$ cal
     April 2016
Su Mo Tu We Th Fr Sa
               1  2
3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

To display feb 2015 calendar
$ cal 2 2015
     February 2015
Su Mo Tu We Th Fr Sa
1  2  3  4  5  6  7  
8  9  10 11 12 13 14 
15 16 17 18 19 20 21 
22 23 24 25 26 27 28

To display complete year calendar.
$ cal -y


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
jQuery - is( selector ) Method

The is( selector ) method checks the current selection against an expression and returns true, if at least one element of the selection fits the given selector.
If no element fits, or the selector is not valid, then the response will be 'false'.
Here is the simple syntax to use this method −
element.is( selector )

Here is the description of all the parameters used by this method −
selector − The expression with which to filter.
selector − The expression with which to filter.
Following is an example showing a simple usage of this method −
<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function() {
			
            $("li").click(function () {
				
               if ($(this).is(":first-child")) {
                  $("p").text("This is list item 1");
               } else if ($(this).is(".middle0,.middle1")) {
                  $("p").text("This is middle class list");
               } else if ($(this).is(":contains('item 5')")) {
                  $("p").text("It's 5th list");
               } 
            });
				
         });
      </script>
		
      <style>
         .selected { color:red; }
      </style>
   </head>
	
   <body>
      <div>
         <span>Click any list item below:</span>
			
         <ul>
            <li class = "top0">list item 1</li>
            <li class = "top1">list item 2</li>
            <li class = "middle0">list item 3</li>
            <li class = "middle1">list item 4</li>
            <li class = "bottom0">list item 5</li>
            <li class = "bottom1">list item 6</li>
         </ul>
			
         <p>FILLER</p>
      </div>
   </body>
</html>
This will produce following result −
list item 1
list item 2
list item 3
list item 4
list item 5
list item 6
FILLER

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
Java infinite do-while loop

Yes. Following do-while loop is a valid statement and causes an infinite loop.
do{} while(true);
Partition Operators in LINQ

Divide an input sequence into two separate sections without rearranging the elements of the sequence and then returning one of them.
Module Module1

   Sub Main()
   
      Dim words = {"once", "upon", "a", "time", "there", "was", "a", "jungle"}

      Dim query = From word In words
                  Skip 4

      Dim sb As New System.Text.StringBuilder()
	  
      For Each str As String In query
         sb.AppendLine(str)
         Console.WriteLine(str)
      Next
	  
      Console.ReadLine()
	  
   End Sub
  
End Module
When the above code in VB is compiled and executed, it produces the following result −
there
was
a
jungle

Module Module1

   Sub Main()
   
      Dim words = {"once", "upon", "a", "time", "there", "was", "a", "jungle"}

      Dim query = From word In words 
                  Skip While word.Substring(0, 1) = "t" 

      Dim sb As New System.Text.StringBuilder()
	  
      For Each str As String In query
         sb.AppendLine(str)
         Console.WriteLine(str)
      Next 
	  
      Console.ReadLine()
   End Sub
  
End Module
When the above code in VB is compiled and executed, it produces the following result −
once
upon
a
was
a
jungle

Module Module1

   Sub Main()
   
      Dim words = {"once", "upon", "a", "time", "there", "was", "a", "jungle"}

      Dim query = From word In words 
                  Take 3 

      Dim sb As New System.Text.StringBuilder()
	  
      For Each str As String In query
         sb.AppendLine(str)
         Console.WriteLine(str)
      Next 
	  
      Console.ReadLine()
	  
   End Sub
   
End Module
When the above code in VB is compiled and executed, it produces the following result −
once
upon
a

Module Module1

   Sub Main()
   
      Dim words = {"once", "upon", "a", "time", "there", "was", "a", "jungle"}

      Dim query = From word In words 
                  Take While word.Length < 6 

      Dim sb As New System.Text.StringBuilder()
	  
      For Each str As String In query
         sb.AppendLine(str)
         Console.WriteLine(str)
      Next
	  
      Console.ReadLine()
	  
   End Sub
   
End Module
When the above code in VB is compiled and executed, it produces the following result −
once
upon
a
time
there
was
a


    23 Lectures 
     1.5 hours 

 Anadi Sharma

    37 Lectures 
     13 hours 

 Trevoir Williams
 Print
 Add Notes
 Bookmark this page
Zoho Interview Experience | Set 37 (Java Developer) - GeeksforGeeks

24 Jul, 2019
Round 1: There were 20 Aptitude Questions and 10 Java MCQ.No C or C++ questions.
Round 2: This time it was quite easy ..
1.Given a String with or without special characters find if it is Palindrome or Not.. No splitting of array must be done or No additional spaces must be used for storing the array..
Eg: RACE CAR
Eg: I DID, DID I ?
2. Given an array of integers of size n. Convert the array in such a way that if next valid number is same as current number, double its value and replace the next number with 0. After the modification, rearrange the array such that all 0’s are shifted to the end.
Input : arr[] = {2, 2, 0, 4, 0, 8}Output : 4 4 8 0 0 0
Input : arr[] = {0, 2, 2, 2, 0, 6, 6, 0, 0, 8}Output : 4 2 12 8 0 0 0 0 0 0
3 . TWISTED PRIME NUMBER
A number is said to be twisted prime if it is a prime number and reverse of the number is also a prime number.
Input : 97
Output : Twisted Prime Number
Explanation: 97 is a prime number
and its reverse 79 is also a prime
number.

4.Given an array A[] and a number x, check for pair in A[] with sum as x.
Eg : Input {1, 2, 4, 3, 5, 6}
SUM : 5
Output : 2 (1, 4) & (2, 3)

5.Largest Sum Contiguous Subarray(Kadane’ Algorithm )
6.Diamond pattern : for given input size -> Here 3
  *
 ***
*****
 ***
  *
Zoho
Interview Experiences
Zoho
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Microsoft Interview Experience for Internship (Via Engage)
Amazon Interview Experience for SDE-1 (On-Campus)
Infosys Interview Experience for DSE - System Engineer | On-Campus 2022
Amazon Interview Experience for SDE-1
Directi Interview | Set 7 (Programming Questions)
Oracle Interview Experience | Set 69 (Application Engineer)
Amazon Interview Experience for SDE1 (8 Months Experienced) 2022
Amazon Interview Experience for SDE-1(Off-Campus)
Amazon Interview Experience (Off-Campus) 2022
Amazon Interview Experience for SDE-1
Python program to sort digits of a number in ascending order - GeeksforGeeks

23 Feb, 2021
Given an integer N, the task is to sort the digits in ascending order. Print the new number obtained after excluding leading zeroes.
Examples:
Input: N = 193202042Output: 1222349Explanation: Sorting all digits of the given number generates 001222349.Final number obtained after removal of leading 0s is 1222349.
Input: N = 78291342023Output:1222334789
Approach: Follow the steps below to solve the problem:
Convert the given integer to its equivalent string
Sort the characters of the string using join() and sorted().
Convert string to integer using type casting
Print the integer obtained.
Below is the implementation of the above approach:
Python3
# Python program to# implement the above approach  # Function to sort the digits# present in the number ndef getSortedNumber(n):      # Convert to equivalent string    number = str(n)      # Sort the string    number = ''.join(sorted(number))      # Convert to equivalent integer    number = int(number)      # Return the integer    return number    # Driver Coden = 193202042  print(getSortedNumber(n))
1222349

Time Complexity: O(N*log(N))Auxiliary Space: O(N)
number-digits
Mathematical
Python Programs
Sorting
Technical Scripter
Mathematical
Sorting
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Program to convert a given number to words
Algorithm to solve Rubik's Cube
Modular multiplicative inverse
Program to multiply two matrices
Count ways to reach the n'th stair
Python program to convert a list to string
Defaultdict in Python
Python | Split string into list of characters
Python program to check whether a number is Prime or not
Python | Get dictionary keys as a list
How to remove percentage sign at last position from every value in R data frame column?

To remove percentage sign at last position from every value in R data frame column, we can follow the below steps −
First of all, create a data frame with a column having percent sign at last position in every value.
First of all, create a data frame with a column having percent sign at last position in every value.
Then, use gsub function to remove the percent sign at last position from every value in the column.
Then, use gsub function to remove the percent sign at last position from every value in the column.
Let’s create a data frame as shown below −
var<-sample(c("5%","10%","1%","6%","7%","12%"),25,replace=TRUE)
df<-data.frame(var)
df
On executing, the above script generates the below output(this output will vary on your system due to randomization) −
   var
1  10%
2  12%
3   1%
4   1%
5   6%
6   5%
7   7%
8   5%
9   1%
10  6%
11 10%
12 10%
13 12%
14 10%
15 10%
16  5%
17  6%
18 12%
19 7%
20  6%
21 10%
22 12%
23  7%
24 10%
25 1%
Remove percentage sign from last position
Using gsub function to remove the percentage sign at last position from every value in column var of data frame df as shown below −
var<-sample(c("5%","10%","1%","6%","7%","12%"),25,replace=TRUE)
df<-data.frame(var)
df$new_var<-gsub("%$","",df$var)
df
   var new_var
1  10% 10
2  12% 12
3   1%  1
4   1%  1
5   6%  6
6   5%  5
7   7%  7
8   5%  5
9   1%  1
10  6%  6
11 10% 10
12 10% 10
13 12% 12
14 10% 10
15 10% 10
16  5%  5
17  6%  6
18 12% 12
19  7%  7
20  6%  6
21 10% 10
22 12% 12
23  7%  7
24 10% 10
25 1%   1
SQL Tryit Editor v1.6

SELECT * FROM Products
WHERE Price NOT BETWEEN 10 AND 20;
​
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, Opera, and Edge(79).
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
Python | Maximum frequency character in String

30 Jun, 2022
This article gives us the methods to find the frequency of maximum occurring character in a python string. This is quite important utility nowadays and knowledge of it is always useful. Let’s discuss certain ways in which this task can be performed. 
Method 1 : Naive method + max() 
In this method, we simply iterate through the string and form a key in a dictionary of newly occurred element or if element is already occurred, we increase its value by 1. We find maximum occurring character by using max() on values. 
Python3
# Python 3 code to demonstrate# Maximum frequency character in String# naive method # initializing stringtest_str = "GeeksforGeeks" # printing original stringprint ("The original string is : " + test_str) # using naive method to get# Maximum frequency character in Stringall_freq = {}for i in test_str:    if i in all_freq:        all_freq[i] += 1    else:        all_freq[i] = 1res = max(all_freq, key = all_freq.get) # printing resultprint ("The maximum of all characters in GeeksforGeeks is : " + str(res))
The original string is : GeeksforGeeks
The maximum of all characters in GeeksforGeeks is : e
Method 2 : Using collections.Counter() + max() 
The most suggested method that could be used to find all occurrences is this method, this actually gets all element frequency and could also be used to print single element frequency if required. We find maximum occurring character by using max() on values. 
Python3
# Python 3 code to demonstrate# Maximum frequency character in String# collections.Counter() + max()from collections import Counter # initializing stringtest_str = "GeeksforGeeks" # printing original stringprint ("The original string is : " + test_str) # using collections.Counter() + max() to get# Maximum frequency character in Stringres = Counter(test_str)res = max(res, key = res.get) # printing resultprint ("The maximum of all characters in GeeksforGeeks is : " + str(res))
The original string is : GeeksforGeeks
The maximum of all characters in GeeksforGeeks is : e
nidhi_biet
vinayedula
Python string-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
Python String | replace()
How to Install PIP on Windows ?
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
SQL | Comments

08 Nov, 2019
As is any programming languages comments matter a lot in SQL also. In this set we will learn about writing comments in any SQL snippet.
Comments can be written in the following three formats:
Single line comments.Multi line commentsIn line comments
Single line comments.
Multi line comments
In line comments
Single line comments: Comments starting and ending in a single line are considered as single line comments.Line starting with ‘–‘ is a comment and will not be executed.Syntax:-- single line comment
-- another comment
SELECT * FROM Customers; 

-- single line comment
-- another comment
SELECT * FROM Customers; 

Multi line comments: Comments starting in one line and ending in different line are considered as multi line comments. Line starting with ‘/*’ is considered as starting point of comment and are terminated when ‘*/’ is encountered.Syntax:/* multi line comment
another comment */
SELECT * FROM Customers; 

/* multi line comment
another comment */
SELECT * FROM Customers; 

In line comments: In line comments are an extension of multi line comments, comments can be stated in between the statements and are enclosed in between ‘/*’ and ‘*/’.Syntax:SELECT * FROM /* Customers; */ 
More examples:Multi line comment ->
/* SELECT * FROM Students;
SELECT * FROM STUDENT_DETAILS;
SELECT * FROM Orders; */
SELECT * FROM Articles; 

In line comment ->
SELECT * FROM Students;
SELECT * FROM /* STUDENT_DETAILS;
SELECT * FROM Orders;
SELECT * FROM */ Articles; 

SELECT * FROM /* Customers; */ 

More examples:
Multi line comment ->
/* SELECT * FROM Students;
SELECT * FROM STUDENT_DETAILS;
SELECT * FROM Orders; */
SELECT * FROM Articles; 

In line comment ->
SELECT * FROM Students;
SELECT * FROM /* STUDENT_DETAILS;
SELECT * FROM Orders;
SELECT * FROM */ Articles; 

This article is contributed by Pratik Agarwal. 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.
Rajendrarajput
SQL-basics
Articles
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Analysis of Algorithms | Set 1 (Asymptotic Analysis)
Time Complexity and Space Complexity
SQL Interview Questions
Understanding "extern" keyword in C
Java Tutorial
ACID Properties in DBMS
SQL query to find second highest salary?
Normal Forms in DBMS
Introduction of DBMS (Database Management System) | Set 1
Difference between Clustered and Non-clustered index
Style Binding in Angular 8

14 Sep, 2020
It is very easy to give the CSS styles to HTML elements using style binding in Angular 8. Style binding is used to set a style of a view element. We can set the inline styles of an HTML element using the style binding in angular. You can also add styles conditionally to an element, hence creating a dynamically styled element.
Syntax:
<element [style.style-property] = "'style-value'">

Example 1:
app.component.html:
HTML
<h1 [style.color] = "'green'"     [style.text-align] = "'center'" >  GeeksforGeeks</h1>
Output:
Example 2: Setting the size of the font using style binding.
app.component.html:
HTML
<div [style.color] = "'green'"      [style.text-align] = "'center'"      [style.font-size.px]="'24'" >  GeeksforGeeks</div>
Output:
Example 3: Conditional styling.
app.component.html:
HTML
<div [style.color]="status=='error' ? 'red': 'green'"      [style.text-align] = "'center'"      [style.font-size.px]="'24'" >  GeeksforGeeks</div>
app.component.ts:
Javascript
import { Component } from '@angular/core';    @Component({      selector: 'app-root',      templateUrl: './app.component.html',      styleUrls: ['./app.component.css']    })    export class AppComponent {     status = "All good";}
Output:
AngularJS-Misc
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Auth Guards in Angular 9/10/11
Routing in Angular 9/10
How to bundle an Angular app for production?
What is AOT and JIT Compiler in Angular ?
Angular PrimeNG Dropdown Component
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 compare times in Golang?

27 Jul, 2020
With the help of Before() and After() and Equal(), function we can compare the time as well as date but we are also going to use the time.Now() and time.Now().Add() function for comparison.
Functions Used: These functions compares the times as seconds.
Before(temp) – This function is used to check if the given time is before the temporary time variable and return true if the time variable comes before the temporary time variable else false.
After(temp) – This function is used to check if given time is after the temporary time variable and return true if time variable comes after temporary time variable else false.
Equal(temp) – This function is used to check if given time is equal the temporary time variable and return true if time variable equals temporary time variable else false.
Example #1 : In this example we can see that by using Before() and After() function, we are able to compare the dates by using these functions.
// Golang program to compare timespackage main  import "fmt"  // importing time moduleimport "time"  // Main functionfunc main() {      today := time.Now()    tomorrow := today.Add(24 * time.Hour)      // Using time.Before() method    g1 := today.Before(tomorrow)    fmt.Println("today before tomorrow:", g1)      // Using time.After() method    g2 := tomorrow.After(today)    fmt.Println("tomorrow after today:", g2)  }
Output :
today before tomorrow: true
tomorrow after today: true

Example #2 :
// Golang program to compare timespackage main  import "fmt"  // importing time moduleimport "time"  // Main functionfunc main() {      today := time.Now()    tomorrow := today.Add(24 * time.Hour)    sameday := tomorrow.Add(-24 * time.Hour)      if today != tomorrow {        fmt.Println("today is not tomorrow")    }      if sameday == today {        fmt.Println("sameday is today")    }      // using Equal function    if today.Equal(sameday) {        fmt.Println("today is sameday")    }  }
Output :
today is not tomorrow
sameday is today
today is sameday

Akanksha_Rai
GoLang-time
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Go
Golang Maps
How to Split a String in Golang?
Interfaces in Golang
Slices in Golang
Different Ways to Find the Type of Variable in Golang
How to Parse JSON in Golang?
How to convert a string in lower case in Golang?
How to Trim a String in Golang?
Inheritance in GoLang
How to split a string with a string delimiter in C#?

Delimiters are the commas that you can see in the below string.
string str = "Welcome,to,New York";
Now set the delimiter separately.
char[] newDelimiter = new char[] { ',' };
Use theSplit() method to split the string considering the delimiter as the parameter.
str.Split(newDelimiter, StringSplitOptions.None);
To split a string with a string deli meter, try to run the following code −
 Live Demo
using System;
class Program {
   static void Main() {
      string str = "Welcome,to,New York";
      char[] newDelimiter = new char[] { ',' };
      string[] arr = str.Split(newDelimiter, StringSplitOptions.None);
      foreach (string val in arr) {
         Console.WriteLine(val);
      }
   }
}
Welcome
to
New York
fmt.Errorf() Function in Golang With Examples

05 May, 2020
In Go language, fmt package implements formatted I/O with functions analogous to C’s printf() and scanf() function. The fmt.Errorf() function in Go language allow us use formatting features to create descriptive error messages. Moreover, this function is defined under the fmt package. Here, you need to import the “fmt” package in order to use these functions.
Syntax:
func Errorf(format string, a ...interface{}) error

Parameters: This function accepts two parameters which are illustrated below:
string: This is your error message with placeholder values such as %s for a string and %d for an integer.
a ...interface{}: This is either constant variable name used in the code or any inbuilt function.
Return Value: It returns the string as a value that satisfies error.
Example 1:
// Golang program to illustrate the usage of// fmt.Errorf() function  // Including the main packagepackage main  // Importing fmtimport (    "fmt")  // Calling mainfunc main() {      // Declaring some constant variables    const name, dept = "GeeksforGeeks", "CS"      // Calling the Errorf() function with verb    // %q which is used for a single-quoted character    err := fmt.Errorf("%q is a %q Portal.", name, dept)      // Printing the error message    fmt.Println(err.Error())}
Output:
"GeeksforGeeks" is a "CS" Portal.

Example 2:
// Golang program to illustrate the usage of// fmt.Errorf() function  // Including the main packagepackage main  // Importing fmt and timeimport (    "fmt"    "time")  // Calling mainfunc main() {      // Calling Errorf() function with verb $v which is used    // for printing structs    err := fmt.Errorf("error occurred at: %v", time.Now())      // Printing the error    fmt.Println("An error happened:", err)}
Output:
An error happened: error occurred at: 2009-11-10 23:00:00 +0000 UTC m=+0.000000001

Golang-fmt
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
strings.Replace() Function in Golang With Examples
fmt.Sprintf() Function in Golang With Examples
Golang Maps
How to Split a String in Golang?
Interfaces in Golang
How to Parse JSON in Golang?
How to Trim a String in Golang?
Different Ways to Find the Type of Variable in Golang
How to convert a string in lower case in Golang?
How to compare times in Golang?
time.NewTicker() Function in Golang With Examples

21 Apr, 2020
In Go language, time packages supplies functionality for determining as well as viewing time. The NewTicker() function in Go language is used to output a new Ticker that contains a channel in order to transmit the time with a period as stated by the duration parameter. It is helpful in setting the intervals or dropping the ticks of the ticker in order to make up for the slow recipients. Here, the duration ‘d’ must be greater than zero else a panic error will occur. And you can terminate the ticker by using the Stop() method in order to liberate the related resources. Moreover, this function is defined under the time package. Here, you need to import the “time” package in order to use these functions.
Syntax:
func NewTicker(d Duration) *Ticker

Here, “d” is the duration and *Ticker is a pointer to the Ticker. Where, the Ticker is used to hold a channel that supplies `ticks’ of a clock at intervals.
Return value: It returns a new Ticker that includes a channel.
Example 1:
// Golang program to illustrate the usage of// time.NewTicker() function  // Including main packagepackage main  // Importing fmt and timeimport "fmt"import "time"  // Calling mainfunc main() {      // Calling NewTicker method    d := time.NewTicker(2 * time.Second)      // Creating channel using make    // keyword    mychannel := make(chan bool)      // Calling Sleep() methpod in go    // function    go func() {        time.Sleep(7 * time.Second)          // Setting the value of channel        mychannel <- true    }()      // Using for loop    for {          // Select statement        select {          // Case statement        case <-mychannel:            fmt.Println("Completed!")            return          // Case to print current time        case tm := <-d.C:            fmt.Println("The Current time is: ", tm)        }    }}
Output:
The Current time is:  2020-04-08 14:54:20.143952489 +0000 UTC m=+2.000223531
The Current time is:  2020-04-08 14:54:22.143940032 +0000 UTC m=+4.000211079
The Current time is:  2020-04-08 14:54:24.143938623 +0000 UTC m=+6.000209686
Completed!

Here, for loop is used in order to print the current time until loop stops and this time is printed after a regular interval that is after a “tick” as specified in the code. And here it is 2 seconds. So, the current time is printed above after a regular interval of 2 seconds. Here, the ticker must stop after three times as the limit is 7 seconds and only 1 second is left after the third tick.
GoLang-time
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Go
Golang Maps
How to Split a String in Golang?
Interfaces in Golang
Slices in Golang
Different Ways to Find the Type of Variable in Golang
How to Parse JSON in Golang?
How to convert a string in lower case in Golang?
How to Trim a String in Golang?
How to compare times in Golang?
How to Install Scala Kernal in Jupyter?

09 Nov, 2021
Jupyter notebook is widely used by almost everyone in the data science community. While it’s a tool with extensive support for python-based development of machine learning projects, one can also use it for Scala development as well, using the spylon-kernel. In this article, we will see how to install spylon-kernel and configure it to build Scala-based projects on Jupyter.
Pre-requisite: Running Scala on Jupyter will require JRE to be installed, with its PATH environment variable set to Java bin folder(C:\Program Files\Java\jre1.8.0_211\bin in our case). Check this tutorial.
Follow the below steps to install Scala Kernal in Jupyter
Step 1: Launch terminal/powershell and install the spylon-kernel using pip, by running the following command.
pip install spylon-kernel
Step 2: Select the Scala kernel in the notebook, by creating a kernel spec, using the following command.
python -m spylon_kernel install
Step3: Launch Jupyter notebook on Browser.
jupyter notebook
Step 4: On the Jupyter homepage, select New -> spylon-kernel. This creates a new ipynb notebook which makes us of the Scala kernel.
Let’s test the install by running some Scala code:
Scala kernel installation and configuration is successful.
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript Date toTimeString() Method

21 Oct, 2021
Below is the example of Date toTimeString() method.
Example:<script>   // Here a date has been assigned   // while creating Date object   var dateobj =    new Date('October 15, 1996 05:35:32');     // Contents of above date object   // of time portion is returned   // using toTimeString() function.   var B = dateobj.toTimeString();     // Printing the time.   document.write(B);</script>                    
<script>   // Here a date has been assigned   // while creating Date object   var dateobj =    new Date('October 15, 1996 05:35:32');     // Contents of above date object   // of time portion is returned   // using toTimeString() function.   var B = dateobj.toTimeString();     // Printing the time.   document.write(B);</script>                    
Output:05:35:32 GMT+0530 (India Standard Time)
05:35:32 GMT+0530 (India Standard Time)
The date.toTimeString() method is used to return the time portion of the given date object in English. The date object is created using date() constructor.
Syntax:
dateObj.toTimeString()
Parameters: This function does not accept any parameter. It is just used along with a Date object created using Date() constructor whose time portion contents are returned in English like language.
Return Values: It return the time portion of the given date object in english.
Note: The DateObj is a valid Date object created using Date() constructor whose time portion contents is returned.
More codes for the above method are as follows:
Program 1: Here nothing as parameter is passed while creating date object but still toTimeString() method return current time.
<script>   // Here nothing has been assigned   // while creating Date object   var dateobj = new Date();     // It return current time using    // toTimeString() method.   var B = dateobj.toTimeString();     // Printing the current time.   document.write(B);</script>
Output:
14:58:08 GMT+0530 (India Standard Time)
Program 2: When time part is not given to the parameter of Date() constructor then it return the time as zeros(0).
<script>   // Only month date and year are    // assigned without time while   // creating Date object.   var dateobj = new Date('October 15, 1996');     // It returns time using    // toTimeString() method.   var B = dateobj.toTimeString();     // Printing the time.   document.write(B);</script>
Output:
00:00:00 GMT+0530 (India Standard Time)
Supported Browsers: The browsers supported by JavaScript Date toTimeString() Method are listed below:
Google Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 5.5 and above
Opera 5 and above
Safari 1 and above
ysachin2314
javascript-date
JavaScript-Methods
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
numpy.full() in Python

09 Mar, 2022
numpy.full(shape, fill_value, dtype = None, order = ‘C’) : Return a new array with the same shape and type as a given array filled with a fill_value.Parameters :
shape      : Number of rows
order      : C_contiguous or F_contiguous
dtype      : [optional, float(by Default)] Data type of returned array.  
fill_value : [bool, optional] Value to fill in the array.

Returns :
ndarray

# Python Programming illustrating# numpy.full method  import numpy as geek  a = geek.full([2, 2], 67, dtype = int)print("\nMatrix a : \n", a)  c = geek.full([3, 3], 10.1)print("\nMatrix c : \n", c)
Output :

Matrix a : 
 [[67 67]
 [67 67]]

Matrix c : 
 [[ 10.1  10.1  10.1]
 [ 10.1  10.1  10.1]
 [ 10.1  10.1  10.1]]

References :https://docs.scipy.org/doc/numpy/reference/generated/numpy.full.html#numpy.fullNote :These NumPy-Python programs won’t run on online IDE’s, so run them on your systems to explore them.This article is contributed by Mohit Gupta_OMG . If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@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.
vinayedula
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
Python – Sort words separated by Delimiter

22 Jul, 2021
Given string of words separated by some delimiter. The task is to sort all the words given in the string
Input : test_str = 'gfg:is:best:for:geeks', delim = "*" 
Output : best*for*geeks*gfg*is 
Explanation : Words sorted after separated by delim.

Input : test_str = 'gfg:is:best', delim = "*" 
Output : best*gfg*is 
Explanation : Words sorted after separated by delim. 
Method: Using sorted() + join() + split()
The combination of the above functions can be used to solve this problem. In this, we segregate all the words by a particular delimiter using split(), and convert to list, then perform the sort of words, then reconvert to string attaching by the same delimiter.
Python3
# Python3 code to demonstrate working of# Sort words separated by Delimiter# Using split() + join() + sorted() # initializing stringtest_str = 'gfg:is:best:for:geeks' # printing original stringprint("The original string is : " + str(test_str)) # initializing Delimiterdelim = ":" # joining the sorted string after splitres = delim.join(sorted(test_str.split(':'))) # printing resultprint("The sorted words : " + str(res))
The original string is : gfg:is:best:for:geeks
The sorted words : best:for:geeks:gfg:is
adnanirshad158
Python string-programs
Python
Python Programs
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
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers