code-rag-bench/online-tutorials huggingface dataset:
What is the difference between Dictionary and HashTable in PowerShell?

PowerShell programmers generally prefer the Hashtable over the Dictionary although there are some advantages of using Dictionary. See the difference below.
a. Hashtable is easy to declare while the Dictionary is a little complex compared to Hashtable. For example,
To create a hashtable,
$hash = @{
   'Country' = 'India'
   'Code' = '91'
}
To create a Dictionary,
$citydata = New-Object System.Collections.Generic.Dictionary"[String,Int]"
$citydata.Add('India',91) 
b. Hashtable is included in the namespace called Collections while Dictionary is included in the namespace called System.Collections.Generic namespace. Hashtable is non-generic so it can be a collection of different data types and Dictionary belongs to a generic class so it is a collection of specific data types.
c. Hashtable and Dictionary both have the BaseType is Object but their datatypes are different. Hashtable has a ‘Hashtable’ datatype and Dictionary has a Dictionary`2 datatype.
Hashtable:
IsPublic IsSerial Name      BaseType
-------- -------- ----      --------
True     True     Hashtable System.Object
Dictionary:
IsPublic IsSerial Name         BaseType
-------- -------- ----         --------
True     True     Dictionary`2 System.Object
ios manipulators showpoint() function in C++ - GeeksforGeeks

28 Aug, 2019
The showpoint() method of stream manipulators in C++ is used to set the showpoint format flag for the specified str stream. This flag always displays the floating point values along with their decimal values.
Syntax:
ios_base& showpoint (ios_base& str)

Parameters: This method accepts str as a parameter which is the stream for which the format flag is affected.
Return Value: This method returns the stream str with showpoint format flag set.
Example 1:
// C++ code to demonstrate// the working of showpoint() function  #include <iostream>  using namespace std;  int main(){      // Initializing the floating values    double n1 = 10;    double n2 = 20.0;      cout.precision(5);      // Using showpoint()    cout << "showpoint flag: "         << showpoint         << n1 << endl         << n2 << endl;      return 0;}
showpoint flag: 10.000
20.000

Example 2:
// C++ code to demonstrate// the working of showpoint() function  #include <iostream>  using namespace std;  int main(){      // Initializing the floating values    double n3 = 30.1223;      cout.precision(5);      // Using showpoint()    cout << "showpoint flag: "         << showpoint         << n3 << endl;      return 0;}
showpoint flag: 30.122

Reference: http://www.cplusplus.com/reference/ios/showpoint/
cpp-ios
cpp-manipulators
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Convert string to char array in C++
Iterators in C++ STL
Inline Functions in C++
List in C++ Standard Template Library (STL)
Multithreading in C++
How to find strings with a given prefix in MySQL?

You can use LIKE operator to find strings with a given prefix.
The syntax is as follows
select *from yourTableName where yourColumnName LIKE 'yourPrefixValue%';
To understand the above syntax, let us create a table. The query to create a table is as follows
mysql> create table findStringWithGivenPrefixDemo
   -> (
   -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> UserMessage text
   -> );
Query OK, 0 rows affected (0.82 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into findStringWithGivenPrefixDemo(UserMessage) values('Hi Good Morning !!!');
Query OK, 1 row affected (0.17 sec)
mysql> insert into findStringWithGivenPrefixDemo(UserMessage) values('Hey I am busy!!');
Query OK, 1 row affected (0.20 sec)
mysql> insert into findStringWithGivenPrefixDemo(UserMessage) values('Hello what are you doing!!!');
Query OK, 1 row affected (0.47 sec)
mysql> insert into findStringWithGivenPrefixDemo(UserMessage) values('Hi I am learning MongoDB!!!');
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from findStringWithGivenPrefixDemo;
The following is the output
+--------+-----------------------------+
| UserId | UserMessage                 |
+--------+-----------------------------+
| 1      | Hi Good Morning !!!         |
| 2      | Hey I am busy!!             |
| 3      | Hello what are you doing!!! |
| 4      | Hi I am learning MongoDB!!! |
+--------+-----------------------------+
4 rows in set (0.00 sec)
Here is the query to find strings with given prefix
mysql> select *from findStringWithGivenPrefixDemo where UserMessage LIKE 'Hi%';
The following is the output displaying only the strings with prefix “Hi”
+--------+-----------------------------+
| UserId | UserMessage                 |
+--------+-----------------------------+
| 1      | Hi Good Morning !!!         |
| 4      | Hi i am learning MongoDB!!! |
+--------+-----------------------------+
2 rows in set (0.00 sec)
mdir - Unix, Linux Command

The mdir command is used to display an MS-DOS directory. Its
syntax is:


mdir [-/] [-f] [-w] [-a] [-b] msdosfile [ msdosfiles...]


Mdir
displays the contents of MS-DOS directories, or the entries for some
MS-DOS files.


Mdir supports the following command line options:






    ./configure; make dvi; dvips mtools.dvi






    ./configure; make html


A premade html can be found at:
oohttp://mtools.linux.luI
and also at:
oohttp://www.tux.org/pub/knaff/mtoolsI




    ./configure; make info















Advertisements


    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
How to print a calendar for the given month and year in Python?

You can use the calender module to get the calender for a given month of a given year in Python. You need to provide the year and month as arguments.
import calendar
y = 2017
m = 11
print(calendar.month(y, m))
This will give the output −
   November 2017
Mo Tu We Th Fr Sa Su
       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
How to remove leading zeros from a number in JavaScript?

Use parseInt() to remove leading zeros from a number in JavaScript.
You can try to run the following code to run how to remove leading zeros −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <script>
         var num1 = parseInt("025", 10);
         document.write(num1);

         var num2 = parseInt("040", 10);
         document.write("<br>"+num2);

         var num3 = parseInt("098", 10);
         document.write("<br>"+num3);
      </script>
   </body>
</html>
25
40
98
How do I use the @ sign in MySQL?

To use the @ sign, use MySQL SET command. The @sign is used to set user-defined variables. Following is the syntax −
SET @anyVariableName:=yourValue;
Let us first create a table −
mysql> create table DemoTable1331
   -> (
   -> Id int,
   -> Name varchar(20)
   -> );
Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1331 values(10,'Chris');
Query OK, 1 row affected (0.71 sec)
mysql> insert into DemoTable1331 values(101,'David');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable1331 values(40,'Bob');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable1331 values(30,'Mike');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable1331 values(60,'John');
Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1331;
This will produce the following output −
+------+-------+
| Id   | Name  |
+------+-------+
|   10 | Chris |
|  101 | David |
|   40 | Bob   |
|   30 | Mike  |
|   60 | John  |
+------+-------+
5 rows in set (0.00 sec)
Here is the query to use @sign in MySQL −
mysql> set @Value:=40;
Query OK, 0 rows affected (0.00 sec)
mysql> select * from DemoTable1331 where Id > @Value;
This will produce the following output −
+------+-------+
| Id   | Name  |
+------+-------+
|  101 | David |
|  60  | John  |
+------+-------+
2 rows in set (0.03 sec)
ReactJS value Attribute - GeeksforGeeks

04 Jun, 2021
React.js library is all about splitting the app into several components. Each Component has its own lifecycle. React provides us some in-built methods that we can override at particular stages in the life-cycle of the component.
In this article, we will know how to use value attributes. The value attribute is used to set or get the value for the input field, selected, textarea.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command.npx create-react-app foldername 
Step 1: Create a React application using the following command.
npx create-react-app foldername
 
Step 2: After creating your project folder i.e. foldername, move to it using the following command.cd foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername
Project Structure: It will look like the following.
Example 1:
App.js
import React from 'react';import ReactDOM from 'react-dom';import './index.css';import App from './App';import reportWebVitals from './reportWebVitals';import ReactDOMServer from 'react-dom/server';     const element = <div>    <h1>GeeksforGeeks</h1>      <input value='geeks'/></div>;    ReactDOM.render(  element,    document.getElementById("root"));
Output:
Example 2:
App.js
import React from 'react';import ReactDOM from 'react-dom';import './index.css';import App from './App';import reportWebVitals from './reportWebVitals';import ReactDOMServer from 'react-dom/server';import { getConfig } from '@testing-library/dom';     const element = <div>    <h1>GeeksforGeeks</h1>      <input id={'input'}/>      <button onClick={ get }>get value</button></div>;  function get(){  var a = document.getElementById('input').value  ;  console.log(a)}ReactDOM.render(  element,    document.getElementById("root"));
Output:
Reference: https://reactjs.org/docs/dom-elements.html#value
ReactJS Attributes
ReactJS DOM Elements
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ReactJS useNavigate() Hook
How to set background images in ReactJS ?
Axios in React: A Guide for Beginners
How to create a table in ReactJS ?
How to navigate on path by button click in react router ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Python | Interleave multiple lists of same length - GeeksforGeeks

30 Dec, 2018
Given lists of same length, write a Python program to store alternative elements of given lists in a new list.
Let’s discuss certain ways in which this can be performed.
Method #1 : Using map() + list comprehensionmap() is used to handle the interleave of lists and the task of insertion at alternate is performed by the list comprehension part of the shorthand code. Only works in Python 2.
# Python2 code to demonstrate # to interleave lists# using map() + list comprehension  # initializing lists test_list1 = [1, 4, 5]test_list2 = [3, 8, 9]  # printing original listsprint ("Original list 1 : " + str(test_list1))print ("Original list 2 : " + str(test_list2))  # using map() + list comprehension# to interleave listsres = [i for j in map(None, test_list1, test_list2)                         for i in j if i is not None]  # printing resultprint ("The interleaved list is : " + str(res))
Original list 1 : [1, 4, 5]
Original list 2 : [3, 8, 9]
The interleaved list is : [1, 3, 4, 8, 5, 9]

 Method #2 : Using List slicingPower of list slicing of python can also be used to perform this particular task. We first extend one list to another and then allow the original list to desired alternate indices of the resultant list.
# Python3 code to demonstrate # to interleave lists# using list slicing  # initializing lists test_list1 = [1, 4, 5]test_list2 = [3, 8, 9]  # printing original listsprint ("Original list 1 : " + str(test_list1))print ("Original list 2 : " + str(test_list2))  # using list slicing# to interleave listsres = test_list1 + test_list2res[::2] = test_list1res[1::2] = test_list2  # printing resultprint ("The interleaved list is : " + str(res))
Original list 1 : [1, 4, 5]
Original list 2 : [3, 8, 9]
The interleaved list is : [1, 3, 4, 8, 5, 9]

 Method #3 : Using itertools.chain() + zip()zip() can be used to link both the lists and then chain() can used to perform the alternate append of the elements as desired. This is the most efficient method to perform this task.
# Python3 code to demonstrate # to interleave lists# using zip() + itertools.chain()import itertools  # initializing lists test_list1 = [1, 4, 5]test_list2 = [3, 8, 9]  # printing original listsprint ("Original list 1 : " + str(test_list1))print ("Original list 2 : " + str(test_list2))  # using zip() + itertools.chain()# to interleave listsres = list(itertools.chain(*zip(test_list1, test_list2)))  # printing resultprint ("The interleaved list is : " + str(res))
Original list 1 : [1, 4, 5]
Original list 2 : [3, 8, 9]
The interleaved list is : [1, 3, 4, 8, 5, 9]

Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to change video playing speed using JavaScript ? - GeeksforGeeks

12 Jan, 2021
In this article, we will see how we can change playback speed of videos embedded in an HTML document using an HTML5 video tag.
We can set the new playing speed using playbackRate attribute. It has the following syntax.
Syntax:
let video = document.querySelector('video')
video.playbackRate = newPlaybackRate
We can also set the default playing speed using defaultPlaybackRate attribute. It has the following syntax.
Syntax:
 let video = document.querySelector('video')
 video.defaultPlaybackRate = 4
 video.load()
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">      <meta name="viewport" content=        "width=device-width, initial-scale=1.0">      <style>        body {            text-align: center;            margin-top: 2%;        }          h1 {            color: green;        }          p {            margin-top: 2%;        }          button {            margin-right: 20px;        }    </style></head>  <body>    <h1>GeeksforGeeks</h1>      <video width="890" height="500" controls loop>        <source src="sample.mp4" type="video/mp4">        Your browser does not support the video tag.    </video>      <p>        <button onclick="increase()">Increase Speed</button>        <button onclick="decrease()">Decrease Speed</button>    </p>      <script>        let video = document.querySelector('video');          // Set the default playing speed        video.defaultPlaybackRate = 0.5          // Loading the video after setting         video.load();          function increase() {              // Increasing the playing speed by 1            video.playbackRate += 1;        }          function decrease() {              // Decreasing the playing speed by 1            if (video.playbackRate > 1)                video.playbackRate -= 1;        }    </script></body>  </html>
Output:
CSS-Misc
HTML-Misc
JavaScript-Misc
Picked
CSS
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Calculate the Mean of each Column of a Matrix or Array in R Programming - colMeans() Function - GeeksforGeeks

03 Jun, 2020
colMeans() function in R Language is used to compute the mean of each column of a matrix or array.
Syntax: colMeans(x, dims = 1)
Parameters:x: array of two or more dimensions, containing numeric, complex, integer or logical values, or a numeric data framedims: integer value, which dimensions are regarded as ‘columns’ to sum over. It is over dimensions 1:dims.
Example 1:
# R program to illustrate# colMeans function  # Initializing a matrix with# 3 rows and 3 columnsx <- matrix(rep(1:9), 3, 3)  # Getting matrix representationx  # Calling the colMeans() functioncolMeans(x)
Output:
     [, 1] [, 2] [, 3]
[1, ]    1    4    7
[2, ]    2    5    8
[3, ]    3    6    9

[1] 2 5 8

Example 2:
# R program to illustrate# colMeans function  # Initializing a 3D arrayx <- array(1:12, c(2, 3, 3))  # Getting the array representationx  # Calling the colMeans() function  # for dims = 1, x[, 1, 1], x[, 2, 1], x[, 3, 1],# x[, 1, 2] ... are columnscolMeans(x, dims = 1)  # for dims = 2, x[,,1], x[,,2], x[,,3]# are columnscolMeans(x, dims = 2)
Output:
,, 1

     [, 1] [, 2] [, 3]
[1, ]    1    3    5
[2, ]    2    4    6,, 2

     [, 1] [, 2] [, 3]
[1, ]    7    9   11
[2, ]    8   10   12,, 3

     [, 1] [, 2] [, 3]
[1, ]    1    3    5
[2, ]    2    4    6

     [, 1] [, 2] [, 3]
[1, ]  1.5  7.5  1.5
[2, ]  3.5  9.5  3.5
[3, ]  5.5 11.5  5.5

[1] 3.5 9.5 3.5

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

We can get the memory usage like virtual memory usage or resident set size etc. at run time. To get them we can use some system libraries. This process depends on operating systems. For this example, we are using Linux operating system.
So here we will see how to get the memory usage statistics under Linux environment using C++. We can get all of the details from “/proc/self/stat” folder. Here we are taking the virtual memory status, and the resident set size.
#include <unistd.h>
#include <ios>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void mem_usage(double& vm_usage, double& resident_set) {
   vm_usage = 0.0;
   resident_set = 0.0;
   ifstream stat_stream("/proc/self/stat",ios_base::in); //get info from proc
   directory
   //create some variables to get info
   string pid, comm, state, ppid, pgrp, session, tty_nr;
   string tpgid, flags, minflt, cminflt, majflt, cmajflt;
   string utime, stime, cutime, cstime, priority, nice;
   string O, itrealvalue, starttime;
   unsigned long vsize;
   long rss;
   stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
   >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
   >> utime >> stime >> cutime >> cstime >> priority >> nice
   >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care
   about the rest
   stat_stream.close();
   long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // for x86-64 is configured
   to use 2MB pages
   vm_usage = vsize / 1024.0;
   resident_set = rss * page_size_kb;
}
int main() {
   double vm, rss;
   mem_usage(vm, rss);
   cout << "Virtual Memory: " << vm << "\nResident set size: " << rss << endl;
}
Virtual Memory: 13272
Resident set size: 1548
Select Random Element from List in R - GeeksforGeeks

23 Sep, 2021
In this article, we will discuss how to select a random element from a List using R programming language.
We can select a Random element from a list by using the sample() function. sample() function is used to get the random element from the data structure
Syntax:
sample(1:length(list), n)
where
1:length(list) is used to iterate all elements over a list
n represents the number of random elements to be returned
Note: In our case n=1 because we have to get only one random element.
Example: R program to create a list of numbers and return one  random element
R
# create a list of integerslist1=list(1:10,23,45,67,8)  # get the random element from the listlist1[[sample(1:length(list1), 1)]]
Output:
Test 1:
[1] 67
Test 2:
[1] 45
Example: R program to create a list of numbers and return one  random element
R
# create a vector of integersvec=c(1,2,3,4,5)  # create a variabledata="Hello Geek"  # pass the vector and variable to listlist1=list(vec,data)  # get the random element from the listlist1[[sample(1:length(list1), 1)]]
Output:
[1] 1 2 3 4 5
Picked
R List-Programs
R-List
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
Data Visualization in R
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Merge DataFrames by Column Names in R
CSS | border-image-source Property - GeeksforGeeks

03 Nov, 2021
The border-image-source property is used to specify the image source which is to be set as the border of an element.  
Syntax:  
border-image-source: url(image-path.png)| none| initial| inherit;
 Note: If the value is none, the border styles will be used. The specified image can be divided into regions with the help of border-image-slice property.  
Default Value : Its default value is none.Values: 
none: No image is specified.
image: Used to specify the path of the image to be used as the border of an element.
initial: Initializes the property with it’s default value.
inherit: It takes the value from the parent element.
Example:  
HTML
<!DOCTYPE html> <html>     <head>         <title>            CSS | border-image-source Property        </title>        <style>             body {                 text-align:center;                color:green;            }                            .border1 {                 border: 10px solid transparent;                 padding: 15px;                 border-image-source: url( https://media.geeksforgeeks.org/wp-content/uploads/border1-2.png);                 border-image-repeat: round;                 border-image-slice: 50;                 border-image-width: 20px;             }                      </style>     </head>     <body>         <h1>GeeksforGeeks</h1>         <h2>border-image-source property</h2>         <div class = "border1">GEEKSFORGEEKS</div>     </body></html>    
Output:  
Supported Browsers: The browsers supported by CSS | border-image-source Property are listed below:  
Chrome 15.0
Edge 11.0
Firefox 15.0
Opera 15.0
Safari 6.0
 
ManasChhabra2
CSS-Properties
Picked
CSS
Web Technologies
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?
Types of CSS (Cascading Style Sheet)
How to create footer to stay at the bottom of a Web page?
How to update Node.js and NPM to next version ?
Express.js express.Router() Function
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
How to get Subtraction of tuples in Python

When it is required to subtract the tuples, the 'map' method and lambda function can be used.
The map function applies a given function/operation to every item in an iterable (such as list, tuple). It returns a list as the result.
Anonymous function is a function which is defined without a name. In general, functions in Python are defined using 'def' keyword, but anonymous function is defined with the help of 'lambda' keyword. It takes a single expression, but can take any number of arguments. It uses the expression and returns the result of it.
Below is a demonstration of the same −
Live Demo
my_tuple_1 = (7, 8, 11, 0 ,3, 4)
my_tuple_2 = (3, 2, 22, 45, 12, 9)

print ("The first tuple is : " )
print(my_tuple_1)
print ("The second tuple is : " )
print(my_tuple_2)

my_result = tuple(map(lambda i, j: i - j, my_tuple_1, my_tuple_2))

print("The tuple after subtraction is : " )
print(my_result)
The first tuple is :
(7, 8, 11, 0, 3, 4)
The second tuple is :
(3, 2, 22, 45, 12, 9)
The tuple after subtraction is :
(4, 6, -11, -45, -9, -5)
Two tuples are defined, and are displayed on the console.
The lambda function is used to subtract each of the corresponding elements from the two tuples.
This operation is mapped to all elements using the 'map' method.
This result is converted into a tuple.
This result is assigned to a value.
It is displayed as output on the console.
How can I position JButtons vertically one after another in Java Swing?

Position buttons vertically one after another using the Box class. Use the createVerticalBox() method that displays components from top to bottom −
JButton button1 = new JButton("One");
JButton button2 = new JButton("Two");
JButton button3 = new JButton("Three");
Box box = Box.createVerticalBox();
box.add(button1);
box.add(button2);
box.add(button3);
The following is an example to position buttons vertically one after another −
package my;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
public class SwingDemo {
   public static void main(String[] args) {
      JButton button1 = new JButton("One");
      JButton button2 = new JButton("Two");
      JButton button3 = new JButton("Three");
      JButton button4 = new JButton("Four");
      JButton button5 = new JButton("Five");
      JButton button6 = new JButton("Six");
      JButton button7 = new JButton("Seven");
      Box box = Box.createVerticalBox();
      box.add(button1);
      box.add(button2);
      box.add(button3);
      box.add(button4);
      box.add(button5);
      box.add(button6);
      box.add(button7);
      JFrame frame = new JFrame();
      frame.add(box);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLocationByPlatform(true);
      frame.setSize(500, 300);
      frame.setVisible(true);
   }
}
DATESBETWEEN function

Returns a table that contains a column of dates that begins with the start_date and continues until the end_date.
DATESBETWEEN (<dates>, <start_date>, <end_date>) 

dates
A column that contains dates.
start_date
A date expression.
end_date
A date expression.
A table containing a single column of date values.
If start_date is a blank date value, then start_date will be the earliest value in the dates column.
If start_date is a blank date value, then start_date will be the earliest value in the dates column.
If end_date is a blank date value, then end_date will be the latest value in the dates column.
If end_date is a blank date value, then end_date will be the latest value in the dates column.
The dates used as the start_date and end_date are inclusive.
The dates used as the start_date and end_date are inclusive.
If the sales occurred on October 1 and December 31 and you specify October 1 as the start date and December 31 as the end_date, then sales on October 1 and December 31 are counted.
If the sales occurred on October 1 and December 31 and you specify October 1 as the start date and December 31 as the end_date, then sales on October 1 and December 31 are counted.
= CALCULATE (
   SUM (Sales[Sales Amount]), DATESBETWEEN (Sales[Date], DATE (2015,1,1), DATE (2015,3,31))
)

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
Capacity of a channel in Computer Network

07 Apr, 2020
By capacity of a channel, it means the capacity of the transmission medium (wire or link). Capacity is the number of bits the transmission medium can hold. So basically there are 2 types of channels – Full duplex and half duplex.
Half duplex – the transmission can happen in one direction at a time.Full duplex – the transmission can happen in both the direction simultaneously.
Half duplex – the transmission can happen in one direction at a time.
Full duplex – the transmission can happen in both the direction simultaneously.
For example, the transmission medium is operating in its maximum capacity then at that time the number of bits it is holding is called capacity of the transmission medium.
But how can we find the capacity mathematically?
If the length of the transmission medium is longer then its capacity will be higher.
It also depends on the area of cross section of the medium.
If the bandwidth is 1 bps, then every second it can take 1 bit. After every second it will move forward so that next bit could occupy the space. Therefore the final time in which it will occupy all the bits will be its propagation delay.
The capacity of the channel depends on two things:
BandwidthPropagation delay
Bandwidth
Propagation delay
Capacity = bandwidth * propagation delay 
(in case of half duplex)

Capacity =2* bandwidth * propagation delay 
(in case of full duplex) 
Computer Networks
GATE CS
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Wireless Application Protocol
Mobile Internet Protocol (or Mobile IP)
GSM in Wireless Communication
Difference between MANET and VANET
Introduction of Mobile Ad hoc Network (MANET)
ACID Properties in DBMS
Types of Operating Systems
Normal Forms in DBMS
Page Replacement Algorithms in Operating Systems
Inter Process Communication (IPC)
Python | Ways to sort a zipped list by values

17 Oct, 2019
Zipped lists are those lists where several lists are mapped together to form one list which can be used as one entity altogether. In Python Zip() function is used to map different lists.
Let’s discuss a few methods to demonstrate the problem.
Method #1: Using lambda and sort
# Python code to demonstrate# sort zipped list by values# using lambda and sorted  # Declaring initial listslist1 = ['geeks', 'for', 'Geeks']list2 = [3, 2, 1]zipped = zip(list1, list2)  # Converting to listzipped = list(zipped)  # Printing zipped listprint("Initial zipped list - ", str(zipped))  # Using sorted and lambdares = sorted(zipped, key = lambda x: x[1])      # printing resultprint("final list - ", str(res))
Initial zipped list -  [('geeks', 3), ('for', 2), ('Geeks', 1)]
final list -  [('Geeks', 1), ('for', 2), ('geeks', 3)]

 Method #2: Using operator and sort
# Python code to demonstrate# sort zipped list by values# using operator and sorted  import operator# Declaring initial listslist1 = ['akshat', 'Manjeet', 'nikhil']list2 = [3, 2, 1]zipped = zip(list1, list2)  # Converting to listzipped = list(zipped)  # Printing zipped listprint("Initial zipped list - ", str(zipped))  # Using sorted and operatorres = sorted(zipped, key = operator.itemgetter(1))      # printing resultprint("final list - ", str(res))
Initial zipped list -  [('akshat', 3), ('Manjeet', 2), ('nikhil', 1)]
final list -  [('nikhil', 1), ('Manjeet', 2), ('akshat', 3)]

nidhi_biet
Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Software Engineering | MOCK (Introduction)

21 May, 2019
Mock is an Object that clone the behavior of a real object. It is basically used in Unit Testing by testing the isolated unit even when Backend is not available.
Why we use MOCK object?The unit testing purpose is to approve each unit of software designed and verify that the generated code is working perfectly, interdependent on external dependencies. Most of the cases, Code under test has some external dependencies like APIs and It would be better to create a mock object instead of generating test cases on the real object of the dependencies.
A web application consists of two components: Frontend and Backend server that are dependent on each other and run simultaneously.The developer of the Frontend is dependent on the backend developer for a server, APIs, and other external services. In the testing or development phase, a major challenge is to handle the various external dependencies.Real Environment exchanges their data through a server where user-end services are handled by a different server and admin services are handled by another server. Developer facing difficulty while developing software. On the other hand tester not able to do efficient unit testing when software is dependent on external dependencies. In order to provide effective testing, mock server is required. Mock server cut out the dependency on a real server and allows tester to do testing independently. Figure gives virtual Representation of Mock server.
Now, in order to effectively utilizes our time and improve testing mechanism, there is a requirement of a Mock server that behaves as a real server, mimic its dependencies. Some of the mocking frameworks available to unit test Java application are Jmock, Mockito, EasyMock. For unit testing, mock objects can be used in place of real objects by simulating the Interfaces required. Mocks are easiest to use while Interface-based design systems.
There is some pattern to be followed for Unit testing with Mock objects:
Build an Instance or object of Mock object.Define States of Mock objects under defined environment.Set expectations, status codes, responses, error display in mock object.Set Mock object as parameter under domain code.Verify Mock objects under unit testing.
Build an Instance or object of Mock object.
Define States of Mock objects under defined environment.
Set expectations, status codes, responses, error display in mock object.
Set Mock object as parameter under domain code.
Verify Mock objects under unit testing.
SoniAnshu
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas dataframe.corr()

22 Apr, 2020
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas dataframe.corr() is used to find the pairwise correlation of all columns in the dataframe. Any na values are automatically excluded. For any non-numeric data type columns in the dataframe it is ignored.
Syntax: DataFrame.corr(self, method=’pearson’, min_periods=1)
Parameters:method :pearson : standard correlation coefficientkendall : Kendall Tau correlation coefficientspearman : Spearman rank correlationmin_periods : Minimum number of observations required per pair of columns to have a valid result. Currently only available for pearson and spearman correlation
Returns: count :y : DataFrame
Note: The correlation of a variable with itself is 1.
For link to CSV file Used in Code, click here
Example #1: Use corr() function to find the correlation among the columns in the dataframe using ‘Pearson’ method.
# importing pandas as pdimport pandas as pd  # Making data frame from the csv filedf = pd.read_csv("nba.csv")  # Printing the first 10 rows of the data frame for visualizationdf[:10]
Now use corr() function to find the correlation among the columns. We are only having four numeric columns in the dataframe.
# To find the correlation among# the columns using pearson methoddf.corr(method ='pearson')
Output :
The output dataframe can be interpreted as for any cell, row variable correlation with the column variable is the value of the cell. As mentioned earlier, that the correlation of a variable with itself is 1. For that reason all the diagonal values are 1.00 Example #2: Use corr() function to find the correlation among the columns in the dataframe using ‘kendall’ method.
# importing pandas as pdimport pandas as pd  # Making data frame from the csv filedf = pd.read_csv("nba.csv")  # To find the correlation among# the columns using kendall methoddf.corr(method ='kendall')
Output :
The output dataframe can be interpreted as for any cell, row variable correlation with the column variable is the value of the cell. As mentioned earlier, that the correlation of a variable with itself is 1. For that reason all the diagonal values are 1.00.
pratibha_gupta
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML | <button> formaction Attribute

31 May, 2019
The HTML <button> formaction Attribute is used to specify where to send the data of the form. After submission of form the formaction attribute called. The form data is to be sent to the server after submission of form. It overrides the feature of the action attribute of an <form> element.
Syntax:
<button type="submit" formaction="URL"> 
Attribute Values: It contains single value URL which is used to specify the URL of the document where the data to be sent after submission of the form.
The possible value of URL are:
absolute URL: It points to the full address of a page. For example: www.geeksforgeeks.org/data-structure
relative URL: It is used to point to a file within in a webpage. For Example: gfg.php
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML <Button> formAction Attribute    </title></head>  <body style="text-align:center;">    <h1>         GeeksForGeeks     </h1>      <h2>         HTML  <button> formAction Attribute     </h2>      <form action="#" method="get" target="_self">        <input type="submit"               id="Geeks"               name="myGeeks"               value="Submit @ geeksforgeeks"                formTarget="_blank"                formMethod="post"               formAction="test.php">    </form></body>  </html>
Output:
Supported Browsers: The browsers supported by HTML button formaction Attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Apple Safari
Opera
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
REST API (Introduction)
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
HTTP headers | Content-Type
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Roadmap to Learn JavaScript For Beginners
Remove elements from a JavaScript Array
Lodash _.flatten() Method

29 Jul, 2020
Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers etc.The Lodash.flatten() method is used to flatten the array to one level deep.
Syntax:
flatten( array )
Parameter: This method accepts single parameter array that holds simple array or array of arrays.
Return Value: The return type of this function is array.
Note: Please install lodash module by using command npm install lodash before using the code given below.
Example 1: When 2D array of Integers is given.
Javascript
// Requiring the lodash libraryconst _ = require("lodash");  // Original arraylet array1 = [[1, 2], [4, 5], [7, 8]]  // Using _.flatten() methodlet newArray = _.flatten(array1);  // Printing original Arrayconsole.log("original Array1: ", array1)  // Printing the newArrayconsole.log("new Array: ", newArray)
Output:
Example 2: When array of arrays of object is given.
Javascript
// Requiring the lodash libraryconst _ = require("lodash");  // Original arraylet array1 = [[{ "a": 1 }],     [{ "b": 2 }, { "c": 3 }]]  // using _.flatten() methodlet newArray = _.flatten(array1);  // printing original Arrayconsole.log("original Array1: ", array1)  // printing the newArrayconsole.log("new Array: ", newArray)
Output: 
Example 3: When empty array of arrays is given.
Javascript
// Requiring the lodash libraryconst _ = require("lodash");  // Original arraylet array1 = [[], [[[]]], [[]], []]  // Using _.flatten() methodlet newArray = lodash.flatten(array1);  // Printing original Arrayconsole.log("original Array1: ", array1)  // Printing the newArrayconsole.log("new Array: ", newArray)
Output:
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Roadmap to Learn JavaScript For Beginners
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Roadmap to Learn JavaScript For Beginners
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
PyQt - Using Qt Designer

The PyQt installer comes with a GUI builder tool called Qt Designer. Using its simple drag and drop interface, a GUI interface can be quickly built without having to write the code. It is however, not an IDE such as Visual Studio. Hence, Qt Designer does not have the facility to debug and build the application.
Creation of a GUI interface using Qt Designer starts with choosing a top level window for the application.
You can then drag and drop required widgets from the widget box on the left pane. You can also assign value to properties of widget laid on the form.
The designed form is saved as demo.ui. This ui file contains XML representation of widgets and their properties in the design. This design is translated into Python equivalent by using pyuic4 command line utility. This utility is a wrapper for uic module. The usage of pyuic4 is as follows −
pyuic4 –x demo.ui –o demo.py

In the above command, -x switch adds a small amount of additional code to the generated XML so that it becomes a self-executable standalone application.
if __name__ == "__main__":
   import sys
   app = QtGui.QApplication(sys.argv)
   Dialog = QtGui.QDialog()
   ui = Ui_Dialog()
   ui.setupUi(Dialog)
   Dialog.show()
   sys.exit(app.exec_())
The resultant python script is executed to show the following dialog box −
The user can input data in input fields but clicking on Add button will not generate any action as it is not associated with any function. Reacting to user-generated response is called as event handling.

    146 Lectures 
     22.5 hours 

 ALAA EID
 Print
 Add Notes
 Bookmark this page
Execute a String of Code in Python

There are times when you need the entire block of code as a string and want this code to execute as part of a bigger python program. IN this article we will see how we can pass code as a string to a variable and then use that variable in a wrapper program which will then execute this program as a python code.
The exec() function is used to execute the code. The code has to be embedded within three “.
code = """
numbers = [11,33,55,39,55,75,37,21,23,41,13]
for num in numbers:
   if num%2 == 0:
      print ('the list contains an even number')
      break
else:
   print ('the list doesnot contain even number')
"""
exec(code)
Running the above code gives us the following result −
the list does not contain even number.
Highcharts - Basic Line Chart

We have already seen the configuration used to draw this chart in Highcharts Configuration Syntax chapter. Let us now consider the following example to further understand a basic line chart.
highcharts_line_basic.htm
<html>
   <head>
      <title>Highcharts Tutorial</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
      <script src = "https://code.highcharts.com/highcharts.js"></script> 
   </head>
   
   <body>
      <div id = "container" style = "width: 550px; height: 400px; margin: 0 auto"></div>
      <script language = "JavaScript">
         $(document).ready(function() {
            var title = {
               text: 'Average Temperatures of Cities'   
            };
            var subtitle = {
               text: 'Source: worldClimate.com'
            };
            var xAxis = {
               categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
                  'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
            };
            var yAxis = {
               title: {
                  text: 'Temperature (\xB0C)'
               },
               plotLines: [{
                  value: 0,
                  width: 1,
                  color: '#808080'
               }]
            };   
            var tooltip = {
               valueSuffix: '\xB0C'
            }
            var legend = {
               layout: 'vertical',
               align: 'right',
               verticalAlign: 'middle',
               borderWidth: 0
            };
            var series =  [{
                  name: 'Tokyo',
                  data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2,
                     26.5, 23.3, 18.3, 13.9, 9.6]
               }, 
               {
                  name: 'New York',
                  data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8,
                     24.1, 20.1, 14.1, 8.6, 2.5]
               }, 
               {
                  name: 'London',
                  data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 
                     16.6, 14.2, 10.3, 6.6, 4.8]
               }
            ];

            var json = {};
            json.title = title;
            json.subtitle = subtitle;
            json.xAxis = xAxis;
            json.yAxis = yAxis;
            json.tooltip = tooltip;
            json.legend = legend;
            json.series = series;
            
            $('#container').highcharts(json);
         });
      </script>
   </body>
   
</html>
Verify the result.
 Print
 Add Notes
 Bookmark this page