code-rag-bench/online-tutorials huggingface dataset:
Python | Append multiple lists at once

16 Aug, 2021
There can be an application requirement to append elements of 2-3 lists to one list. This kind of application has the potential to come into the domain of Machine Learning or sometimes in web development as well. Let’s discuss certain ways in which this particular task can be performed.
Method #1 : Using + operator This can be easily done using the plus operator as it does the element addition at the back of the list. Similar logic is extended in the case of multiple lists.
Python3
# Python3 code to demonstrate# adding multiple list at once# using + operator # initializing liststest_list1 = [1, 3, 5, 5, 4]test_list2 = [4, 6, 2, 8, 10]test_list3 = [7, 5, 2, 9, 11] # printing original listsprint ("The original list 1 is : " + str(test_list1))print ("The original list 2 is : " + str(test_list2))print ("The original list 3 is : " + str(test_list3)) # using + operator# adding multiple list at oncetest_list1 = test_list1 + test_list2 + test_list3     # printing resultprint ("The extended and modified list is : " +  str(test_list1))
Output:
The original list 1 is : [1, 3, 5, 5, 4]
The original list 2 is : [4, 6, 2, 8, 10]
The original list 3 is : [7, 5, 2, 9, 11]
The extended and modified list is : [1, 3, 5, 5, 4, 4, 6, 2, 8, 10, 7, 5, 2, 9, 11]
  Method #2 : Using itertools.chain() The chain function can also be employed to perform this particular tasks as it uses the iterator to perform this and hence offers better performance over the above method.
Python3
# Python3 code to demonstrate# adding multiple list at once# using itertools.chain()from itertools import chain # initializing liststest_list1 = [1, 3, 5, 5, 4]test_list2 = [4, 6, 2, 8, 10]test_list3 = [7, 5, 2, 9, 11] # printing original listsprint ("The original list 1 is : " + str(test_list1))print ("The original list 2 is : " + str(test_list2))print ("The original list 3 is : " + str(test_list3)) # using itertools.chain()# adding multiple list at oncetest_list1 = list(chain(test_list1, test_list2, test_list3))     # printing resultprint ("The extended and modified list is : " +  str(test_list1))
Output:
The original list 1 is : [1, 3, 5, 5, 4]
The original list 2 is : [4, 6, 2, 8, 10]
The original list 3 is : [7, 5, 2, 9, 11]
The extended and modified list is : [1, 3, 5, 5, 4, 4, 6, 2, 8, 10, 7, 5, 2, 9, 11]
jonnymonty
gulshankumarar231
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.
HTML | <button> formmethod Attribute

14 Feb, 2022
The HTML button formmethod Attribute is used to specify the HTTP method used to send data while submitting the form. There are two kinds of HTTP methods, which are GET and POST. this Attribute is only used with the Button type=”submit”
Syntax:
<button type="submit" formmethod="get|post">
Attribute values:
GET: In the GET method, after the submission of the form, the form values will be visible in the address bar of the new browser tab. It has a limited size of about 3000 characters. It is only useful for non-secure data not for sensitive information. It has a default value.
POST: In the post method, after the submission of the form, the form values will not be visible in the address bar of the new browser tab as it was visible in the GET method. It appends form data inside the body of the HTTP request. It has no size limitation. This method does not support bookmark the result.
Example: This Example illustrate the use of formmethod Attribute in Button Element.
<!DOCTYPE html><html>  <head>    <title>       Button Formmethod attribute    </title></head>  <body style="text-align: center">    <h1 style="color: green">      GeeksforGeeks    </h1>    <h4>      HTML Button Formmethod Attribute    </h4>    <form action="#" method="post"           enctype="multipart/form-data">        First name:        <input type="text" name="fname">        <br><br>        Last name:        <input type="text" name="lname">        <br><br>        Address:        <input type="text" name="Address">        <br><br>        <button type="submit" formmethod="GET">          submit using GET         </button>        <br>        <br>        <button type="submit" formenctype="text/plan"                 formmethod="POST">          submit using POST        </button>    </form></body>  </html>
Output:Supported Browsers: The browsers supported by HTML <button> Formmethod attribute are listed below:
Google Chrome 9.0
Internet Explorer 10.0
Firefox 4.0
Opera 10.6
Safari 5.1
hritikbhatnagar2182
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Angular File Upload
Design a web page using HTML and CSS
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Fix “Execution failed app:processDebugResources” in Android Studio

23 Jun, 2021
Resources are the files and static content that the application’s code uses, such as animations, images, layouts, and string values. These files stored in the resource directory can be referenced from the application’s code but when a non-existent reference is called android throws an “Execution failed app:processDebugResources” error. In this article, we will be discussing 5 different methods to solve this error.
Method 1: Change the version of buildTools
Method 2: Run Gradle with –stacktrace
Method 3: Add required libraries
Method 4: Clean project
Method 5: Invalid Caches/Restart
If the android SDK corresponding to the buildToolsVersion used in the app is not installed, make sure to change the buildToolsVersion to the latest Android SDK Build Tools version already installed.
Step 1: Navigate to Tools > SDK Manager
Step 2: Navigate to SDK Tools & click “Show Package Details” and look for the latest version of the Android SDK Build Tools Version installed.
Step 3: Navigate to app > Gradle Script > build.gradle (Module:app) and make sure the buildToolsVersion is the same as the latest version of the build tools already installed.
Step 4: Sync the project to solve the issue. 
(a) Make sure not to give any references to a non-existent string in the resources. A reference to a string not defined in the strings.xml file can cause this error.
(b) Make sure to follow the naming conventions in the layout, strings, color, attrs, styles, drawable, and various directories in the resources folder.
To find out what’s exactly causing the error, we can use the –stacktrace command. 
Step 1: Navigate to File > Settings.
Step 2: Navigate to Build, Execution, Deployment > Compiler and add “–stacktrace” in Command-line Options.
Step 3: Click Apply and OK. 
If you are running a 64-bit version of Ubuntu, install the 32-bit libraries with the following command:
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
If you are running 64-bit Fedora, install the libraries with the following command: 
sudo yum install zlib.i686 ncurses-libs.i686 bzip2-libs.i686
To find out how to add these libraries, please visit the official website https://developer.android.com/studio/install
A clean project removes the build artifacts and recompiles the project again, thereby solving the issue. Navigate to Build > Clean Project
The only way to solve some errors is to clean out the cached data which can be done by Navigating to File > Invalidate Caches/Restart > Invalidate Cache and Restart. 
Android-Studio
Picked
Android
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Add Views Dynamically and Store Data in Arraylist in Android?
Android SDK and it's Components
Flutter - Custom Bottom Navigation Bar
How to Communicate Between Fragments in Android?
Retrofit with Kotlin Coroutine in Android
How to Post Data to API using Retrofit in Android?
Flutter - Stack Widget
Introduction to Android Development
Activity Lifecycle in Android with Demo App
Fragment Lifecycle in Android
Type Annotations in Julia

12 Oct, 2020
Julia is a dynamically typed language i.e. the type of the variable need not be declared in the program statically. Along with this, it also provides a technique to comment on the type of variable to the Just-in-Time (JIT) compiler at the runtime. Moreover, Julia supports both dynamic as well as static typing. This distinctive feature of Julia differentiates it from the other programming languages.
Type-annotating variables in Julia can be done using the :: operator. This operator confirms that the value on the left is the same type as the value on the right.
Syntax: 
<expr>::<type>
where,
expr: It can be  an expression for computing a value or an assignment statement for a variable or an declaration of a variable.
type: It is the data type of the variable being used in the program.
Julia type annotations can be used for two types of expressions:
Type Assert: It is an expression that is used for computing a certain value of a variable.
Example 1 :
Julia
# Julia program to illustrate Type Assertionb = 10  # assures at runtime that 'b' will be an integera = b :: Int       print(a)
Output:
Example 2:
Julia
# Julia program to illustrate Type Assertionc = 20.5d = 30.4  # assures at runtime that 'c+d' will be a float64c + d::Float64     print(c + d)
Output:
Example 3:
Julia
# Julia program to illustrate Type Assertionc = 10.5  # assures at runtime that 'c+c' will be an integer  c + c::Int
Output:
ERROR: TypeError: in typeassert, expected Int64, got a value of type Float64
Stacktrace:
[1] top-level scope at REPL[2]:1

Variable Type Declaration:
These are left-hand sides of assignments or declarations of local variables.
It also covers type fields of a struct and named tuples.
Function arguments and return type can also be type-annotated.
Example 4:
Julia
# Julia program for variable type declarationstruct example    # this field will always contain only integer values  x ::Int   end  x = 20print(x)
Output:
Example 5:
Julia
# Julia program for variable type declarationstruct Person    # this field will always contain only string values  name::String     # this field will always contain only integer values  age::Int   end  p = Person("Max", 24)
 Output:
Example 6: 
Julia
# Function accepting Float64 value # and returning a Float32 value  function example(x ::Float64) ::Float32      cos(π * x)  end  # calling the functionresult = example(1.5)  # print resultprint(result)
Output:
Julia Data-science
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Vectors in Julia
Getting rounded value of a number in Julia - round() Method
Manipulating matrices in Julia
Reshaping array dimensions in Julia | Array reshape() Method
Storing Output on a File in Julia
Exception handling in Julia
Formatting of Strings in Julia
Tuples in Julia
Creating array with repeated elements in Julia - repeat() Method
Get array dimensions and size of a dimension in Julia - size() Method
multiset find() function in C++ STL

07 Jul, 2022
The multiset::find() is a built-in function in C++ STL which returns an iterator pointing to the lower_bound of the element which is searched in the multiset container. If the element is not found, then the iterator points to the position past the last element in the set. 
Syntax:
multiset_name.find(element)
Parameters: The function accepts one mandatory parameter element which specifies the element to be searched in the multiset container. 
Return Value: The function returns an iterator which points to the element which is searched in the multiset container. If the element is not found, then the iterator points to the position just after the last element in the multiset. 
Time complexity: If n is the size of multiset, then the time complexity of multiset::find() function is logarithmic order of n i.e. O(log(n)). 
Below program illustrates the above function.
 Program 1: 
CPP
// CPP program to demonstrate the// multiset::find() function#include <bits/stdc++.h>using namespace std;int main(){   // Initialize multiset  multiset<int> s;   s.insert(1);  s.insert(4);  s.insert(2);  s.insert(5);  s.insert(3);  s.insert(3);  s.insert(3);  s.insert(5);   cout << "The set elements are: ";  for (auto it = s.begin(); it != s.end(); it++)    cout << *it << " ";   // iterator pointing to  // position where 2 is  auto pos = s.find(3);   // prints the set elements  cout << "\nThe set elements after 3 are: ";  for (auto it = pos; it != s.end(); it++)    cout << *it << " ";   return 0;}
The set elements are: 1 2 3 3 3 4 5 5 
The set elements after 3 are: 3 3 3 4 5 5
Program 2: 
CPP
// CPP program to demonstrate the// multiset::find() function#include <bits/stdc++.h>using namespace std;int main(){   // Initialize multiset  multiset<char> s;   s.insert('a');  s.insert('a');  s.insert('a');  s.insert('b');  s.insert('c');  s.insert('a');  s.insert('a');  s.insert('c');   cout << "The set elements are: ";  for (auto it = s.begin(); it != s.end(); it++)    cout << *it << " ";   // iterator pointing to  // position where 2 is  auto pos = s.find('b');   // prints the set elements  cout << "\nThe set elements after b are: ";  for (auto it = pos; it != s.end(); it++)    cout << *it << " ";   return 0;}
The set elements are: a a a a a b c c 
The set elements after b are: b c c
rishabhpandey7681
CPP-Functions
cpp-multiset
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Primitive Wrapper Classes are Immutable in Java

12 Dec, 2021
In Java, an immutable class is a class (Integer, Byte, Long, Float, Double, Character, Boolean, and Short) which once created then its body can not be changed and the same applies to immutable objects which once created cannot be changed. Now the question arises that we do need the help of wrapper classes while dealing with primitive data types in Java where these classes are made immutable. 
Geeks, now you must be wondering why do we make them as immutable for which we will be listing some advantages as listed below as follows:
They are automatically synchronized as their state them can not be altered by virtue of the definition of immutability.
There are zero scopes of inconsistency as an object of the wrapper class can not be altered.
It helps in caching as one instance of a specific type itself can facilitate dozen of applications.
Tip: Best usage of wrapper classes as immutable objects is as keys of the Map.  
Example:
Java
// Java Program to Demonstrate that Primitive// Wrapper Classes are Immutable // Main classclass GFG {     // Main driver method    public static void main(String[] args)    {         // Getting an integer value        Integer i = new Integer(12);         // Printing the same integer value        System.out.println(i);         // Calling method 2        modify(i);         // Now printing the value stored in above integer        System.out.println(i);    }     // Method 2    // To modify integer value    private static void modify(Integer i) { i = i + 1; }}
Output:
Output explanation: 
Here the parameter ‘i’ is the reference in modifying and refers to the same object as ‘i’ in main(), but changes made to ‘i’ are not reflected in main() method. It is because all primitive wrapper classes (Integer, Byte, Long, Float, Double, Character, Boolean, and Short) are immutable in Java, so operations like addition and subtraction create a new object and not modify the old. The below line of code in the modify method is operating on wrapper class Integer, not an int, and does the following as described below as follows:
i = i + 1;
Unbox ‘i’ to an int value
Add 1 to that value
Box the result into another Integer object
Assign the resulting Integer to ‘i’ (thus changing what object ‘i’ references)
Since object references are passed by value, the action taken in the modified method does not change i that was used as an argument in the call to modify. Thus the main routine still prints 12 after the method returns.
This article is contributed by Yogesh D Doshi. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
simmytarika5
solankimayank
sweetyty
java-wrapper-class
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Split() String method in Java with examples
Arrays.sort() in Java with examples
Reverse a string in Java
Object Oriented Programming (OOPs) Concept in Java
For-each loop in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
Stream In Java
Map of pairs in STL

18 Oct, 2017
Map in STL is used to hash key and value. We generally see map being used for standard data types. We can also use map for pairs.
For example consider a simple problem, given a matrix and positions visited, print which positions are not visited.
// C++ program to demonstrate use of map// for pairs#include <bits/stdc++.h>using namespace std;  map<pair<int, int>, int> vis;  // Print positions that are not marked// as visitedvoid printPositions(int a[3][3]){    for (int i = 0; i < 3; i++)        for (int j = 0; j < 3; j++)            if (vis[{ i, j }] == 0)                cout << "(" << i << ", " << j << ")"                     << "\n";}  int main(){    int mat[3][3] = { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 } };      // Marking some positions as visited    vis[{ 0, 0 }] = 1; // visit (0, 0)    vis[{ 1, 0 }] = 1; // visit (1, 0)    vis[{ 1, 1 }] = 1; // visit (1, 1)    vis[{ 2, 2 }] = 1; // visit (2, 2)      // print which positions in matrix are not visited by rat    printPositions(mat);    return 0;}
Output:
(0, 1)
(0, 2)
(1, 2)
(2, 0)
(2, 1)

This article is contributed by Abhishek Rajput. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
cpp-pair
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C | Operators | Question 1

08 May, 2017
#include "stdio.h"
int main() 
{ 
  int x, y = 5, z = 5; 
  x = y == z; 
  printf("%d", x); 
  
  getchar(); 
  return 0; 
}

(A) 0(B) 1(C) 5(D) Compiler Error
Answer: (B)
 
Explanation: The crux of the question lies in the statement x = y==z. The operator == is executed before = because precedence of comparison operators (<=, >= and ==) is higher than assignment operator =.The result of a comparison operator is either 0 or 1 based on the comparison result. Since y is equal to z, value of the expression y == z becomes 1 and the value is assigned to x via the assignment operator.
C Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C | Dynamic Memory Allocation | Question 5
C | Advanced Pointer | Question 9
C | File Handling | Question 5
C | Loops & Control Structure | Question 5
C | Advanced Pointer | Question 2
C | Advanced Pointer | Question 3
C | Advanced Pointer | Question 4
C | Pointer Basics | Question 7
C | File Handling | Question 3
C | Structure & Union | Question 2
Calendar set() Method in Java with Examples

21 Feb, 2019
The set(int calndr_field, int new_val) method in Calendar class is used to set the calndr_field value to a new_val. The older field of this calendar get replaced by a new field.
Syntax:
public void set(int calndr_field, int new_val)
Parameters: The method takes two parameters:
calndr_field: This is of Calendar type and refers to the field of the calendar that is to be altered.
new_val: This refers to the new value that is to be replaced with.
Return Value: The method does not return any value.
Below programs illustrate the working of set() Method of Calendar class:Example 1:
// Java code to illustrate// set() method  import java.util.*;public class Calendar_Demo {    public static void main(String args[])    {          // Creating a calendar        Calendar calndr = Calendar.getInstance();          // Displaying the month        System.out.println("The Current Month is: "                           + calndr.get(                                 Calendar.MONTH));          // Replacing with a new value        calndr.set(Calendar.MONTH, 11);          // Displaying the modified result        System.out.println("Altered Month is: "                           + calndr.get(                                 Calendar.MONTH));    }}
The Current Month is: 1
Altered Month is: 11

Example 2:
// Java code to illustrate// set() method  import java.util.*;public class Calendar_Demo {    public static void main(String args[])    {          // Creating a calendar        Calendar calndr = Calendar.getInstance();          // Displaying the Year        System.out.println("The Current year is: "                           + calndr.get(                                 Calendar.YEAR));          // Replacing with a new value        calndr.set(Calendar.YEAR, 1996);          // Displaying the modified result        System.out.println("Altered year is: "                           + calndr.get(                                 Calendar.YEAR));    }}
The Current year is: 2019
Altered year is: 1996

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/Calendar.html#set-int-int-
Java - util package
Java-Calendar
Java-Functions
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
Stream In Java
ArrayList in Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Set in Java
Python – Multimode of List

10 Feb, 2020
Sometimes, while working with Python lists we can have a problem in which we need to find mode in list i.e most frequently occurring character. But sometimes, we can have more than 1 modes. This situation is called multimode. Lets discuss certain ways in which this task can be performed.
Method #1 : Using loop + formulaThe simpler manner to approach this problem is to employ the formula for finding multimode and perform using loop shorthands. This is the most basic approach to solve this problem.
# Python3 code to demonstrate working of # Multimode of List# using loop + formula import mathfrom collections import Counter  # initialize list test_list = [1, 2, 1, 2, 3, 4, 3]   # printing original list print("The original list is : " + str(test_list))   # Multimode of List# using loop + formula res = []test_list1 = Counter(test_list) temp = test_list1.most_common(1)[0][1] for ele in test_list:  if test_list.count(ele) == temp:    res.append(ele)res = list(set(res))  # printing result print("The multimode of list is : " + str(res)) 
The original list is : [1, 2, 1, 2, 3, 4, 3]
The multimode of list is : [1, 2, 3]

 
Method #2 : Using statistics.multimode()This task can also be performed using inbuilt function of mulimode(). This is new in Python versions >= 3.8.
# Python3 code to demonstrate working of # Multimode of List# using statistics.multimode() import statistics   # initialize list test_list = [1, 2, 1, 2, 3, 4, 3]   # printing original list print("The original list is : " + str(test_list))   # Multimode of List# using statistics.multimode() res = statistics.multimode(test_list)   # printing result print("The multimode of list is : " + str(res)) 
The original list is : [1, 2, 1, 2, 3, 4, 3]
The multimode of list is : [1, 2, 3]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Determine Period Index and Column for DataFrame in Pandas

11 Jun, 2021
In Pandas to determine Period Index and Column for Data Frame, we will use the pandas.period_range() method. It is one of the general functions in Pandas that is used to return a fixed frequency PeriodIndex, with day (calendar) as the default frequency.
Syntax: pandas.to_numeric(arg, errors=’raise’, downcast=None)
Parameters:start : Left bound for generating periodsend : Right bound for generating periodsperiods : Number of periods to generatefreq : Frequency aliasname : Name of the resulting PeriodIndex
Returns: PeriodIndex
Example 1:
Python3
import pandas as pd   course = ["DBMS", "DSA", "OOPS",          "System Design", "CN", ] # pass the period and starting indexwebinar_date = pd.period_range('2020-08-15', periods=5) # Determine Period Index and Column# for DataFramedf = pd.DataFrame(course, index=webinar_date, columns=['Course']) df
 
 
Output:
 
 
Example 2:
 
Python3
import pandas as pd day = ["Sun", "Mon", "Tue",       "Wed", "Thurs", "Fri", "Sat"] # pass the period and starting indexdaycode = pd.period_range('2020-08-15', periods=7) # Determine Period Index and Column for DataFramedf = pd.DataFrame(day, index=daycode, columns=['day']) df
 
 
Output:
 
 
Example 3:
 
Python3
import pandas as pd Team = ["Ind", "Pak", "Aus"] # pass the period and starting indexmatch_date = pd.period_range('2020-08-01', periods=3) # Determine Period Index and Column for DataFramedf = pd.DataFrame(Team, index=match_date, columns=['Team']) df
 
 
Output:
 
 
khushboogoyal499
Python Pandas-exercise
Python pandas-general-functions
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Conditioning Plot - GeeksforGeeks

24 Sep, 2021
A conditioning plot or co-plot or subset plot is a scatter plot of two variables when conditioned on a third variable. The third variable is called the conditioning variable. This variable can have both values either continuous or categorical. In the continuous variable, we created subsets by dividing them into a smaller range of values. In categorical variables, the subsets are created based on different categories.
Let’s take three variables X, Y and Z. Z be the variable which we divided into the k groups. Here, there are many ways in which a group can be formed such as:
By dividing the data into equal size of k groups.
By dividing the data into different clusters on the basis of scatter plot.
By dividing the range of data points into equal values.
The categorical data have natural grouping on the basis of different categories of the dataframe.
Then, we plot n rows and m columns matrix where n*m >= k. Each set of (row, column) represents an individual scatter plot, in which each scatters plot consists of the following components.
Vertical Axis: Variable Y
Horizontal Axis: Variable X
where, points in the group corresponding to row i and column j are used. 
The conditioning plot provides the answer to the following questions:
Is there any relationship between the two variables?
If there is a relationship then, does the nature of the relationship depend upon the third variable?
Do different groups in the data behave similarly?
Are there any outliers in the data?
Python3
# code% matplotlib inlineimport numpy as npimport seaborn as snsimport matplotlib.pyplot as pltimport pandas as pd # load training file for titanic datasettitanic_dataset =pd.read_csv('train.csv') # head of datasettitanic_dataset.head() # conditioning plot on the basis of categorical variablessns.lmplot(x='Age', y ='Fare',hue='Survived', col ='Sex',data=titanic_dataset)sns.lmplot(x='Age', y ='Fare',hue='Survived', col ='Pclass',data=titanic_dataset) # conditioning plot on the basis of continuous variablesdf1, df2 = titanic_dataset.loc[titanic_dataset['Age'] < 20 ] ,    titanic_dataset.loc[titanic_dataset['Age'] >= 20 ]  lm = sns.lmplot(x='Parch', y ='Fare',hue='Survived',data=df1)ax1 =lm.axesax1=plt.gca()ax1.set_title('Age < 20') lm_2 = sns.lmplot(x='Parch', y ='Fare',hue='Survived',data=df2) ax2 =lm_2.axesax2=plt.gca()ax2.set_title('Age >= 20')
Conditional Plot on the basis of Sex
Conditional Plot on the basis of Passenger_Class
Conditional Plot on the basis of Age
NIST handbook
sagar0719kumar
anikaseth98
ML-Statistics
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Linear Regression
Activation functions in Neural Networks
Python | Decision tree implementation
Support Vector Machine Algorithm
ML | Underfitting and Overfitting
Read JSON file using Python
Python map() function
How to get column names in Pandas dataframe
Python Dictionary
Taking input in Python
How to label specific points in scatter plot in R ? - GeeksforGeeks

13 Jul, 2021
Scatter plots in the R programming language can be plotted to depict complex data easily and graphically. It is used to plot points, lines as well as curves. The points can be labeled using various methods available in base R and by incorporating some external packages.
The ggplot() method can be used in this package in order to simulate graph customizations and induce flexibility in graph plotting. 
Syntax:
ggplot(data = <DATA>, mapping = aes(<MAPPINGS>)) +  <GEOM_FUNCTION>()
The data can be binded into the scatter plot using the data attribute of the ggplot method. The mapping in the function can be induced using the aes() function to create aesthetic mapping, by filtering the variables to be plotted on the scatter plot. We can also specify how to depict different components in the graph, for instance, the x and y axes positions, the labels to assign to these points or characteristics such as size, shape, color, etc.
This method also allows the addition of various geoms- that is the components of graph. geom_point() is used for creation of scatter plot. geom_label() is used to understand the aesthetics specified to the ggplot. 
Example:
R
library(ggplot2) # creating a data framedf <- data.frame(col1 = c(1:5),                 col2 = c(4:8),                 col3 = letters[1:5]                       )print ("Original DataFrame") # plotting the dataggplot(aes(x=col1, y=col2, label=col3), data=df) +  geom_point() +  geom_label()
Output
The plot() method in Base R is used to plotting the R objects, namely, lists or data frames. 
Syntax:
plot(x, y, data , col)
Parameter : 
x,y – The x and y coordinates of the points
col – The color to assign to the points. The color is specified using a character string. 
data – The data frame points to be plotted in the graph
The text method can be used to customize the plots to add string names to the plotted points. 
Syntax:
text (x, y , labels , data) 
Parameter : 
x, y – The coordinates of the points to label
labels – the vector of labels to be added 
data – the data to use for plotting
Example:
R
# creating a data framedf <- data.frame(col1 = c(1:5),                 col2 = c(4:8),                 col3 = letters[1:5]                       ) print ("Original DataFrame") # plotting the dataplot(col1 ~col2 , col="red", cex=2, data= df ) # adding text to the datatext(col1  ~ col2, labels= col3 ,data=df , cex=0.9)
 
 
Output
 
 
kapoorsagar226
Picked
R-Charts
R-ggplot
R-Graphs
R-plots
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Control Statements in R Programming
Change Color of Bars in Barchart using ggplot2 in R
Data Visualization in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
Logistic Regression in R Programming
Linear Discriminant Analysis in R Programming
How to filter R DataFrame by values in a column?
How to change Colors in ggplot2 Line Plot in R ?
How to import an Excel File into R ?
How to use the return statement in C#?

The return statement is used to return value. When a program calls a function, the program control is transferred to the called function. A called function performs a defined task and when its return statement is executed or when its function-ending closing brace is reached, it returns the program control back to the main program.
The following is an example to learn about the usage of return statement in C#. Here, we are finding the factorial of a number and returning the result using the return statement.
while (n != 1) {
   res = res * n;
   n = n - 1;
}
return res;
Here is the complete example.
 Live Demo
using System;
namespace Demo {
   class Factorial {
      public int display(int n) {
         int res = 1;
         while (n != 1) {
            res = res * n;
            n = n - 1;
         }
         return res;
      }
      static void Main(string[] args) {
         int value = 5;
         int ret;
         Factorial fact = new Factorial();
         ret = fact.display(value);
         Console.WriteLine("Value is : {0}", ret );
         Console.ReadLine();
      }
   }
}
Value is : 120
Input Iterators in C++

In this tutorial, we will be discussing a program to understand input iterators in C++.
Input iterators are one of the five iterators in STL being the weakest and simplest of all. They are mostly used in serial input operations where each value is read one and then the iterator moves to the next one.
 Live Demo
#include <iostream>
#include <vector>
using namespace std;
int main(){
   vector<int> v1 = { 1, 2, 3, 4, 5 };
   //declaring iterator
   vector<int>::iterator i1;
   for (i1 = v1.begin(); i1 != v1.end(); ++i1) {
      //looping over elements via iterator
      cout << (*i1) << " ";
   }
   return 0;
}
1 2 3 4 5
Relational Operators in C++

In C++ Programming, the values stored in two variables can be compared using following operators and relation between them can be determined. These operators are called relational operators. Various C++ relational operators available are −
You can use these operators for checking the relationship between the operands. These operators are mostly used in conditional statements and loops to find a relation between 2 operands and act accordingly. For example,
#include<iostream>
using namespace std;
int main() {
   int a = 3, b = 2;
   if(a < b) {
      cout<< a << " is less than " << b;
   }
   else if(a > b) {
      cout<< a << " is greater than " << b;
   }
   else if(a == b){
      cout << a << " is equal to " << b;
   }
   return 0;
}
This will give the output −
3 is greater than 2
How to connect to the Azure subscription using Azure CLI in PowerShell?

To connect to the specific azure subscription using Az CLI we need to use “Az account set” command but before using this command make sure you are connected with the Azure cloud using “az login” account.
az account set --subscription 'subscription name or id'
You can also use -s instead of --subscription.
az account set -s 'subscription name or id'
To check if the subscription is set properly, use the below command.
PS C:\> az account show -otable
Ruby | String length Method

08 Jan, 2020
length is a String class method in Ruby which is used to find the character length of the given string.
Syntax: str.length
Parameters: Here, str is the string whose length is to be calculated
Returns:It will return the character length of the str.
Example 1:
# Ruby program to demonstrate# the length method   # Taking a string and# using the methodputs "GFG".lengthputs "geeksforgeeks".length
Output:
3
13

Example 2:
# Ruby program to demonstrate# the length method   # Taking a string and# using the methodputs "g4g".lengthputs "ruby string".length
Output:
3
11

Ruby String-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Global Variable in Ruby
Ruby | Array select() function
Ruby | Enumerator each_with_index function
Ruby | Case Statement
Ruby | unless Statement and unless Modifier
Ruby | Hash delete() function
Ruby | Data Types
Ruby | String capitalize() Method
Ruby | String gsub! Method
numpy.rot90() in Python

09 Mar, 2022
The numpy.rot90() method performs rotation of an array by 90 degrees in the plane specified by axis(0 or 1).Syntax:
numpy.rot90(array, k = 1, axes = (0, 1))
Parameters :
array : [array_like]i.e. array having two or more dimensions.
k     : [optional , int]No. of times we wish to rotate array by 90 degrees.
axes  : [array_like]Plane, along which we wish to rotate array.

Returns :
rotated copy of array

# Python Program illustrating# numpy.rot90() method  import numpy as geek  array = geek.arange(12).reshape(3, 4)print("Original array : \n", array)  # Rotating array 4 times : Returns same original arrayprint("\nArray being rotated 4 times : \n", geek.rot90(array, 4))  # Rotating onceprint("\nRotated array : \n", geek.rot90(array))  # Rotating twiceprint("\nRotated array : \n", geek.rot90(array, 2))
Output :
Original array : 
 [[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]

Array being rotated 4 times : 
 [[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]]

Rotated array : 
 [[ 3  7 11]
 [ 2  6 10]
 [ 1  5  9]
 [ 0  4  8]]

Rotated array : 
 [[11 10  9  8]
 [ 7  6  5  4]
 [ 3  2  1  0]]

References :https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.rot90.html
Note :These codes won’t run on online IDE’s. 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.
vinayedula
Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
size element method – Selenium Python

30 Apr, 2020
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. To open a webpage using Selenium Python, checkout – Navigating links using get method – Selenium Python. Just being able to go to places isn’t terribly useful. What we’d really like to do is to interact with the pages, or, more specifically, the HTML elements within a page. There are multiple strategies to find an element using Selenium, checkout – Locating Strategies
This article revolves around how to use size method in Selenium. size method is used to get size of current element.
element.size
Example –
<input type="text" name="passwd" id="passwd-id" />
To find an element one needs to use one of the locating strategies, For example,
element = driver.find_element_by_id("passwd-id")
element = driver.find_element_by_name("passwd")
element = driver.find_element_by_xpath("//input[@id='passwd-id']")
Also, to find multiple elements, we can use –
elements = driver.find_elements_by_name("passwd")
Now one can get size of this element with –
element.size
Let’s try to get element and its size at geeksforgeeks using size method.Program –
# import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # get element element = driver.find_element_by_id("gsc-i-id2")  # get rectprint(element.size)
Output-
Terminal Output –
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Create a directory in Python
How to use R to download file from internet ?

09 Jul, 2021
In this article, we will be looking at the approach to download any type of file from the internet using R Programming Language. To download any type of file from the Internet download.file() function is used. This function can be used to download a file from the Internet.
Syntax: download.file(url, destfile, method, quiet = FALSE, mode = “w”, cacheOK = TRUE, extra = getOption(“download.file.extra”),headers = NULL, ...)
Parameters:
URL:-a character string (or longer vector e.g., for the “libcurl” method) naming the URL of a resource to be downloaded.
destfile:-a character string (or vector, see URL) with the name where the downloaded file is saved.
method:-Method to be used for downloading files.
Returns: It will save the downloaded file to the provided destination.
In this approach for Downloading any type of file using download.file() function in R language user just need to call the download.file() function which is one of the inbuilt functions of R language and passes the URL of the file which is needed to be downloaded and the destination address for saving the downloaded file.
Under this example, we will be simply assigning a URL variable to the link to a sample CSV file from the internet and setting the destination address for the downloaded file ad then calling the download.file() function and pass the URL and destination address as the parameter.
File to be downloaded: Sample-Spreadsheet-1000-rows
Program:
R
# Specify URL where file is storedurl <- "https://sample-videos.com/csv/Sample-Spreadsheet-1000-rows.csv"  destination<- "C:/Users/Geetansh Sahni/Documents/downloaded_gfg.csv"  download.file(url, destination)
Output:
Under this example, we will be simply assigning a URL variable to the link to a sample PDF file from the internet and setting the destination address for the downloaded file ad then calling the download.file() function and pass the URL and destination address as the parameter.
File to be downloaded: sample
Program:
R
# Specify URL where file is storedurl <- "https://cin.ufpe.br/~fbma/Crack/Cracking%20the%20Coding%       20Interview%20189%20Programming%20Questions%20       and%20Solutions.pdf"  destination<- "C:/Users/Geetansh Sahni/Documents/downloaded_gfg.pdf"  download.file(url, destination)
Output:
Picked
Web-scraping
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
R - if statement
Logistic Regression in R Programming
How to filter R DataFrame by values in a column?
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
How to set NOW() as default value for datetime datatype in MySQL?

We can set the now() function as a default value with the help of dynamic default. First, we will create a table with data type” datetime”. After that, we will set now() as the default value for column “MyTime” as shown below.
Creating a table.
mysql> create table DefaultDateTimeDemo
   -> (
   -> MyTime datetime default CURRENT_TIMESTAMP
   -> );
Query OK, 0 rows affected (0.59 sec)
After creating the above table, we won’t insert any value while using the insert command. This is done so that we can get the default date time with the help of dynamic value default.
Here is the query to insert records.
mysql> insert into DefaultDateTimeDemo values();
Query OK, 1 row affected (0.13 sec)
Now, we can check whether the default value now() is added or not. Here is the query to display records.
mysql> select *from DefaultDateTimeDemo;
The following is the output that shows the current date and time.
+---------------------+
| MyTime              |
+---------------------+
| 2018-11-09 11:58:47 |
+---------------------+
1 row in set (0.00 sec)

Now, we can verify whether the result is correct or not with the help of now() method. Here is the query to check the result.
mysql> select now();
The following is the output.
+---------------------+
| now()               |
+---------------------+
| 2018-11-09 11:58:40 |
+---------------------+
1 row in set (0.00 sec)

Look at the sample output above. Both of them gives the same result.
Python | Reverse Slicing of given string - GeeksforGeeks

04 Jul, 2019
Sometimes, while working with strings we might have a problem in which we need to perform the reverse slicing of string, i.e slicing the string for certain characters from the rear end. Let’s discuss certain ways in which this can be done.
Method #1 : Using join() + reversed()The combination of above function can be used to perform this particular task. In this, we reverse the string in memory and join the sliced no. of characters so as to return the string sliced from rear end.
# Python3 code to demonstrate working of# Reverse Slicing string # Using join() + reversed()  # initializing string test_str = "GeeksforGeeks"  # printing original string print("The original string is : " + test_str)  # initializing K K = 7  # Using join() + reversed()# Reverse Slicing string res = ''.join(reversed(test_str[0:K]))  # printing result print("The reversed sliced string is : " + res)
The original string is : GeeksforGeeks
The reversed sliced string is : ofskeeG

 
Method #2 : Using string slicingThe string slicing can be used to perform this particular task, by using “-1” as the third argument in slicing we can make function perform the slicing from rear end hence proving to be a simple solution.
# Python3 code to demonstrate working of# Reverse Slicing string # Using string slicing  # initializing string test_str = "GeeksforGeeks"  # printing original string print("The original string is : " + test_str)  # initializing K K = 7  # Using string slicing# Reverse Slicing string res = test_str[(K-1)::-1]  # printing result print("The reversed sliced string is : " + res)
The original string is : GeeksforGeeks
The reversed sliced string is : ofskeeG

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Create a Pandas DataFrame from Lists
*args and **kwargs in Python
Check if element exists in list in Python
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 print without newline in Python?