code-rag-bench/online-tutorials huggingface dataset:
VB.Net - ScrollBar Control

The ScrollBar controls display vertical and horizontal scroll bars on the form. This is used for navigating through large amount of information. There are two types of scroll bar controls: HScrollBar for horizontal scroll bars and VScrollBar for vertical scroll bars. These are used independently from each other.
Let's click on HScrollBar control and VScrollBar control from the Toolbox and place them on the form.
The following are some of the commonly used properties of the ScrollBar control −
AutoSize
Gets or sets a value indicating whether the ScrollBar is automatically resized to fit its contents.
BackColor
Gets or sets the background color for the control.
ForeColor
Gets or sets the foreground color of the scroll bar control.
ImeMode
Gets or sets the Input Method Editor (IME) mode supported by this control.
LargeChange
Gets or sets a value to be added to or subtracted from the Value property when the scroll box is moved a large distance.
Maximum
Gets or sets the upper limit of values of the scrollable range.
Minimum
Gets or sets the lower limit of values of the scrollable range.
SmallChange
Gets or sets the value to be added to or subtracted from the Value property when the scroll box is moved a small distance.
Value
Gets or sets a numeric value that represents the current position of the scroll box on the scroll bar control.
The following are some of the commonly used methods of the ScrollBar control −
OnClick
Generates the Click event.
Select
Activates the control.
The following are some of the commonly used events of the ScrollBar control −
Click
Occurs when the control is clicked.
DoubleClick
Occurs when the user double-clicks the control.
Scroll
Occurs when the control is moved.
ValueChanged
Occurs when the Value property changes, either by handling the Scroll event or programmatically. 
In this example, let us create two scroll bars at runtime. Let's double click on the Form and put the follow code in the opened window.
Public Class Form1
   Private Sub Form1_Load(sender As Object, e As EventArgs) _
      Handles MyBase.Load
      
      'create two scroll bars
      Dim hs As HScrollBar
      Dim vs As VScrollBar
      hs = New HScrollBar()
      vs = New VScrollBar()
      
      'set properties
      hs.Location = New Point(10, 200)
      hs.Size = New Size(175, 15)
      hs.Value = 50
      vs.Location = New Point(200, 30)
      vs.Size = New Size(15, 175)
      hs.Value = 50
      
      'adding the scroll bars to the form
      Me.Controls.Add(hs)
      Me.Controls.Add(vs)
      ' Set the caption bar text of the form.  
      Me.Text = "tutorialspoint.com"
   End Sub
End Class
When the above code is executed and run using Start button available at the Microsoft Visual Studio tool bar, it will show the following window −

    63 Lectures 
     4 hours 

 Frahaan Hussain

    103 Lectures 
     12 hours 

 Arnold Higuit

    60 Lectures 
     9.5 hours 

 Arnold Higuit

    97 Lectures 
     9 hours 

 Arnold Higuit
 Print
 Add Notes
 Bookmark this page
Java program to check occurence of each character in String

In order to find occurrence of each character in a string we can use Map utility of Java.In Map, a key could not be duplicate so make each character of the string as the key of Map and provide an initial value corresponding to each key as 1 if this character does not insert in the map before. Now when a character repeats during insertion as key in Map increase its value by one. Continue this for each character until all characters of string get inserted.
public class occurenceOfCharacter {
   public static void main(String[] args) {
      String str = "SSDRRRTTYYTYTR";
      HashMap <Character, Integer> hMap = new HashMap<>();
      for (int i = str.length() - 1; i > = 0; i--) {
         if (hMap.containsKey(str.charAt(i))) {
            int count = hMap.get(str.charAt(i));
            hMap.put(str.charAt(i), ++count);
         } else {
            hMap.put(str.charAt(i),1);
         }
      }
      System.out.println(hMap);
   }
}
{D=1, T=4, S=2, R=4, Y=3}
C program for DFA accepting all strings over w ∈(a,b)* containing “aba” as a substring

Design a DFA for the language L={w1abaw2 | w1,w2 Є(a,b)*}, which means the DFA accepts all strings which contain “aba” as a substring.
The strings that are accepted by language L= {aba,aabaa, aabab, babab, ababa, .......}
Step 1 − Transition diagram for minimal string (starting string) −
If w1 and w2 are null then the string it generates is “aba” because w1, w2 ε(a,b)*
q0 is the initial state and q3 is the final state.
Step 2 − The final DFA for the given language is as follows −
qo is the initial state q0 on ‘a’ goes to q1 and on ‘b’ goes to q0, according to DFA each state has to generate a transition on both inputs.
qo is the initial state q0 on ‘a’ goes to q1 and on ‘b’ goes to q0, according to DFA each state has to generate a transition on both inputs.
q1 on ‘a’ goes to q1 and on ‘b’ goes to q2, we have to keep in mind according to the given language we need to generate a substring “aba”.
q1 on ‘a’ goes to q1 and on ‘b’ goes to q2, we have to keep in mind according to the given language we need to generate a substring “aba”.
q2 on ‘a’ goes on q3 on ‘b’ goes to q0 state.
q2 on ‘a’ goes on q3 on ‘b’ goes to q0 state.
q3 which is the final state, on input ‘a’ and ‘b’ goes to q3 only.
q3 which is the final state, on input ‘a’ and ‘b’ goes to q3 only.
Let’s see the transition table as follows −
Following is the C program for construction of DFA accepting all strings over w ε(a,b)* which contains “aba” as a substring -
 Live Demo
#include <stdio.h>
#include <string.h>
void checkDFA(char s[] ) {
   // storing initial state
   int initialState = 0;
   //assign initial state to previous state.
   int previousState = initialState;
   int finalState;
   for(int i = 0; i < strlen(s); i++)    {
      if((previousState == 0 && s[i] == 'a') || (previousState == 1 && s[i] == 'a')) {
         finalState = 1;
      }
      if((previousState == 0 && s[i] == 'b') || (previousState == 2 && s[i] == 'b')) {
         finalState = 0;
      }
      if(previousState == 1 && s[i] == 'b') {
         finalState = 2;
      }
      if((previousState == 2 && s[i] == 'a') || (previousState == 3)) {
         finalState = 3;
      }
      previousState = finalState;
   }
   if(finalState == 3) {
      printf("given string is Accepted");
   }
   else
   {
      printf("given string is Not Accepted");
   }
}
int main() {
   // Given string
   char s[40];
   printf("implementation of DFA which having a sub string 'aba':\n enter a string:");
   scanf("%s",s);
   checkDFA(s);
   return 0;
}
The output is as follows −
Run 1:
implementation of DFA which having a sub string 'aba':
enter a string:aba
given string is Accepted.
Run 2:
implementation of DFA which having a sub string 'aba':
enter a string:abba
given string is Not Accepted.
How to get current date/time in milli seconds in Java?

The getTime() method of the Date class retrieves and returns the epoch time (number of milliseconds from Jan 1st 1970 00:00:00 GMT0.
Live Demo
import java.util.Date;
public class Sample {
   public static void main(String args[]){  
      //Instantiating the Date class
      Date date = new Date();
      long msec = date.getTime();
      System.out.println("Milli Seconds: "+msec);
   }
}
Milli Seconds: 1605160094688
Milli Seconds: 1605160094688
The getTimeInMillis() method of the calendar class retrieves and returns the time in milli seconds from the epochepoch time (Jan 1st 1970 00:00:00 GMT).
Live Demo
import java.util.Calendar;
public class Sample {
   public static void main(String args[]){  
      //Creating the Calendar object
      Calendar cal = Calendar.getInstance();
      long msec = cal.getTimeInMillis();
      System.out.println("Milli Seconds: "+msec);
   }
}
Milli Seconds: 1605160934357
Milli Seconds: 1605160934357
The toEpochMilli() method of the Instant class  returns the milliseconds from the epoch.
Live Demo
import java.time.Instant;
import java.time.ZonedDateTime;
public class Sample {
   public static void main(String args[]){  
      //Creating the ZonedDateTime object
      ZonedDateTime obj = ZonedDateTime.now();
      Instant instant = obj.toInstant();
      long msec = instant.toEpochMilli();
      System.out.println("Milli Seconds: "+msec);
   }
}
Milli Seconds: 1605162474464
Milli Seconds: 1605162474464
Add list elements with a multi-list based on index in Python

Lists can be nested. Which means we have smaller lists as elements inside a bigger list. In this article we solve the challenge of adding the elements of a simple list to the elements of a nested list. If the length of the lists are different then the length of the smaller list becomes the maximum length of the resulting list.
Below are the various methods to accomplish this.
In this method, we take the length of the smaller list and loop through the elements of this list adding it to the elements of the bigger list. Here we use the append function to append each element into the result list.
 Live Demo
simple_list = [25, 35, 45, 55, 65]
nested_list = [[5,10], [10], [5,15], [25], [5,10,15],[5,6]]
result_list = []

for n in range(len(simple_list)):
   var = []
   for m in nested_list[n]:
      var.append(m + simple_list[n])
   result_list.append(var)
print("The first list :", simple_list)
print("The nested list :", nested_list)
print("Result :",result_list)
Running the above code gives us the following result −
The first list : [25, 35, 45, 55, 65]
The nested list : [[5, 10], [10], [5, 15], [25], [5, 10, 15], [5, 6]]
Result : [[30, 35], [45], [50, 60], [80], [70, 75, 80]]
The enumerate() function takes a collection like list or tuple and returns it as an enumerate object. In this approach we first create an outer for loop having the enumerate function to get each element of the nested list and then add them to the respective elements in the simple list through an inner for loop.
 Live Demo
simple_list = [25, 35, 45, 55, 65,25]
nested_list = [[5,10], [10], [5,15], [25], [5,10,15]]
result_list = []

# using enumerate
result_list = [[val + simple_list[p] for val in q] for p, q in enumerate(nested_list)]
print("The first list :", simple_list)
print("The nested list :", nested_list)
print("Result :",result_list)
Running the above code gives us the following result −
The first list : [25, 35, 45, 55, 65, 25]
The nested list : [[5, 10], [10], [5, 15], [25], [5, 10, 15]]
Result : [[30, 35], [45], [50, 60], [80], [70, 75, 80]]
In this approach we repeat the above program but using zip () instead of enumerate. The zip() takes in both the lists as its input.
 Live Demo
simple_list = [25, 35, 45, 55, 65,25]
nested_list = [[5,10], [10], [5,15], [25], [5,10,15]]
result_list = []

result_list = [[w + u for w in v ]for u, v in zip(simple_list, nested_list)]

print("The first list :", simple_list)
print("The nested list :", nested_list)
print("Result :",result_list)
Running the above code gives us the following result −
The first list : [25, 35, 45, 55, 65, 25]
The nested list : [[5, 10], [10], [5, 15], [25], [5, 10, 15]]
Result : [[30, 35], [45], [50, 60], [80], [70, 75, 80]]
D3.js selection.classed() Function - GeeksforGeeks

06 Sep, 2020
The selection.classed() function is used to set the class to the selected element. This function can also be used to unset the class to a particular element that is selected.
Syntax:
selection.classed(names[, value]);

Parameters: The above-given function takes two parameters which are given above and described below:
name: It is the name of the class to be given to the element that is selected.
value: It is the boolean value i.e true or false to set or unset the class.
Return Values: This function does not return anything.
Example 1: Setting the class name.
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" path1tent="width=device-width,                     initial-scale=1.0">    <script src="https://d3js.org/d3.v4.min.js">    </script></head>  <body>    <div>        <a>GeeksforGeeks</a>    </div>      <script>          // Sets the class to the a tag        var a = d3.select("a")            .classed("className", true);                  // This will select the anchor tag        var divselect = document.querySelector(".className");        console.log(divselect.innerHTML);    </script></body>  </html>
Output:
GeeksforGeeks
Example 2: Unset the class name.
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" path1tent="width=device-width,                     initial-scale=1.0">    <script src="https://d3js.org/d3.v4.min.js">    </script></head>  <body>    <div>        <p class="classGiven classGiven2">            GeeksforGeeks        </p>    </div>      <script>          // Unsets the class named classGiven        // to the "p" tag        var a = d3.select("p")            .classed("classGiven2", false);          // This will select the "p" tag        var divselect = document            .querySelector(".classGiven");                      console.log(divselect.innerHTML);          // This will not select the "p" tag        // As the classGiven 2 is unset                  var divselect = document            .querySelector(".classGiven2");          console.log(divselect);    </script></body>  </html>
Output:
GeeksforGeeks
null
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
How to Open URL in New Tab using JavaScript ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Python program to find the highest 3 values in a dictionary

25 Aug, 2021
Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds key:value pair.
Examples: 
Input : my_dict = {'A': 67, 'B': 23, 'C': 45,
                   'D': 56, 'E': 12, 'F': 69} 

Output : {'F': 69, 'A': 67, 'D': 56}
Let’s see different methods we can find the highest 3 values in a dictionary.   Method #1: Using collections.Counter()A Counter is a dict subclass for counting hashable objects. It is an unordered collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any integer value including zero or negative counts. The Counter class is similar to bags or multisets in other languages.most_common([n]) returns a list of the n most common elements and their counts from the most common to the least. 
Python3
# Python program to demonstrate# finding 3 highest values in a Dictionary from collections import Counter # Initial Dictionarymy_dict = {'A': 67, 'B': 23, 'C': 45,           'D': 56, 'E': 12, 'F': 69} k = Counter(my_dict) # Finding 3 highest valueshigh = k.most_common(3) print("Initial Dictionary:")print(my_dict, "\n")  print("Dictionary with 3 highest values:")print("Keys: Values") for i in high:    print(i[0]," :",i[1]," ")
Initial Dictionary:
{'C': 45, 'B': 23, 'D': 56, 'A': 67, 'E': 12, 'F': 69} 

Dictionary with 3 highest values:
Keys: Values
F  : 69  
A  : 67  
D  : 56
 
Method #2: Using heapq.nlargest()
Python3
# Python program to demonstrate# finding 3 highest values in a Dictionaryfrom heapq import nlargest # Initial Dictionarymy_dict = {'A': 67, 'B': 23, 'C': 45,           'D': 56, 'E': 12, 'F': 69} print("Initial Dictionary:")print(my_dict, "\n") ThreeHighest = nlargest(3, my_dict, key = my_dict.get) print("Dictionary with 3 highest values:")print("Keys: Values") for val in ThreeHighest:    print(val, ":", my_dict.get(val))
Initial Dictionary:
{'D': 56, 'E': 12, 'F': 69, 'C': 45, 'B': 23, 'A': 67} 

Dictionary with 3 highest values:
Keys: Values
F : 69
A : 67
D : 56
 
anikakapoor
Python dictionary-programs
python-dict
Python
Python Programs
python-dict
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 | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
C# Program to Get and Print the Command Line Arguments Using Environment Class

01 Nov, 2021
In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since the last system boot in milliseconds information. By just using some predefined methods we can get the information of the Operating System using the Environment class. In this article, we will discuss how to get and display the command line arguments using the Environment class. So to do this task we use the CommandLine property of the Environment Class. This property is used to find the command line for the current process.
Syntax:
Environment.CommandLine
Return Type: The return type of this property is a string. This string represents the command-line arguments.
Example:
Input  : Hello Geeks
Output : Hello Geeks

Input  : Hello 123
Output : Hello 123
C#
// C# program to display the command line arguments// using Environment Classusing System;  class GFG{  static public void Main(){          // Declaring a string variable    string commandlineResult = "";          // Getting the command line argument    // Using the CommandLine property of     // Environment class    commandlineResult = Environment.CommandLine;          // Display the data    Console.WriteLine("Command Line Data: \n" +                       commandlineResult);}}
Output:
E:\> example.exe Hello Geeks
Command Line Data:
example.exe Hello Geeks
CSharp-programs
Picked
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
Extension Method in C#
C# | List Class
C# | .NET Framework (Basic Architecture and Component Stack)
HashSet in C# with Examples
Switch Statement in C#
Lambda Expressions in C#
Partial Classes in C#
Hello World in C#
VBScript Split Function

A Split Function returns an array that contains a specific number of values split based on a Delimiter.
Split(expression[,delimiter[,count[,compare]]]) 

expression, a Required parameter. The String Expression that can contain strings with delimiters.
expression, a Required parameter. The String Expression that can contain strings with delimiters.
delimiter, an Optional Parameter. The Parameter, which is used to convert into arrays based on a delimiter.
delimiter, an Optional Parameter. The Parameter, which is used to convert into arrays based on a delimiter.
count, an Optional Parameter. The number of substrings to be returned, and if specified as -1, then all the substrings are returned.
count, an Optional Parameter. The number of substrings to be returned, and if specified as -1, then all the substrings are returned.
compare, an Optional Parameter. This parameter specifies which comparison method to be used.

0 = vbBinaryCompare - Performs a binary comparison
1 = vbTextCompare - Performs a textual comparison


compare, an Optional Parameter. This parameter specifies which comparison method to be used.
0 = vbBinaryCompare - Performs a binary comparison
0 = vbBinaryCompare - Performs a binary comparison
1 = vbTextCompare - Performs a textual comparison
1 = vbTextCompare - Performs a textual comparison
<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         ' Splitting based on delimiter comma '$'
         a = Split("Red $ Blue $ Yellow","$")
         b = ubound(a)
         
         For i = 0 to b
            document.write("The value of array in " & i & " is :"  & a(i)& "<br />")
         Next

      </script>
   </body>
</html>
When the above code is saved as .HTML and executed in Internet Explorer, it produces the following result−
The value of array in 0 is :Red 
The value of array in 1 is : Blue 
The value of array in 2 is : Yellow
Neo4j - Unwind Clause

The unwind clause is used to unwind a list into a sequence of rows.
Following is a sample Cypher Query which unwinds a list.
UNWIND [a, b, c, d] AS x 
RETURN x 
To execute the above query, carry out the following steps −
Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot.
Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot.
On executing, you will get the following result.
 Print
 Add Notes
 Bookmark this page
Difference between HTML and CSS - GeeksforGeeks

28 Jul, 2020
HTMLHTML stands for Hyper Text Markup Language and it is the language which is used to define the structure of a web page. HTML is used along with CSS and Java script to design web pages. HTML is the basic building block of a website. It has different attributes and elements with different properties.Each element has a opening and a closing tag. We can also add images by the help of HTML.Example:<html><body>    <h1>Welcome to GeeksForGeeks</h1></body></html>Output:
<html><body>    <h1>Welcome to GeeksForGeeks</h1></body></html>
Output:
CSS:CSS stands for Cascading Style Sheets and it is used to style web documents. It is used to provide the background color and is also used for styling. It can also be used to style the font and change its size. We can also style many different web pages with the same specifications by the help of CSS. CSS is also recommended by World Wide Web Consortium (W3C). It can also be used along with HTML and Java script to design web pages.Example:<html><head><style>body {  background-color:red;}</style></head><body>  <h1>Welcome to GeeksForGeeks!</h1>  <p>This page has red background color</p>  </body></html>Output:
<html><head><style>body {  background-color:red;}</style></head><body>  <h1>Welcome to GeeksForGeeks!</h1>  <p>This page has red background color</p>  </body></html>
Output:
Difference between HTML and CSS:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Basics
HTML-Basics
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
C# - Anonymous Methods

We discussed that delegates are used to reference any methods that has the same signature as that of the delegate. In other words, you can call a method that can be referenced by a delegate using that delegate object.
Anonymous methods provide a technique to pass a code block as a delegate parameter. Anonymous methods are the methods without a name, just the body.
You need not specify the return type in an anonymous method; it is inferred from the return statement inside the method body.
Anonymous methods are declared with the creation of the delegate instance, with a delegate keyword. For example,
delegate void NumberChanger(int n);
...
NumberChanger nc = delegate(int x) {
   Console.WriteLine("Anonymous Method: {0}", x);
};

The code block Console.WriteLine("Anonymous Method: {0}", x); is the body of the anonymous method.
The delegate could be called both with anonymous methods as well as named methods in the same way, i.e., by passing the method parameters to the delegate object.
For example,
nc(10);

The following example demonstrates the concept −
using System;

delegate void NumberChanger(int n);
namespace DelegateAppl {
   class TestDelegate {
      static int num = 10;
      
      public static void AddNum(int p) {
         num += p;
         Console.WriteLine("Named Method: {0}", num);
      }
      public static void MultNum(int q) {
         num *= q;
         Console.WriteLine("Named Method: {0}", num);
      }
      public static int getNum() {
         return num;
      }
      static void Main(string[] args) {
         //create delegate instances using anonymous method
         NumberChanger nc = delegate(int x) {
            Console.WriteLine("Anonymous Method: {0}", x);
         };
         
         //calling the delegate using the anonymous method 
         nc(10);
         
         //instantiating the delegate using the named methods 
         nc =  new NumberChanger(AddNum);
         
         //calling the delegate using the named methods 
         nc(5);
         
         //instantiating the delegate using another named methods 
         nc =  new NumberChanger(MultNum);
         
         //calling the delegate using the named methods 
         nc(2);
         Console.ReadKey();
      }
   }
}
When the above code is compiled and executed, it produces the following result −
Anonymous Method: 10
Named Method: 15
Named Method: 30


    119 Lectures 
     23.5 hours 

 Raja Biswas

    37 Lectures 
     13 hours 

 Trevoir Williams

    16 Lectures 
     1 hours 

 Peter Jepson

    159 Lectures 
     21.5 hours 

 Ebenezer Ogbu

    193 Lectures 
     17 hours 

 Arnold Higuit

    24 Lectures 
     2.5 hours 

 Eric Frick
 Print
 Add Notes
 Bookmark this page
How to resolve ‘node’ is not recognized as an internal or external command error after installing Node.js ?

10 Jul, 2020
There are many different ways to install node.js on a computer. The simplest method to verify whether node.js has been properly installed in your computer is simply type node-v in the command prompt or Windows PowerShell.
But many times, it happens, most commonly if you’re a beginner, the command prompt prints the output something like this:
'node' is not recognized as an internal or external command,
operable program or batch file.

This is the most common error and it is very simple to resolve this. It might be a case that the user might have properly installed node from the official node website. But sometimes, the reason is that the path variable is not defined in your system. So to properly define a path variable and resolve this error, follow these simple steps:
Open the Environment Variables option in your Control Panel. (Go to Control Panel -> System and Security ->System -> Advanced System Settings-> Environment Variables ->User Variables or System Variables.)Select the variable named Path. A dialogue box named Edit user variable will appear. In the variable value option inside that dialogue box, paste the complete path of the location where node.js is installed in your system.Then click on OK.Restart the command prompt again and now verify by typing node-v in the command prompt. It will now display the version of the node which you’ve installed from the internet .
Open the Environment Variables option in your Control Panel. (Go to Control Panel -> System and Security ->System -> Advanced System Settings-> Environment Variables ->User Variables or System Variables.)
Select the variable named Path. A dialogue box named Edit user variable will appear. In the variable value option inside that dialogue box, paste the complete path of the location where node.js is installed in your system.Then click on OK.
Restart the command prompt again and now verify by typing node-v in the command prompt. It will now display the version of the node which you’ve installed from the internet .
Node.js-Misc
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
mkdir command in Linux with Examples

08 Sep, 2021
mkdir command in Linux allows the user to create directories (also referred to as folders in some operating systems ). This command can create multiple directories at once as well as set the permissions for the directories. It is important to note that the user executing this command must have enough permissions to create a directory in the parent directory, or he/she may receive a ‘permission denied’ error. 
Syntax: 
mkdir [options...] [directories ...]
–version: It displays the version number, some information regarding the license and exits. Syntax: 
mkdir --version
Output: 
–help: It displays the help related information and exits. Syntax: 
mkdir --help
Output: 
-v or –verbose: It displays a message for every directory created. Syntax: 
mkdir -v [directories]
Output: 
-p: A flag which enables the command to create parent directories as necessary. If the directories exist, no error is specified. Syntax: 
Syntax: 
mkdir -p [directories]
Suppose you execute the following command – 
mkdir -p first/second/third
If the first and second directories do not exist, due to the -p option, mkdir will create these directories for us. If we do not specify the -p option, and request the creation of directories, where parent directory doesn’t exist, we will get the following output – 
If we specify the -p option, the directories will be created, and no error will be reported. Following is the output of one such execution. We’ve also provided the -v option, so that we can see it in action. Output: 
-m: This option is used to set the file modes, i.e. permissions, etc. for the created directories. The syntax of the mode is the same as the chmod command. Syntax: 
Syntax: 
mkdir -m a=rwx [directories]
The above syntax specifies that the directories created give access to all the users to read from, write to and execute the contents of the created directories. You can use ‘a=r’ to only allow all the users to read from the directories and so on. Output:  
sweetyty
linux-command
Linux-directory-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
tar command in Linux with examples
curl command in Linux with Examples
Conditional Statements | Shell Script
TCP Server-Client implementation in C
Tail command in Linux with examples
Docker - COPY Instruction
scp command in Linux with Examples
UDP Server-Client implementation in C
echo command in Linux with Examples
Split Pandas Dataframe by Column Index

29 Aug, 2020
Pandas support two data structures for storing data the series (single column) and dataframe where values are stored in a 2D table (rows and columns).  To index  a  dataframe using the index we need to make use of dataframe.iloc() method which takes 
Syntax: pandas.DataFrame.iloc[]
Parameters:Index Position: Index position of rows in integer or list of integer.
Return type: Data frame or Series depending on parameters
Let’s create a dataframe. In the below example we will use a simple binary dataset used to classify if a species is a mammal or reptile. The species column holds the labels where 1 stands for mammal and 0 for reptile. The data is stored in the dict which can be passed to the DataFrame function outputting a dataframe.
Python3
import pandas as pd  dataset = {'toothed': [1, 1, 1, 0, 1, 1, 1, 1, 1, 0],           'hair': [1, 1, 0, 1, 1, 1, 0, 0, 1, 0],           'breathes': [1, 1, 1, 1, 1, 1, 0, 1, 1, 1],           'legs': [1, 1, 0, 1, 1, 1, 0, 0, 1, 1],           'species': [1, 1, 0, 1, 1, 1, 0, 0, 1, 0]           }  df = pd.DataFrame(dataset)  df.head()
Output :
output of head()
Example 1: Now we would like to separate species columns from the feature columns (toothed, hair, breathes, legs) for this we are going to make use of the iloc[rows, columns] method offered by pandas. 
Here ‘:’ stands for all the rows and -1 stands for the last column so the below cell is going to take the all the rows and all columns except the last one (‘species’) as can be seen in the output:
Python3
X = df.iloc[:,:-1]X
Output: 
To split the species column from the rest of the dataset we make you of a similar code except in the cols position instead of padding a slice we pass in an integer value -1.
Python3
Y = df.iloc[:,-1]Y
Output : 
Example 2: Splitting using list of integers 
Similar output can be obtained by passing in a list of integers instead of a slice 
Python3
X = df.iloc[:,[0,1,2,3]]X
Output:
To the species column we are going to use the index of the column which is 4 we can use -1 as well 
Python3
Y = df.iloc[:,4]Y
Output:
Example 3: Splitting dataframes into 2 separate dataframes 
In the above two examples, the output for Y was a Series and not a dataframe Now we are going to split the dataframe into two separate dataframe’s this can be useful when dealing with multi-label datasets. Will be using the same dataset. 
In the first, we are going to split at column hair 
Python3
df.iloc[:,[0,1]]
Output:
The second dataframe will contain 3 columns breathes , legs , species 
Python3
df.iloc[:,[2,3,4]] 
Output:
Python pandas-dataFrame
Python Pandas-exercise
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# - Passing Parameters by Value

This is the default mechanism for passing parameters to a method. In this mechanism, when a method is called, a new storage location is created for each value parameter.
The values of the actual parameters are copied into them. Hence, the changes made to the parameter inside the method have no effect on the argument. The following example demonstrates the concept −
using System;

namespace CalculatorApplication {
   class NumberManipulator {
      public void swap(int x, int y) {
         int temp;
         
         temp = x; /* save the value of x */
         x = y;    /* put y into x */
         y = temp; /* put temp into y */
      }
      static void Main(string[] args) {
         NumberManipulator n = new NumberManipulator();
         
         /* local variable definition */
         int a = 100;
         int b = 200;
         
         Console.WriteLine("Before swap, value of a : {0}", a);
         Console.WriteLine("Before swap, value of b : {0}", b);
         
         /* calling a function to swap the values */
         n.swap(a, b);
         
         Console.WriteLine("After swap, value of a : {0}", a);
         Console.WriteLine("After swap, value of b : {0}", b);
         
         Console.ReadLine();
      }
   }
}
When the above code is compiled and executed, it produces the following result −
Before swap, value of a :100
Before swap, value of b :200
After swap, value of a :100
After swap, value of b :200

It shows that there is no change in the values though they had changed inside the function.

    119 Lectures 
     23.5 hours 

 Raja Biswas

    37 Lectures 
     13 hours 

 Trevoir Williams

    16 Lectures 
     1 hours 

 Peter Jepson

    159 Lectures 
     21.5 hours 

 Ebenezer Ogbu

    193 Lectures 
     17 hours 

 Arnold Higuit

    24 Lectures 
     2.5 hours 

 Eric Frick
 Print
 Add Notes
 Bookmark this page
Variable number of arguments in C++

Sometimes, you may come across a situation, when you want to have a function, which can take variable number of arguments, i.e., parameters, instead of predefined number of parameters. The C/C++ programming language provides a solution for this situation and you are allowed to define a function which can accept variable number of parameters based on your requirement. The following example shows the definition of such a function.
int func(int, ... ) {
   .
   .
   .
}
int main() {
   func(1, 2, 3);
   func(1, 2, 3, 4);
}
It should be noted that the function func() has its last argument as ellipses, i.e. three dotes (...) and the one just before the ellipses is always an int which will represent the total number variable arguments passed. To use such functionality, you need to make use of stdarg.h header file which provides the functions and macros to implement the functionality of variable arguments and follow the given steps −
Define a function with its last parameter as ellipses and the one just before the ellipses is always an int which will represent the number of arguments.
Define a function with its last parameter as ellipses and the one just before the ellipses is always an int which will represent the number of arguments.
Create a va_list type variable in the function definition. This type is defined in stdarg.h header file.
Create a va_list type variable in the function definition. This type is defined in stdarg.h header file.
Use int parameter and va_start macro to initialize the va_list variable to an argument list. The macro va_start is defined in stdarg.h header file.
Use int parameter and va_start macro to initialize the va_list variable to an argument list. The macro va_start is defined in stdarg.h header file.
Use va_arg macro and va_list variable to access each item in argument list.
Use va_arg macro and va_list variable to access each item in argument list.
Use a macro va_end to clean up the memory assigned to va_list variable.
Use a macro va_end to clean up the memory assigned to va_list variable.
Now let us follow the above steps and write down a simple function which can take the variable number of parameters and return their average −
 Live Demo
#include <iostream>
#include <cstdarg>
using namespace std;
double average(int num,...) {
   va_list valist;
   double sum = 0.0;
   int i;
   va_start(valist, num); //initialize valist for num number of arguments
   for (i = 0; i < num; i++) { //access all the arguments assigned to valist
      sum += va_arg(valist, int);
   }
   va_end(valist); //clean memory reserved for valist
   return sum/num;
}
int main() {
   cout << "Average of 2, 3, 4, 5 = "<< average(4, 2,3,4,5) << endl;
   cout << "Average of 5, 10, 15 = "<< average(3, 5,10,15)<< endl;
}
Average of 2, 3, 4, 5 = 3.5
Average of 5, 10, 15 = 10
Looping through the content of a file in Bash

Often it is a requirement to read each of the line from a file using a bash script. There are various approaches to read the lines form a file. In the below example we have first described how to create a sample file and then run a script reading that sample file.
# Open vi Editor
vi a_file.txt
# Input the below lines
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
# cat the file
cat a_file.txt
Running the above code gives us the following result −
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
In this approach we use a do-while loop to read a file. We give the file name as an input at the end of the file. First we create a script and give the execute permission to it. Then only it can read the file and show the result.
#!/bin/bash
while read LINE
do echo "$LINE"
done < a_file.txt
Running the above code gives us the following result −
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
In next approach we use a for loop along with the in clause. Here we store the result of cat command (which is each line) in a variable which is part of for loop and echo the variable.
#!/bin/bash
file=a_file.txt
for i in `cat $file`
do
echo "$i"
done
Running the above code gives us the following result −
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
We can also get the content of the file by using only echo. But the result will come out as an array of lines and printed out as one-line output showing combination of all the lines.
echo $( < a_file.txt )
Running the above code gives us the following result:
Monday Tuesday Wednesday Thursday Friday Saturday Sunday
If a file has some lines which are blank then we ca avoid them in the output by using the following code. This uses the IFS (internal Field Separator) is set to empty string so that the blank lines are treated as field separator and avoided in the output. Assuming there are blank lines between 3rd and 4th line, those blank liens will not be printed.
#!/bin/bash
while IFS = read -r LINE
do echo "$LINE"
done < a_file.txt
Running the above code gives us the following result −
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
How to get the list of local groups using PowerShell?

To get the local groups on the windows system using PowerShell, you can use the Get-LocalGroup (Module: Microsoft.PowerShell.LocalAccounts) command. This command will list down all the groups on the particular system.
If we check the properties of this command, it supports Name, Description, ObjectClass (user or group), PrincipalSource (ComputerName – Local or Remote), SID (Security Identifier).
We will select them,
PS C:\> Get-LocalGroup | Select Name, Objectclass, Principalsource,sid
Name                                              ObjectClass PrincipalSource    SID
----                                              -----------  ---------------   ---
LocalAdminGroup                                     Group                         S-1-5-21-
3679408808-4189780139-2861908768-1003
Access Control Assistance Operators                 Group                         S-1-5-32-579
Administrators                                      Group                         S-1-5-32-544
Backup Operators                                    Group                         S-1-5-32-551
Certificate Service DCOM Access                     Group                         S-1-5-32-574
Cryptographic Operators                             Group                         S-1-5-32-569
Distributed COM Users                               Group                         S-1-5-32-562
Event Log Readers                                   Group                         S-1-5-32-573
Guests                                              Group                         S-1-5-32-546
Hyper-V Administrators                              Group                         S-1-5-32-578
IIS_IUSRS                                           Group                         S-1-5-32-568
You can retrieve the Local Groups information on the remote system using the Invoke-Command method.
Invoke-Command -ComputerName Test1-Win2k16 -ScriptBlock{ Get-LocalGroup}
Please note − This command supports from the PS version 5.1 onwards. For the earlier versions, we can use the cmd command “Net LocalGroup”. For example,
PS C:\Users\Administrator> net localgroup
Aliases for \\ADDC
------------------------------------------------------------------
*Access Control Assistance Operators
*Account Operators
*Administrators
*Allowed RODC Password Replication Group
*Backup Operators
*Cert Publishers
*Certificate Service DCOM Access
*Cryptographic Operators
*Denied RODC Password Replication Group
*Distributed COM Users
*DnsAdmins
*Event Log Readers
*Guests
*Hyper-V Administrators
*IIS_IUSRS
*Incoming Forest Trust Builders
*LocalAdminGroup
*Network Configuration Operators
*Performance Log Users
*Performance Monitor Users
*Pre-Windows 2000 Compatible Access
*Print Operators
*RAS and IAS Servers
*RDS Endpoint Servers
On the remote server,
Invoke-Command -ComputerName Test1-Win2k16 -ScriptBlock{Net localgroup}
Please note − To run the above command, Remote servers must use the PowerShell version 5.1 or the advanced.
How to remove the outline of an oval in Tkinter?

With Tkinter canvas, we can draw shapes for 2D or 3D applications, we can create images, draw animation, and many more things. Let us suppose that we have to create an oval that should be drawn aesthetically on the canvas. There can be other features that can be present to give the oval and other shapes an aesthetic look. To remove the outlining from the shapes in the canvas, we can provide an empty value to the outline property in the method.
#Import tkinter library
from tkinter import *
#Create an instance of tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
win.geometry("750x350")
#Create a canvas and an oval
canvas= Canvas(win, width=400, height=350,bg= "#458a4a")
canvas.create_oval(50,50,250,250, fill="white", outline="")
canvas.pack()
win.mainloop()
Now, execute the code to display the output that contains an oval inside the canvas.
Program to calculate value of nCr in C++

Given with n C r, where C represents combination, n represents total numbers and r represents selection from the set, the task is to calculate the value of nCr.
Combination is the selection of data from the given in a without the concern of arrangement. Permutation and combination differs in the sense that permutation is the process of arranging whereas combination is the process of selection of elements from the given set.
Formula for permutation is -:
nPr = (n!)/(r!*(n-r)!)
Input-: n=12 r=4
Output-: value of 12c4 is :495
Start
Step 1 -> Declare function for calculating factorial
   int cal_n(int n)
   int temp = 1
   Loop for int i = 2 and i <= n and i++
      Set temp = temp * i
   End
   return temp
step 2 -> declare function to calculate ncr
   int nCr(int n, int r)
      return cal_n(n) / (cal_n(r) * cal_n(n - r))
step 3 -> In main()
   declare variable as int n = 12, r = 4
   print nCr(n, r)
Stop
#include <bits/stdc++.h>
using namespace std;
//it will calculate factorial for n
int cal_n(int n){
   int temp = 1;
   for (int i = 2; i <= n; i++)
      temp = temp * i;
   return temp;
}
//function to calculate ncr
int nCr(int n, int r){
   return cal_n(n) / (cal_n(r) * cal_n(n - r));
}
int main(){
   int n = 12, r = 4;
   cout <<"value of "<<n<<"c"<<r<<" is :"<<nCr(n, r);
   return 0;
}
value of 12c4 is :495
How to find the size of a variable without using sizeof in C#?

To get the size of a variable, sizeof is used.
int x;
x = sizeof(int);
To get the size of a variable, without using the sizeof, try the following code −
// without using sizeof
byte[] dataBytes = BitConverter.GetBytes(x);
int d = dataBytes.Length;
Here is the complete code.
 Live Demo
using System;
class Demo {
   public static void Main() {
      int x;
      // using sizeof
      x = sizeof(int);
      Console.WriteLine(x);
      // without using sizeof
      byte[] dataBytes = BitConverter.GetBytes(x);
      int d = dataBytes.Length;
      Console.WriteLine(d);
   }
}
4
4
Function pointer to member function in C++

In C++ , function pointers when dealing with member functions of classes or structs, it is invoked using an object pointer or a this call. We can only call members of that class (or derivatives) using a pointer of that type as they are type safe.
 Live Demo
#include <iostream>
using namespace std;
class AB {
   public:
      int sub(int a, int b) {
         return a-b;
      }
      int div(int a, int b) {
         return a/b;
      }
};
//using function pointer
int res1(int m, int n, AB* obj, int(AB::*fp)(int,int)) {
   return (obj->*fp)(m,n);
}
//using function pointer
int res2(int m, int n, AB* obj, int(AB::*fp2)(int,int)) {
   return (obj->*fp2)(m,n);
}
int main() {
   AB ob;
   cout << "Subtraction is = " << res1(8,5, &ob, &AB::sub) << endl;
   cout << "Division is = " << res2(4,2, &ob, &AB::div) << endl;
   return 0;
}
Subtraction is = 3
Division is = 2