code-rag-bench/online-tutorials huggingface dataset:
Create a Pandas Dataframe from a dict of equal length lists in Python

The Dataframe in pandas can be created using various options. One of the option is to take a dictionary and convert it to a Dataframe. In this article we will see how to take three lists of equal length and convert them to a pandas dataframe using a python dictionary.
In this approach we have the lists declared individually. Then each of them is used as a value for the appropriate key inside a dictionary definition. Finally the pandas method called pd.Dataframe is applied to the dictionary.
 Live Demo
import pandas as pd

# Lists for Exam schedule
Days = ['Mon', 'Tue', 'Wed','Thu', 'Fri']
Sub = ['Chemisry','Physics','Maths','English','Biology']
Time = ['2 PM', '10 AM', '11 AM','1 PM', '3 PM']

# Dictionary for Exam Schedule
Exam_Schedule = {'Exam Day': Days,
               'Exam Subject': Sub,
               'Exam Time': Time}

# Dictionary to DataFrame
Exam_Schedule_df = pd.DataFrame(Exam_Schedule)

print(Exam_Schedule_df)
Running the above code gives us the following result −
   Exam Day Exam Subject Exam Time
0    Mon    Chemisry     2 PM
1    Tue    Physics       10 AM
2    Wed    Maths         11 AM
3    Thu    English       1 PM
4    Fri    Biology       3 PM
In this approach we take the lists directly as the values inside the dictionary instead of declaring them individually. Then the dictionary is converted to the pandas dataframe in a similar manner as above.
 Live Demo
import pandas as pd

# Dictionary for Exam Schedule
Exam_Schedule = {
'Exam Day': ['Mon', 'Tue', 'Wed','Thu', 'Fri'],
'Exam Subject': ['Chemisry','Physics','Maths','English','Biology'],
'Exam Time': ['2 PM', '10 AM', '11 AM','1 PM', '3 PM']
}

# Dictionary to DataFrame
Exam_Schedule_df = pd.DataFrame(Exam_Schedule)

print(Exam_Schedule_df)
Running the above code gives us the following result −
   Exam Day Exam Subject Exam Time
0    Mon       Chemisry       2 PM
1    Tue       Physics       10 AM
2    Wed       Maths          11 AM
3    Thu       English      1 PM
4    Fri       Biology        3 PM
Ternary Operator in C#

Ternary operator is a Conditional operator in C#. It takes three arguments and evaluates a Boolean expression.
For example −
b = (a == 1) ? 20 : 30;
Above, if the first operand evaluates to true (1), the second operand is evaluated. If the first operand evaluates to false (0), the third operand is evaluated.
The following is an example −
 Live Demo
using System;

namespace DEMO {

   class Program {

      static void Main(string[] args) {

         int a, b;
         a = 10;
         b = (a == 1) ? 20 : 30;
         Console.WriteLine("Value of b is {0}", b);

         b = (a == 10) ? 20 : 30;
         Console.WriteLine("Value of b is {0}", b);
         Console.ReadLine();
      }
   }
}
Value of b is 30
Value of b is 20
How to add multiple intervals to DATE_ADD() in MySQL?

The current date and time is as follows −
mysql> select now();
This will produce the following output −
+---------------------+
| now()               |
+---------------------+
| 2019-06-15 12:24:06 |
+---------------------+
1 row in set (0.00 sec)
Let us first create a table −
mysql> create table DemoTable
   ->(
   -> ArrivalDate datetime
   -> );
Query OK, 0 rows affected (1.15 sec)
Insert some records in the table using insert command. Here, we are adding multiple intervals to the DATE_ADD() method −
mysql> insert into DemoTable values(DATE_ADD(DATE_ADD(NOW(), INTERVAL 6
MONTH), INTERVAL 1 YEAR));
Query OK, 1 row affected (0.13 sec)

mysql> insert into DemoTable values(DATE_ADD(DATE_ADD(NOW(), INTERVAL 3
MONTH), INTERVAL 4 YEAR));
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------------+
| ArrivalDate         |
+---------------------+
| 2020-12-15 12:23:39 |
| 2023-09-15 12:23:48 |
+---------------------+
2 rows in set (0.00 sec)
Redis - Hash Hmget Command

Redis HMGET command is used to get the values associated with the specified fields in the hash stored at the key. If the field does not exist in Redis hash, then a nil value is returned.
Array reply, list of values associated with the given fields, in the same order as they are requested.
Following is the basic syntax of Redis HMGET command.
redis 127.0.0.1:6379> HMGET KEY_NAME FIELD1...FIELDN 

redis 127.0.0.1:6379> HSET myhash field1 "foo" 
(integer) 1 
redis 127.0.0.1:6379> HSET myhash field2 "bar" 
(integer) 1 
redis 127.0.0.1:6379> HMGET myhash field1 field2 nofield 
1) "foo" 
2) "bar" 
3) (nil)


    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
How to disable autocomplete of an HTML input field ? - GeeksforGeeks

06 Sep, 2021
In this article, we will learn how to disable or off autocomplete features of a particular input field in HTML form. As we know that autocomplete feature is used to allow a browser whether to automatically complete filled the input data value based on the values that the user entered before. As the latest browsers supports enabled autocomplete by default. The autocomplete feature faster the process of filling the form. In case of low internet excess or session expired, if the autocomplete is enabled then the browser automatically filled the data values that the user entered before. 
Autocomplete attribute take two values:
on: It specifies that autocomplete is enabled.
off: It specifies that the autocomplete is disabled.
If you want to disabled autocomplete feature then follow the approach which are given below: 
Approach: 
First we create an HTML document that contains an <input> tag.
Use the <input> tag with autocomplete attribute
Set the autocomplete attribute to value “off”.
 
Example: Below code demonstrates that a form has two input fields, one with autocomplete status is on and in the other field autocomplete feature is off.
HTML
<!DOCTYPE html><html>  <head>    <title>        How to disable autocomplete         of an HTML input field?    </title>      <style>        h1,        h2 {            font-family: impact;        }    </style></head>  <body style="text-align:center;">      <h1>GeeksForGeeks</h1>      <h2>        How to disable autocomplete         of an HTML input field?    </h2>      <form id="myGeeks">        Name:<input type="text" id="text_id"             name="geeks" autocomplete="on">        <br>        Address: <input type="Address"             name="address" autocomplete="off">        <br><br>          <input type="submit">    </form></body>  </html>
Output: 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML-Questions
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Angular File Upload
Form validation using jQuery
How to auto-resize an image to fit a div container using CSS?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
Sum of internal angles of a Polygon - GeeksforGeeks

08 Mar, 2022
Given an integer N, the task is to find the sum of interior angles of an N-sided polygon. A plane figure having a minimum of three sides and angles is called a polygon.Examples:  
Input: N = 3 Output: 180 3-sided polygon is a triangle and the sum of the interior angles of a triangle is 180.Input: N = 6 Output: 720  
 
Approach: The sum of internal angles of a polygon with N sides is given by (N – 2) * 180Below is the implementation of the above approach: 
C++
Java
C#
Python
PHP
Javascript
// C++ implementation of the approach#include <bits/stdc++.h>using namespace std; // Function to return the sum of internal// angles of an n-sided polygonint sumOfInternalAngles(int n){    if (n < 3)        return 0;    return (n - 2) * 180;} // Driver codeint main(){    int n = 5;     cout << sumOfInternalAngles(n);     return 0;}
// Java implementation of the approachclass GFG {     // Function to return the sum of internal    // angles of an n-sided polygon    static int sumOfInternalAngles(int n)    {        if (n < 3)            return 0;        return ((n - 2) * 180);    }     // Driver code    public static void main(String args[])    {        int n = 5;         System.out.print(sumOfInternalAngles(n));    }}
// C# implementation of the approachusing System;class GFG {     // Function to return the sum of internal    // angles of an n-sided polygon    static int sumOfInternalAngles(int n)    {        if (n < 3)            return 0;        return ((n - 2) * 180);    }     // Driver code    public static void Main()    {        int n = 5;         Console.Write(sumOfInternalAngles(n));    }}
# Python3 implementation of the approach # Function to return the sum of internal# angles of an n-sided polygondef sumOfInternalAngles(n):    if(n < 3):        return 0    return ((n - 2) * 180) # Driver coden = 5print(sumOfInternalAngles(n))
<?php// PHP implementation of the approach // Function to return the sum of internal// angles of an n-sided polygonfunction sumOfInternalAngles($n){    if($n < 3)        return 0;    return (($n - 2) * 180);} // Driver code$n = 5;echo(sumOfInternalAngles($n));?>
<script> // JavaScript implementation of the approach // Function to return the sum of internal// angles of an n-sided polygonfunction sumOfInternalAngles(n){    if (n < 3)        return 0;    return (n - 2) * 180;} // Driver code     let n = 5;     document.write(sumOfInternalAngles(n));  // This code is contributed by Mayank Tyagi </script>
540
 
Time Complexity: O(1)
Auxiliary Space: O(1)
mayanktyagi1709
subhammahato348
Geometric
Mathematical
Technical Scripter
Mathematical
Geometric
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Program for distance between two points on earth
Convex Hull | Set 1 (Jarvis's Algorithm or Wrapping)
Line Clipping | Set 1 (Cohen–Sutherland Algorithm)
Convex Hull | Set 2 (Graham Scan)
Optimum location of point to minimize total distance
Program for Fibonacci numbers
Write a program to print all permutations of a given string
Set in C++ Standard Template Library (STL)
C++ Data Types
Coin Change | DP-7
numpy.amin() in Python - GeeksforGeeks

28 Apr, 2022
The numpy.amin() function returns minimum of an array or minimum along axis(if mentioned). Syntax : numpy.amin(arr, axis = None, out = None, keepdims = <class numpy._globals._NoValue>) Parameters : 
arr : [array_like]input data
axis : [int or tuples of int]axis along which we want the min value. Otherwise, it will consider arr to be flattened.
out : [ndarray, optional]Alternative output array in which to place the result
keepdims : [boolean, optional]If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. If the default value is passed, then keepdims will not be passed through to the all method of sub-classes of ndarray, however any non-default value will be. If the sub-classes sum method does not implement keepdims any exceptions will be raised.
Return : Minimum of array – arr[ndarray or scalar], scalar if axis is None; the result is an array of dimension a.ndim – 1, if axis is mentioned. Code – 
Python
# Python Program illustrating# numpy.amin() method import numpy as geek # 1D arrayarr = geek.arange(8)print("arr : ", arr)print("Min of arr : ", geek.amin(arr)) # 2D arrayarr = geek.arange(10).reshape(2, 5)print("\narr : ", arr) # Minimum of the flattened arrayprint("\nMin of arr, axis = None : ", geek.amin(arr)) # Minimum along the first axis# axis 0 means verticalprint("Min of arr, axis = 0 : ", geek.amin(arr, axis = 0)) # Minimum along the second axis# axis 1 means horizontalprint("Min of arr, axis = 1 : ", geek.amin(arr, axis = 1))  
Output – 
arr :  [0 1 2 3 4 5 6 7]
Min of arr :  0

arr :  [[0 1 2 3 4]
 [5 6 7 8 9]]

Min of arr, axis = None :  0
Min of arr, axis = 0 :  [0 1 2 3 4]
Min of arr, axis = 1 :  [0 5]
References – https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.amin.html#numpy.amin 
Note – These codes won’t run on online IDE’s. So please, run them on your systems to explore the working.
This article is contributed by Mohit Gupta_OMG . If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
vinayedula
surinderdawra388
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python OpenCV - cv2.rotate() method - GeeksforGeeks

08 Jun, 2020
OpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.rotate() method is used to rotate a 2D array in multiples of 90 degrees. The function cv::rotate rotates the array in three different ways.
Syntax: cv2.cv.rotate( src, rotateCode[, dst] )
Parameters:src: It is the image whose color space is to be changed.rotateCode: It is an enum to specify how to rotate the array.dst: It is the output image of the same size and depth as src image. It is an optional parameter.
Return Value: It returns an image.
Image used for all the below examples:
Example #1: Rotate by 90 degrees clockwise
# Python program to explain cv2.rotate() method  # importing cv2import cv2  # pathpath = r'C:\Users\user\Desktop\geeks14.png'  # Reading an image in default modesrc = cv2.imread(path)  # Window name in which image is displayedwindow_name = 'Image'  # Using cv2.rotate() method# Using cv2.ROTATE_90_CLOCKWISE rotate# by 90 degrees clockwiseimage = cv2.rotate(src, cv2.cv2.ROTATE_90_CLOCKWISE)  # Displaying the imagecv2.imshow(window_name, image)cv2.waitKey(0)
Output:
Example #2: Rotate by 180 degrees clockwise
# Python program to explain cv2.rotate() method  # importing cv2import cv2  # pathpath = r'C:\Users\user\Desktop\geeks14.png'  # Reading an image in default modesrc = cv2.imread(path)  # Window name in which image is displayedwindow_name = 'Image'  # Using cv2.rotate() method# Using cv2.ROTATE_180 rotate by # 180 degrees clockwiseimage = cv2.rotate(src, cv2.ROTATE_180)  # Displaying the imagecv2.imshow(window_name, image)cv2.waitKey(0)
Output:
Example #3: Rotate by 270 degrees clockwise
# Python program to explain cv2.rotate() method  # importing cv2import cv2  # pathpath = r'C:\Users\user\Desktop\geeks14.png'  # Reading an image in default modesrc = cv2.imread(path)  # Window name in which image is displayedwindow_name = 'Image'  # Using cv2.rotate() method# Using cv2.ROTATE_90_COUNTERCLOCKWISE # rotate by 270 degrees clockwiseimage = cv2.rotate(src, cv2.ROTATE_90_COUNTERCLOCKWISE)  # Displaying the imagecv2.imshow(window_name, image)cv2.waitKey(0)
Output:
Image-Processing
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
array data() in C++ STL with Examples - GeeksforGeeks

23 Jul, 2018
The array::data() is a built-in function in C++ STL which returns an pointer pointing to the first element in the array object.
Syntax:
array_name.data()
Parameters: The function does not accept any parameters.
Return Value: The function returns an pointer.
Below programs illustrate the above function:
Program 1:
// CPP program to demonstrate the// array::data() function#include <bits/stdc++.h>using namespace std;int main(){    array<int, 5> arr = { 1, 2, 3, 4, 5 };      // prints the array elements    cout << "The array elements are: ";    for (auto it = arr.begin(); it != arr.end(); it++)        cout << *it << " ";      // Points to the first element    auto it = arr.data();      cout << "\nThe first element is:" << *it;      return 0;}
The array elements are: 1 2 3 4 5 
The first element is:1

Program 2:
// CPP program to demonstrate the// array::data() function#include <bits/stdc++.h>using namespace std;int main(){    array<int, 5> arr = { 1, 2, 3, 4, 5 };      // prints the array elements    cout << "The array elements are: ";    for (auto it = arr.begin(); it != arr.end(); it++)        cout << *it << " ";      // Points to the first element    auto it = arr.data();      // increment    it++;    cout << "\nThe second element is: " << *it;      // increment    it++;    cout << "\nThe third element is: " << *it;      return 0;}
The array elements are: 1 2 3 4 5 
The second element is: 2
The third element is: 3

cpp-array
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
std::string class in C++
Inline Functions in C++
Pair in C++ Standard Template Library (STL)
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
Queue in C++ Standard Template Library (STL)
How to Restore SQL Server Database From Backup? - GeeksforGeeks

15 Oct, 2021
A Database is defined as a structured form of data that is stored database a computer or data in an organized manner and can be accessed in various ways. It is also the collection of schemas, tables, queries, views, etc. Databases help us with easily storing, accessing, and manipulating data held on a computer. The Database Management System allows a user to interact with the database. In this article, we will see how can we restore SQL Server Database from Backup.
For the demonstration purpose, we will create one database named ‘geeks’.
Step 1: Create Database
Use the below SQL statement to create database called geeks;
QUERY:
CREATE DATABASE geeks;
you can see database with name ‘geeks’ is created.
Step 2: Use database
Query:
USE geeks;
Step 3: Table definition
We have the following demo_table  in the database.
Query:
CREATE TABLE demo_table
(FIRSTNAME varchar(20),
LASTNAME varchar(20),
GENDER varchar(10), AGE int);
Step 4: Insert values
Following command is used to insert values into the table.
Query:
INSERT INTO demo_table VALUES
('ROMY','KUMARI','FEMALE', 22),
('PUSHKAR', 'JHA', 'MALE', 23),
('SOUMYA', 'SHRIYA', 'FEMALE', 22),
('NIKHIL', 'KALRA', 'MALE', 23),
('ROHIT', 'KUMAR', 'MALE', 23),
Step 5: View data of the table
Query:
SELECT * FROM demo_table;
Output:
Restoring of database can be done through Object explorer in SQL Server.
Steps to restore database:
Select View from menu bar.
Select Object explorer option. Object explorer will be appeared on left side of the screen.
Right click on Database folder and select ‘Restore Database’ option.
The dialog box will open, select device option and browse the backup media.
After selecting the Backup media, click OK
Database will be restored successfully.
Now, for demonstration of restoring the database. Delete the geeks database.
Step 6: Delete the Database
Syntax:
DROP DATABASE database_name;
We can not drop the database while in use.
Query:
DROP DATABASE geeks;
Output:
geeks database is deleted. You can not find geeks database in the object explorer.
Step 7: Restore database
Right click on database and select ‘Restore database’ option
Select ‘device’ option and add backup media
Click Ok button
Prompt will appear showing the message as “Database restored successfully”. Click OK.
Check Object explorer.
‘geeks’ database is restored successfully.
Picked
SQL-Server
TrueGeek-2021
SQL
TrueGeek
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
How to redirect to another page in ReactJS ?
How to remove duplicate elements from JavaScript Array ?
Basics of API Testing Using Postman
SQL Statement to Remove Part of a String
Types of Internet Protocols
Python | Pandas DataFrame.transpose - GeeksforGeeks

21 Feb, 2019
Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure of the Pandas.
Pandas DataFrame.transpose() function transpose index and columns of the dataframe. It reflect the DataFrame over its main diagonal by writing rows as columns and vice-versa.
Syntax: DataFrame.transpose(*args, **kwargs)
Parameter :copy : If True, the underlying data is copied. Otherwise (default), no copy is made if possible.*args, **kwargs : Additional keywords have no effect but might be accepted for compatibility with numpy.
Returns : The transposed DataFrame
Example #1: Use DataFrame.transpose() function to find the transpose of the given dataframe.
# importing pandas as pdimport pandas as pd  # Creating the DataFramedf = pd.DataFrame({'Weight':[45, 88, 56, 15, 71],                   'Name':['Sam', 'Andrea', 'Alex', 'Robin', 'Kia'],                   'Age':[14, 25, 55, 8, 21]})  # Create the indexindex_ = pd.date_range('2010-10-09 08:45', periods = 5, freq ='H')  # Set the indexdf.index = index_  # Print the DataFrameprint(df)
Output :
Now we will use DataFrame.transpose() function to find the transpose of the given dataframe.
# return the transposeresult = df.transpose()  # Print the resultprint(result)
Output :
As we can see in the output, the DataFrame.transpose() function has successfully returned the transpose of the given dataframe. Example #2: Use DataFrame.transpose() function to find the transpose of the given dataframe.
# importing pandas as pdimport pandas as pd  # Creating the DataFramedf = pd.DataFrame({"A":[12, 4, 5, None, 1],                    "B":[7, 2, 54, 3, None],                    "C":[20, 16, 11, 3, 8],                    "D":[14, 3, None, 2, 6]})   # Create the indexindex_ = ['Row_1', 'Row_2', 'Row_3', 'Row_4', 'Row_5']  # Set the indexdf.index = index_  # Print the DataFrameprint(df)
Output :
Now we will use DataFrame.transpose() function to find the transpose of the given dataframe.
# return the transposeresult = df.transpose()  # Print the resultprint(result)
Output :As we can see in the output, the DataFrame.transpose() function has successfully returned the transpose of the given dataframe.
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.
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
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Java Program to Check if JVM is 32 or 64 bit - GeeksforGeeks

10 Mar, 2021
JVM Stands for Java Virtual Machine. It is an abstract computing machine that allows a computer to run a Java program.  It is a platform-independent environment, responsible for compiling Java programs by performing conversion of Java code into machine language i.e. byte code. The memory needed by JVM to run a Java program is called heap memory.
In Java, the getProperty() method is used to get information about various properties related to the system. Similarly, there two different approaches to check the bit of JVM by using System property “sun.arch.data.model” or “os. arch”. It will return either 32 bit or 64 bit based on your Java installation.  
Method required : get.Property()
Syntax:
String System.getProperty( String key )
Parameter:
Key is the property of the operating system
Return Type
1) Returns a string containing the value of the property
2) Returns Null if the property does not exist
There are basically 3 methods to check whether the JVM is 32 bit or 64 bit:-
Using sun.arch.data.model
Java
// Java Program to check bitness of JVM by// using System property "sun.arch.data.model"public class checkBit {    // get bitness of JVM    private static final String a        = System.getProperty("sun.arch.data.model");      public static void main(String[] args)    {        // printing the JVM version        System.out.println("JVM is " + a + " bit");    }}
Output:
Case 1: When JVM is 64 bit
Case 2: When JVM is 32 bit
Using os.arch.model
Java
// Java Program to check bitness of JVM by// using System property "os.arch.model"public class bit {    // get bitness of JVM    private static final String s        = System.getProperty("os.arch");      public static void main(String[] args)    {        // printing the of what bit JVM is        System.out.println("JVM is " + s + " bit");    }}
Output:
Case 1: When JVM is 64 bit
Case 2: When JVM is 32 bit
Note: There is another approach to check the bits of JVM without Java program is by executing instruction ‘java -version’ in command prompt.
Case 1: When JVM is 64 bit
Case 2: When JVM is 32 bit
java-JVM
Picked
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
Iterate through List in Java
MySQL | COALESCE( ) Function - GeeksforGeeks

21 Nov, 2019
The MySQL COALESCE() function is used for returning the first non-null value in a list of expressions. If all the values in the list evaluate to NULL, then the COALESCE() function returns NULL.
The COALESCE() function accepts one parameter which is the list which can contain various values. The value returned by the MySQL COALESCE() function is the first non-null value in a list of expressions or NULL if all the values in a list are NULL.
Syntax:
COALESCE(value_1, value_2, ...., value_n)
Parameters Used:
value_1 – It is used to specify the first value in the list.
Return Value:The MySQL COALESCE() function returns the first non-null value in a list of expressions or NULL if all the values in a list are NULL.
Supported Versions of MySQL:
MySQL 5.7
MySQL 5.6
MySQL 5.5
MySQL 5.1
MySQL 5.0
MySQL 4.1
MySQL 4.0
MySQL 3.23
Example-1: Implementing COALESCE() function on a list.
SELECT COALESCE(NULL, 'A', 'B', NULL); 
Output:
A 
Example-2: Implementing COALESCE() function on a list.
SELECT COALESCE('A', NULL, 'B', NULL); 
Output:
A 
Example-3: Implementing COALESCE() function on a list.
SELECT COALESCE(NULL, 1, 2, 3, NULL, 'B', NULL); 
Output:
1 
Example-4: Implementing COALESCE() function on a list.
SELECT COALESCE(NULL, NULL, 'geeksforgeeks', NULL); 
Output:
geeksforgeeks 
mysql
SQLmysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between SQL and NoSQL
Difference between DDL and DML in DBMS
SQL | Views
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Difference between DELETE and TRUNCATE
SQL | Subquery
Count number of vector values in range with R - GeeksforGeeks

28 Sep, 2021
In this article, we will see how to count the number of vector values present in the given range in R. To achieve this functionality we can follow the following approach.
Approach
Create vector
Set range
Iterate through the vector
Check for elements that are within the range
Add them
Display sum
Implementation using this approach is given below.
Example 1:
R
# declaring a integer point vectorvec <- c(1,12,3,14,-1,-3) # specifying the range to check the element inmin_range = -2max_range = 8 # computing the size of the vectorsize = length(vec) # declaring sum =0 as the count of elements in rangesum = 0 # looping over the vector elementsfor(i in 1:size) {     # check if elements lies in the range provided  if(vec[i]>=min_range && vec[i]<=max_range)     # incrementing count of sum if condition satisfied  sum =sum+1      } print ("Sum of elements in range : ")print (sum)
Output
[1] “Sum of elements in range : “
[1] 3
Example 2:
R
# declaring a integer point vectorvec <- c(1,12,3,14,-1,-3,0.1) # specifying the range to check the element inmin_range = -2max_range = 8print ("Sum of elements in specified range : ") # and operator check if the element is less than# max range and greater than min rangesum(vec>min_range & vec<max_range)
Output 
[1] “Sum of elements in specified range : “
[1] 4
However, if any of the elements of the vector is NA, then sum() method returns NA as the output. It can be ignored by specifying na.rm=TRUE.
Example 3:
R
# declaring a integer point vectorvec <- c(1,12,3,14,NA,-3,0.1) # specifying the range to check the element inmin_range = -2max_range = 8print ("Sum of elements in specified range without ignoring NA: ") # and operator check if the element is less than# max range and greater than min rangesum(vec>min_range & vec<max_range) print ("Sum of elements in specified range ignoring NA: ")sum(vec>min_range & vec<max_range,na.rm=TRUE)
Output
[1] “Sum of elements in specified range without ignoring NA: “
[1] NA
[1] “Sum of elements in specified range ignoring NA: “
[1] 3
simmytarika5
Picked
R Vector-Programs
R-Vectors
R Language
R Programs
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
How to Replace specific values in column in R DataFrame ?
How to change Row Names of DataFrame in R ?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
Remove rows with NA in one column of R DataFrame
Ruby | Enumerable max() function - GeeksforGeeks

05 Dec, 2019
The max() of enumerable is an inbuilt method in Ruby returns the maximum elements or an array containing the maximum N elements in the enumerable. When no block is given, it assumes all elements to be self comparable, but when the block is given then it is compared using .
Syntax: enu.max(n) { |a, b| block }
Parameters: The function takes two optional parameters n and block. N signifies the number of maximum elements and block determines the comparison property.
Return Value: It returns a max element or an array containing N max elements.
Example #1:
# Ruby program for max method in Enumerable  # Initialize enu1 = (2..6)    # Printsputs enu1.max   p enu1.max(2)
Output:
6
[6, 5]

Example #2:
# Ruby program for max method in Enumerable  # Initialize enu1 = [10, 17, 9, 10, 100, 34]    # Printsputs enu1.max { |a, b| a<=>b}   p enu1.max(2){ |a, b| a<=>b} 
Output:
100
[100, 34]

Ruby Enumerable-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Ruby | Array count() operation
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Hash delete() function
Ruby | Types of Variables
Ruby | Enumerator each_with_index function
Ruby | Case Statement
Ruby | Array select() function
Ruby | Data Types
Ruby | Numeric round() function
All palindrome numbers in a list?

Here we will see one simple problem. We have to find all numbers that are palindrome in nature in a given list. The approach is simple, take each number from list and check it is palindrome or not, and print the number.
Begin
   for each element e in arr, do
      if e is palindrome, then
         print e
      end if
   done
End
#include <iostream>
#include <cmath>
using namespace std;
bool isPalindrome(int n){
   int reverse = 0, t;
   t = n;
   while (t != 0){
      reverse = reverse * 10;
      reverse = reverse + t%10;
      t = t/10;
   }
   return (n == reverse);
}
int getAllPalindrome(int arr[], int n) {
   for(int i = 0; i<n; i++){
      if(isPalindrome(arr[i])){
         cout << arr[i] << " ";
      }
   }
}
int main() {
   int arr[] = {25, 145, 85, 121, 632, 111, 858, 45};
   int n = sizeof(arr) / sizeof(arr[0]);
   cout << "All palindromes: ";
   getAllPalindrome(arr, n);
}
All palindromes: 121 111 858
How to Create TreeMap in Java? - GeeksforGeeks

07 Jan, 2021
The TreeMap in Java is used to implement Map interface and NavigableMap along with the Abstract Class. The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used.
To create TreeMap we can use Map class or TreeMap class reference.
Example 1:
Java
// Java program demonstrate how to create a TreeMap  import java.util.*;  class GFG {      public static void main(String[] args)    {        // Declaring a treemap        TreeMap<Integer, String> map;          // Creating an empty TreeMap        map = new TreeMap<Integer, String>();          System.out.println("TreeMap successfully"                           + " created");    }}
TreeMap successfully created
Example 2:
Java
// Java program demonstrate how to create and add elements// to TreeMap  import java.util.*;  class GFG {    public static void main(String[] args)    {        // Creating an empty TreeMap using Map interface        Map<Integer, String> map = new TreeMap<>();                System.out.println("TreeMap successfully"                           + " created");          // Adding elements        map.put(1, "Geeks");        map.put(2, "for");        map.put(3, "Geeks");          // Printing TreeMap        System.out.println("TreeMap: " + map);    }}
TreeMap successfully created
TreeMap: {1=Geeks, 2=for, 3=Geeks}
Java-Collections
java-TreeMap
Picked
Java
Java Programs
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Different ways of Reading a text file in Java
Constructors in Java
Exceptions in Java
Generics in Java
Convert a String to Character array in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
Convert Python Nested Lists to Multidimensional NumPy Arrays - GeeksforGeeks

09 Jul, 2021
Prerequisite: Python List, Numpy ndarray
Both lists and NumPy arrays are inter-convertible. Since NumPy is a fast (High-performance) Python library for performing mathematical operations so it is preferred to work on NumPy arrays rather than nested lists.
Method 1: Using numpy.array().
Approach :
Import numpy package.
Initialize the nested list and then use numpy.array() function to convert the list to an array and store it in a different object.
Display both list and NumPy array and observe the difference.
Below is the implementation.
Python3
# importing numpy libraryimport numpy # initializing listls = [[1, 7, 0],       [ 6, 2, 5]] # converting list to arrayar = numpy.array(ls) # displaying listprint ( ls) # displaying arrayprint ( ar)
Output :
[[1, 7, 0], [6, 2, 5]]
[[1 7 0]
 [6 2 5]]
Method 2: Using numpy.asarray().
Approach :
Import numpy package.
Initialize the nested 4-dimensional list and then use numpy.asarray() function to convert the list to the array and store it in a different object.
Display both list and NumPy array and observe the difference.
Below is the implementation.
Python3
# importing numpy libraryimport numpy # initializing listls = [[1, 7, 0],[ 6, 2, 5],[ 7, 8, 9],[ 41, 10, 20]] # converting list to arrayar = numpy.asarray(ls) # displaying listprint ( ls) # displaying arrayprint ( ar)
Output :
[[1, 7, 0], [6, 2, 5], [7, 8, 9], [41, 10, 20]]
[[ 1  7  0]
 [ 6  2  5]
 [ 7  8  9]
 [41 10 20]]
abhishek0719kadiyan
Python numpy-ndarray
python-list
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Create a Pandas DataFrame from Lists
*args and **kwargs in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
sum() function in Python
Print lists in Python (4 Different Ways)
How to find the number of columns of an R data frame that satisfies a condition based on row values?

Sometimes we want to extract the count from the data frame and that count could be the number of columns that have same characteristics based on row values. For example, if we have a data frame containing three columns with fifty rows and the values are integers between 1 and 100 then we might want to find the number of columns that have value greater than 20 for each of the rows. This can be done by using rowSums function.
Consider the below data frame −
 Live Demo
> x1<-sample(1:10,20,replace=TRUE)
> x2<-sample(1:100,20)
> x3<-rpois(20,5)
> df<-data.frame(x1,x2,x3)
> df
 x1 x2 x3
1 9 72 9
2 5 20 6
3 3 82 4
4 5 47 4
5 1 45 10
6 6 14 6
7 10 54 7
8 10 13 6
9 4 98 5
10 4 76 5
11 5 53 5
12 9 87 2
13 3 79 6
14 2 73 5
15 10 75 3
16 1 7 2
17 5 92 7
18 5 34 5
19 9 52 5
20 5 43 4
Adding a new column to df with number columns having values greater than 5 −
> df$Number_of_columns_LargerThan5<-rowSums(df>5)
> df
 x1 x2 x3 Number_of_columns_LargerThan5
1 9 72 9    3
2 5 20 6    2
3 3 82 4    1
4 5 47 4    1
5 1 45 10   2
6 6 14 6    3
7 10 54 7   3
8 10 13 6   3
9 4 98 5    1
10 4 76 5   1
11 5 53 5   1
12 9 87 2   2
13 3 79 6   2
14 2 73 5   1
15 10 75 3  2
16 1 7 2    1
17 5 92 7   2
18 5 34 5   1
19 9 52 5   2
20 5 43 4   1
Adding a new column to df with number columns having values less than 5 −
> df$Number_of_columns_LessThan5<-rowSums(df<5)
> df
x1 x2 x3 Number_of_columns_LargerThan5 Number_of_columns_LessThan5
1 9 72 9          3                         1
2 5 20 6          2                         1
3 3 82 4          1                         3
4 5 47 4          1                         2
5 1 45 10         2                         2
6 6 14 6          3                         1
7 10 54 7         3                         1
8 10 13 6         3                         1
9 4 98 5          1                         2
10 4 76 5         1                         2
11 5 53 5         1                         1
12 9 87 2         2                         2
13 3 79 6         2                         2
14 2 73 5         1                         2
15 10 75 3        2                         2
16 1 7 2          1                         3
17 5 92 7         2                         1
18 5 34 5         1                         1
19 9 52 5         2                         1
20 5 43 4         1                         2
Let’s have a look at another example −
 Live Demo
> y1<-sample(1:100,20)
> y2<-sample(1:1000,20)
> df_y<-data.frame(y1,y2)
> df_y
   y1 y2
1 33 663
2 20 523
3 24 791
4 100 330
5 48 264
6 32 579
7 56 51
8 94 57
9 76 711
10 58 411
11 49 849
12 63 805
13 67 696
14 1 237
15 11 147
16 12 448
17 75 465
18 65 220
19 99 958
20 34 909
> df_y$Number_of_columns_less_than_equalto_50<-rowSums(df_y<=50)
> df_y
  y1 y2 Number_of_columns_less_than_equalto_50
1 33 663    1
2 20 523    1
3 24 791    1
4 100 330   0
5 48 264    1
6 32 579    1
7 56 51     0
8 94 57     0
9 76 711    0
10 58 411   0
11 49 849   1
12 63 805   0
13 67 696   0
14 1 237    1
15 11 147   1
16 12 448   1
17 75 465   0
18 65 220   0
19 99 958   0
20 34 909   1
TrimEnd() method in C#

The TrimEnd() method removes all trailing occurrences of a set of characters specified in an array.
For example, the following string has trailing 1s.
String str ="234561111".
We can easily remove the above trailing 1s from a string using the TrimEnd() method.
Let us see an example to remove all trailing 1s.
 Live Demo
using System;
class Program {
   static void Main() {

      String str ="234561111".TrimEnd(new Char[] { '1' } );
      Console.WriteLine(str);
   }
}
23456
Graph Plotting in Python

Python has the ability to create graphs by using the matplotlib library. It has numerous packages and functions which generate a wide variety of graphs and plots. It is also very simple to use. It along with numpy and other python built-in functions achieves the goal. In this article we will see some of the different kinds of graphs it can generate.
Here we take a mathematical function to generate the x and Y coordinates of the graph. Then we use matplotlib to plot the graph for that function. Here we can apply labels and show the title of the graph as shown below. We are plotting the graph for the trigonometric function − tan.
from matplotlib import pyplot as plt
import numpy as np
import math #needed for definition of pi
x = np.arange(0, math.pi*2, 0.05)
y = np.tan(x)
plt.plot(x,y)
plt.xlabel("angle")
plt.ylabel("Tan value")
plt.title('Tan wave')
plt.show()
Running the above code gives us the following result −
We can have two or more plots on a single canvas by creating multiple axes and using them in the program.
import matplotlib.pyplot as plt
import numpy as np
import math
x = np.arange(0, math.pi*2, 0.05)
fig=plt.figure()
axes1 = fig.add_axes([0.1, 0.1, 0.8, 0.8]) # main axes
axes2 = fig.add_axes([0.55, 0.55, 0.3, 0.3]) # inset axes
axes3 = fig.add_axes([0.2, 0.3, 0.2, 0.3]) # inset axes
axes1.plot(x, np.sin(x), 'b')
axes2.plot(x,np.cos(x),'r')
axes3.plot(x,np.tan(x),'g')
axes1.set_title('sine')
axes2.set_title("cosine")
axes3.set_title("tangent")
plt.show()
Running the above code gives us the following result −
We can also create a grid containing different graphs each of which is a subplot. For this we use the function subplot2grid. Here we have to choose the axes carefully so that all the subplots can fit in to the grid. A little hit an dtrail may be needed.
import matplotlib.pyplot as plt
a1 = plt.subplot2grid((3,3),(0,0),colspan = 2)
a2 = plt.subplot2grid((3,3),(0,2), rowspan = 3)
a3 = plt.subplot2grid((3,3),(1,0),rowspan = 2, colspan = 2)
import numpy as np
x = np.arange(1,10)
a2.plot(x, x*x,'r')
a2.set_title('square')
a1.plot(x, np.exp(x),'b')
a1.set_title('exp')
a3.plot(x, np.log(x),'g')
a3.set_title('log')
plt.tight_layout()
plt.show()
Running the above code gives us the following result:
Contour plots (sometimes called Level Plots) are a way to show a three-dimensional surface on a two-dimensional plane. It graphs two predictor variables X Y on the y-axis and a response variable Z as contours.Matplotlib contains contour() and contourf() functions that draw contour lines and filled contours, respectively.
import numpy as np
import matplotlib.pyplot as plt

xlist = np.linspace(-3.0, 3.0, 100)
ylist = np.linspace(-3.0, 3.0, 100)

X, Y = np.meshgrid(xlist, ylist)
Z = np.sqrt(X**2 + Y**2)

fig,ax=plt.subplots(1,1)
cp = ax.contourf(X, Y, Z)
fig.colorbar(cp) # Add a colorbar to a plot
ax.set_title('Filled Contours Plot')

#ax.set_xlabel('x (cm)')
ax.set_ylabel('y (cm)')
plt.show()
Running the above code gives us the following result:
HashMap in Java

The HashMap class uses a hashtable to implement the Map interface. This allows the execution time of basic operations, such as get( ) and put( ), to remain constant even for large sets.
Following is the list of constructors supported by the HashMap class.
Let us see another example −
import java.util.*;
public class Main {
   public static void main(String args[]) {
      HashMap hashMap = new HashMap();
      hashMap.put("John", new Integer(10000));
      hashMap.put("Tim", new Integer(25000));
      hashMap.put("Adam", new Integer(15000));
      hashMap.put("Katie", new Integer(30000));
      hashMap.put("Jacob", new Integer(45000));
      hashMap.put("Steve", new Integer(23000));
      hashMap.put("Nathan", new Integer(25000));
      hashMap.put("Amy", new Integer(27000));
      Set set = hashMap.entrySet();
      Iterator iterator = set.iterator();
      while(iterator.hasNext()) {
         Map.Entry map = (Map.Entry)iterator.next();
         System.out.print(map.getKey() + ": ");
         System.out.println(map.getValue());
      }
      System.out.println();
      System.out.println("Size of IdentintyHashMap: "+hashMap.size());
      int bonus = ((Integer)hashMap.get("Amy")).intValue();
      hashMap.put("Amy", new Integer(bonus + 5000));
      System.out.println("Amy's salary after bonus = " + hashMap.get("Amy"));
      int deductions = ((Integer)hashMap.get("Steve")).intValue();
      hashMap.put("Steve", new Integer(deductions - 3000));
      System.out.println("Steve's salary after deductions = " + hashMap.get("Steve"));
   }
}
Adam: 15000
Nathan: 25000
Katie: 30000
Steve: 23000
John: 10000
Tim: 25000
Amy: 27000
Jacob: 45000

Size of IdentintyHashMap: 8
Amy's salary after bonus = 32000
Steve's salary after deductions = 20000
Get first value in Java TreeSet

To get the first value in TreeSet, use the first() method.
First, get the TreeSet and add elements to it
TreeSet<String> tSet = new TreeSet<String>();
tSet.add("10");
tSet.add("20");
tSet.add("30");
tSet.add("40");
tSet.add("50");
tSet.add("60");
Now, get the first value
tSet.first()
The following is an example to get the first value in TreeSet
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String args[]){
      TreeSet<String> tSet = new TreeSet<String>();
      tSet.add("10");
      tSet.add("20");
      tSet.add("30");
      tSet.add("40");
      tSet.add("50");
      tSet.add("60");
      System.out.println("TreeSet elements...");
      Iterator i = tSet.iterator();
      while(i.hasNext()){
         System.out.println(i.next());
      }
      System.out.println("First Value = " + tSet.first());
   }
}
The output is as follows
TreeSet elements...
10
20
30
40
50
60
First Value = 10
Python - String Exercises

Now you have learned a lot about Strings, and how to use them in Python.
Are you ready for a test?
Try to insert the missing part to make the code work as expected:
Use the len method to print the length of the string.
x = "Hello World"
print()

Go to the Exercise section and test all of our Python Strings Exercises:

Python String Exercises

We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to pass reference parameters PHP?

In PHP, use &$ in function parameter to pass reference parameters.
The PHP code is as follows
 Live Demo
<!DOCTYPE html>
<html>
<body>
<?php
function referenceDemo(&$number){
   $number=$number+100;
   return $number;
}
$number=900;
echo "The actual value is=",$number,"<br>";
$result=referenceDemo($number);
echo "The modified value is=",$result;
?>
</body>
</html>
This will produce the following output 
The actual value is=900
The modified value is=1000