code-rag-bench/online-tutorials huggingface dataset:
PHP - Function popen()

The popen() function can open a pipe to the program specified in the command parameter, and return false if an error occurs. 
resource popen ( string $command , string $mode )

 This function can open a pipe to the process executed by forking the command given by command. 
<?php
   $handle = popen("/bin/ls", "r");
?>

    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
Navigating links using get method - Selenium Python - GeeksforGeeks

10 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. Through Selenium Python API you can access all functionalities of Selenium WebDriver in an intuitive way. This article illustrates about how to use Selenium Python to navigate to any link on web using get method of Selenium Webdriver in python.
If you have not installed Selenium and its components yet, install them from here – Selenium Python Introduction and Installation.
The first thing one’ll want to do with WebDriver is navigate to a link. The normal way to do this is by calling get method:Syntax –
driver.get(url)

Example-
driver.get("http://www.google.com")
WebDriver will wait until the page has fully loaded (that is, the onload event has fired) before returning control to your test or script. It’s worth noting that if your page uses a lot of AJAX on load then WebDriver may not know when it has completely loaded. If you need to ensure such pages are fully loaded then you can use waits.
Project Example –After you have installed Selenium, create a file called run.py as –Program –
# Python program to demonstrate# selenium  # import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # get google.co.indriver.get("https://google.co.in / search?q = geeksforgeeks")
Output-
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Adding new column to existing DataFrame in Pandas
Python map() function
Read JSON file using Python
How to get column names in Pandas dataframe
Enumerate() in Python
How to Install PIP on Windows ?
Python OOPs Concepts
Read a file line by line in Python
Iterate over a list in Python
Different ways to create Pandas Dataframe
Intuitive Understanding of Logistic Regression (python) | by Andrew Hershy | Towards Data Science

A logistic regression is a model used to predict the “either-or” of a target variable. The example we will be working on is:
Target variable: Student will pass or fail the exam.
Independent variable: Hours spent studying per week
Logistic models are essentially linear models with an extra step. In logistic models, a linear regression is ran through a “sigmoid function” which compresses its output into dichotomous 1’s and 0’s.
If we wanted to predict actual test scores, we would use a linear model. If we wanted to predict “pass”/ “fail”, we would use a logistic regression model.
y = b0 + b1x
p = 1 / 1 + e ^-(b0 + b1x)
In the image below, the straight line is linear , and the “S” shaped line is logistic. Logistic regressions have higher accuracy when used for “either-or” models due to their shape.
import numpy as npimport pandas as pdimport matplotlib.pyplot as plt%matplotlib inlinedf = pd.read_excel(r”C:\Users\x\x\Log_test.xlsx”)x = df[‘W_hours’]y = df[‘Y’]plt.scatter(x,y)plt.show()
df.info()x.plot.hist()y.plot.hist()
There are 23 rows in the dataset. Below is the distribution of hours studied:
Below is the distribution of pass (1)/fail (0):
Next, we will use the sklearn library to import “LogisticRegression”. Details about the parameters can be found here.
We are converting our bivariate model into 2 dimensions with the .reshape() function. We are defining 1 column, but we are leaving the number of rows to be the size of the dataset. So we get the new shape for x as (23, 1), a vertical array. This is needed to make the sklearn function work properly.
Use the “logreg.fit(x,y)” to fit the regression.
from sklearn.linear_model import LogisticRegressionlogreg = LogisticRegression(C=1.0, solver=’lbfgs’, multi_class=’ovr’)#Convert a 1D array to a 2D array in numpyx = x.reshape(-1,1)#Run Logistic Regressionlogreg.fit(x, y)
Let’s write a program where we can get the predicted probability of passing and failing by hours studied. We input the study time in the code below: Examples of 12, 16, and 20 hours studied.
print(logreg.predict_proba([[12]]))print(logreg.predict_proba([[16]]))print(logreg.predict_proba([[20]]))
The output on the left is the probability of failing, the output on the right is passing.
In order to visualize the model, let’s make a loop where we run each half-hour of study time into the regression from 0 to 33.
hours = np.arange(0, 33, 0.5)probabilities= []for i in hours:    p_fail, p_pass = logreg.predict_proba([[i]])[0]    probabilities.append(p_pass)plt.scatter(hours,probabilities)plt.title("Logistic Regression Model")plt.xlabel('Hours')plt.ylabel('Status (1:Pass, 0:Fail)')plt.show()
In this fictional set of data, a student is guaranteed to pass if he/she studies more than 20 hours and is guaranteed to fail if less than 10 hours. 17 hours is the 50/50 mark.
Thanks for reading,
Is Random Forest better than Logistic Regression? (a comparison)
Excel vs SQL: A Conceptual Comparison
Predicting Cancer with Logistic Regression in Python
Optimize your Investments using Math and Python
Uber Reviews Text Analysis
Algorithms | InsertionSort | Question 2 - GeeksforGeeks

28 Jun, 2021
Which is the correct order of the following algorithms with respect to their time Complexity in the best case ?(A) Merge sort > Quick sort >Insertion sort > selection sort(B) insertion sort < Quick sort < Merge sort < selection sort(C) Merge sort > selection sort > quick sort > insertion sort(D) Merge sort > Quick sort > selection sort > insertion sortAnswer: (B)Explanation:
In best case, 

Quick sort: O (nlogn) 
Merge sort: O (nlogn)
Insertion sort: O (n)
Selection sort: O (n^2)  
Quiz of this Question
Algorithms-InsertionSort
InsertionSort
Algorithms Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Algorithms | Dynamic Programming | Question 2
Algorithms | Dynamic Programming | Question 3
Algorithms Quiz | Dynamic Programming | Question 8
Algorithms | Bit Algorithms | Question 3
Algorithms | Bit Algorithms | Question 2
Algorithms | Divide and Conquer | Question 2
Algorithms | Bit Algorithms | Question 1
Data Structures and Algorithms | Set 38
Algorithms | Divide and Conquer | Question 4
Algorithms | Analysis of Algorithms | Question 19
Git Push to GitHub

Let's try making some changes to our local git and pushing them to GitHub.
Commit the changes:
git commit -a -m "Updated index.html. Resized image"
[master e7de78f] Updated index.html. Resized image
 1 file changed, 1 insertion(+), 1 deletion(-)
And check the status:
git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
Now push our changes to our remote origin:
git push origin
Enumerating objects: 9, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 16 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 578 bytes | 578.00 KiB/s, done.
Total 5 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/w3schools-test/hello-world.git
   5a04b6f..facaeae  master -> master
Go to GitHub, and confirm that the repository has a new commit:
Now, we are going to start working on branches on GitHub.
push the current branch to its default remote origin:
git  


Start the Exercise
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.
Explain scope of a variable in C language.

Storage classes specify the scope, lifetime and binding of variables.
To fully define a variable, one needs to mention not only its ‘type’ but also its storage class.
A variable name identifies some physical location within computer memory, where a collection of bits are allocated for storing values of variable.
Storage class tells us the following factors −
Where the variable is stored (in memory or cpu register)?
What will be the initial value of variable, if nothing is initialized?
What is the scope of variable (where it can be accessed)?
What is the life of a variable?
Scope defines the visibility of an object. It defines where an object can be accessed.
The scope variable is local or global
The variable defined within the block has local scope. They are visible only to the block in which they are defined.
The variable defined in global area is visible from their definition until the end of program. It is visible everywhere in program.
Following is the C program for the scope of a variable −
#include<stdio.h>
int c= 30; /* global area */
main ( ) {
   int a = 10; //local scope//
   printf ("a=%d,c=%d"a,c);
   fun ( );
}
fun ( ){
   printf ("c=%d",c); //global variable
}
When the above program is executed, it produces the following output −
a =10, c = 30
c = 30
Following is the C program for the local and global variables −
 Live Demo
#include<stdio.h>
int a,b;
a=1,b=2;
main() {
   int c,d;
   printf("enter c and d values:");
   scanf("%d%d",&c,&d);
   c=c+d; //local variables
   b=a*b; //global variables
   printf("c value is:%d\n",c);
   printf("b value is:%d\n",b);
}
When the above program is executed, it produces the following output −
enter c and d values:4 7
c value is:11
b value is:2
Check if an array is sorted and rotated in C++

Given an array of integers, the task is to check if the array is sorted (increasing order) and rotated after some number of position or not.
For Example
Input-1:
N = [7, 8, 9, 4, 5, 6]
Output:
True
Explanation: Since the given array is in increasing order and the elements after the 3rd position are rotated, we will return True in this case.
Input-2:
N = [1, 5, 7, 6, 2, 3]
Output:
False
Explanation: Since the given array is neither in increasing order nor rotated with some specific position, the output is False.
We have an array with the element either in increasing order or unsorted. If the array has to be sorted and rotated, then at least one element will be there such that N[i] > N[i+1].
Thus, for every N[i], we will count if there lies any element which satisfies the condition and return True or False accordingly.
Take Input of an array element.
A Boolean function checkSortedandRotated(int *arr, int n) takes an array and its size as the input and returns true if the array is sorted and rotated otherwise false.
Iterate over the whole array and count the number of elements which are (arr[i] > arr[i+1]%n). If the count is '1', then return True, otherwise return False.
Return the output.
Live Demo
#include <bits/stdc++.h>
using namespace std;
bool checkSortedandRotated(int * arr, int n) {
   int count = 0;
   for (int i = 0; i < n; i++) {
      if (arr[i] > arr[(i + 1) % n])
         count++;
   }
   return (count <= 1);
}
int main() {
   int arr[] = {5,6,7,1,2,3,4};
   int n = sizeof(arr) / sizeof(int);
   if (checkSortedandRotated(arr, n)) {
      cout << "True" << endl;
   } else {
      cout << "False" << endl;
   }
   return 0;
}
Running the above code will generate the output as,
True
Since the given array [5, 6, 7, 1, 2, 3, 4] is sorted and rotated from the 3rd position, we get the output as 'True' in this case.
How to Install Packages in Python on MacOS? - GeeksforGeeks

16 Oct, 2021
To get started with using pip, you should install Python on your system. Make sure that you have a working pip.
Follow the below steps to install python packages on MacOS:
Step 1: As the first step, you should check that you have a working Python with pip installed. This can be done by running the following commands and the output will be similar to like this:
$ python --version
Python 3.N.N
$ python -m pip --version
pip X.Y.Z from ... (python 3.N.N
If the output looks like this, You have a working pip in your environment.
If your output doesn’t look like this then refer to this pip document.  It provides guidance on how to install pip within a Python environment that doesn’t have it.
Step 2: To install a package, run the following commands in the terminal:
python -m pip install SomePackage            # latest version
python -m pip install SomePackage==1.0.4     # specific version
python -m pip install 'SomePackage>=1.0.4'     # minimum version
Note: replace the SomePackage with the package name which you want to install.
By default, pip will fetch packages from Python Package Index, a repository of software for the Python programming language where anyone can upload packages.
Run the following commands:
$ python -m pip install git+https://github.com/pypa/SomePackage.git@main
[...]
Successfully installed SomePackage
Use the below command to upgrade an installed package:
$ python -m pip install --upgrade SomePackage
Uninstalling SomePackage:
  [...]
Proceed (y/n)? y
Successfully uninstalled SomePackage
To uninstall a Python package use the below command:
python -m pip uninstall SomePackage
Note: replace the SomePackage with the package name which you want to install.
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Recover a Deleted File in Linux?
How to Install Jupyter Notebook on MacOS?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
Possible to form a triangle from array values in C++

In this problem, we are given an array of integers. Our task is to check if the creation of a non-degenerate triangle taking the elements of the array as sides of the triangle.
Non-degenerate triangle − it is a triangle that has a positive area. The condition for a non-degenerate triangle with sides a, b, c is −
a + b > c
a + c > b
b + c > a
Let’s take an example to understand the problem better −
Input − arr[2, 5 ,9, 4, 3]
Output − Yes
Explanation − the triangle formed is 2 3 4.
To solve this problem, we will check that the above condition is satisfied by the values of the array.
A navie solution will involve direct checking of every triplet of the array.
A more effective solution will involve sorting the array elements and the checking three consecutive triplets of the array. As for sorted array if the sum of two elements is not greater than the next one check values after that is not worthy (they are already large).
Program to show the implementation of our solution
 Live Demo
#include <bits/stdc++.h>
using namespace std;
bool isTrianglePossible(int arr[], int N){
   if (N < 3)
      return false;
   sort(arr, arr + N);
   for (int i = 0; i < N - 2; i++)
      if (arr[i] + arr[i + 1] > arr[i + 2])
         return true;
}
int main() {
   int arr[] = {5, 12, 13, 65, 6, 1};
   int N = sizeof(arr) / sizeof(int);
   cout<<"Creation of triangle from elements of array ";
   isTrianglePossible(arr, N)?cout<<"is Possible": cout<<"is not Possible";
   return 0;
}
Creation of triangle from elements of array is Possible
WSDL - <ports> Element

A <port> element defines an individual endpoint by specifying a single address for a binding.
Here is the grammar to specify a port −
<wsdl:definitions .... >
   <wsdl:service .... > *
      <wsdl:port name = "nmtoken" binding = "qname"> *
         <-- extensibility element (1) -->
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>
The port element has two attributes: name and binding .
The port element has two attributes: name and binding .
The name attribute provides a unique name among all ports defined within the enclosing WSDL document.
The name attribute provides a unique name among all ports defined within the enclosing WSDL document.
The binding attribute refers to the binding using the linking rules defined by WSDL.
The binding attribute refers to the binding using the linking rules defined by WSDL.
Binding extensibility elements are used to specify the address information for the port.
Binding extensibility elements are used to specify the address information for the port.
A port MUST NOT specify more than one address.
A port MUST NOT specify more than one address.
A port MUST NOT specify any binding information other than address information.
A port MUST NOT specify any binding information other than address information.
Here is a piece of code from the Example chapter −
<service name = "Hello_Service">
   <documentation>WSDL File for HelloService</documentation>
   <port binding = "tns:Hello_Binding" name = "Hello_Port">
      <soap:address
         location = "http://www.examples.com/SayHello/">
   </port>
</service>
 Print
 Add Notes
 Bookmark this page
What is the difference between a python tuple and a dictionary?

They are very different data structures. Elements in a tuple have the following properties −
Order is maintained.
Order is maintained.
They are immutable
They are immutable
They can hold any type, and types can be mixed.
They can hold any type, and types can be mixed.
Elements are accessed via numeric (zero based) indices.
Elements are accessed via numeric (zero based) indices.
A Python dictionary is an implementation of a hash table. Elements of a dictionary have the following properties −
Ordering is not guaranteed
Ordering is not guaranteed
Every entry has a key and a value
Every entry has a key and a value
Elements are accessed using key's values
Elements are accessed using key's values
Entries in a dictionary can be changed.
Entries in a dictionary can be changed.
Key values can be of any hashable type (i.e. not a dict) and types can be mixed while values can be of any type (including other dict’s), and types can be mixed
Key values can be of any hashable type (i.e. not a dict) and types can be mixed while values can be of any type (including other dict’s), and types can be mixed
Both of these data structures can be created using comprehensions. Examples −
Tuple: (1, 'a', (3, 6, 8), 'string')
Dictionary: {'foo': [1, 2, 3], 'bar': 'baz'}
Go Arithmetic Operators

Arithmetic operators are used to perform common mathematical operations.
Multiply 10 with 5, and print the result.
package main   
import ("fmt") 
func main() {
  fmt.Print(105)
}

Start the Exercise
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.
What is the purpose of OPTIMIZE FOR ROWS in DB2 SQLs? How is it useful?

The OPTIMIZE FOR N ROWS is a DB2 clause which we can add in the query to give priority for the retrieval of the first few rows only. This clause will enable the optimizer to choose the access path that minimizes the response time for fetching first few rows.
The OPTIMIZE FOR N ROWS clause is not effective on SELECT DISTINCT and COUNT function because DB2 will need the entire qualifying rows in order to fetch the DISTINCT rows or COUNT the number of rows. The OPTIMIZE FOR N ROWS clause gives DB2 a better opportunity to establish the access path.
The OPTIMIZE FOR N rows clause can be used in a SQL query as given below.
SELECT ORDER_ID, ORDER_TOTAL FROM ORDERS
   ORDER BY ORDER_TOTAL DESC
   OPTIMIZE FOR 2 ROWS
We will use “FETCH FIRST n ROWS ONLY” to limit the number of rows returned and it will not consider the actual number of qualifying rows.
A practical scenario in which we can use OPTIMIZE FOR N ROWS would be a CICS screen where we can display a list of 5 orders only.
SELECT ORDER_ID, ORDER_TOTAL FROM ORDERS
   ORDER BY ORDER_TOTAL DESC
   OPTIMIZE FOR 5 ROWS
For example, our DB2 ORDERS table has the below data.
 
The result of our OPTIMIZE FOR 5 ROWS query will be as given below.
How can you order the result obtained by select query in MySQL?

It is common to select certain data or rows from a table. The rows are returned in the order in which they appear in the table. We may sometimes require that the rows we select from the table must be returned to us in ascending or descending order with respect to some column.
The “ORDER BY” statement is used to order the results with respect to some column. The following example will provide more clarity.
Suppose, we have a table which consists of various fields including the “name” field. We want to select all the rows from the table but we want the rows must be ordered in alphabetic order of the names. Here is where the “ORDER BY” statement comes into play. This scenario requires us to order the results in ascending order of the “name” field.
The “ORDER BY” statement ,by default, orders the specified column in ascending order. If you want the result to be ordered in descending order, you need to specify the same. To oder the result in descending order, the keyword “DESC” is to be specified.
Ascending order
SELECT * FROM table_name ORDER BY column_name
Descending order
SELECT * FROM table_name ORDER BY column_name DESC
import MySQL connector
import MySQL connector
establish connection with the connector using connect()
establish connection with the connector using connect()
create the cursor object using cursor() method
create the cursor object using cursor() method
create a query using the appropriate mysql statements
create a query using the appropriate mysql statements
execute the SQL query using execute() method
execute the SQL query using execute() method
close the connection
close the connection
Suppose we have a table named “Student” as follows −
+----------+---------+-----------+------------+
|    Name  |   Class |    City   | Marks      |
+----------+---------+-----------+------------+
|    Karan |    4    |  Amritsar |    95      |
|    Sahil |    6    |  Amritsar |    93      |
|    Kriti |    3    |    Batala |    88      |
|   Khushi |    9    |    Delhi  |    90      |
|    Kirat |    5    |    Delhi  |    85      |
+----------+---------+-----------+------------+
We want to select all the rows from the table but in alphabetic order of their names. In short, we want to order the result in ascending order of names.
import mysql.connector

db=mysql.connector.connect(host="your host", user="your username", password="your
password",database="database_name")

cursor=db.cursor()

query= "SELECT * FROM Students ORDER BY Name"
cursor.execute(query)
for row in cursor:
   print(row)
The above code when executed succesfully returns the rows in ascending or alphabetic order of the names of the students.
(‘Amit’ , 9 , ‘Delhi’ , 90)
(‘Karan’, 4 ,’Amritsar’ , 95)
(‘Kriti’ , 3 , ‘Batala’ ,88)
(‘Priya’ , 5 , ‘Delhi’ ,85)
(‘Sahil’ , 6 , ‘Amritsar’ ,93)
All the rows displayed are in alphabetic order of the names. Similarly, the rows could have been arranged in ascending or descending order of the marks following the similar syntax.
Style every checked <input> element with CSS

To style every checked <input> element, use the CSS :checked selector. You can try to run the following code to implement the :checked selector −
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         input:checked {
            height: 20px;
            width: 20px;
         }
      </style>
   </head>
   <body>
      <p>Fav sports:</p>
      <form action="">
         <input type = "checkbox" value = "Football">Football<br>
         <input type = "checkbox" value = "Cricket">Cricket<br>
         <input type = "checkbox" checked = "checked" value = "Tennis"> Tennis<br>
         <input type = "checkbox" value = "Badminton">Tennis
      </form>
   </body>
</html>
Groovy - If Statement

The first decision making statement is the if statement. The general form of this statement is −
if(condition) { 
   statement #1 
   statement #2 
   ... 
}

The general working of this statement is that first a condition is evaluated in the if statement. If the condition is true, it then executes the statements. The following diagram shows the flow of the if statement.
Following is an example of a if/else statement −
class Example { 
   static void main(String[] args) { 
      // Initializing a local variable 
      int a = 2 
		
      //Check for the boolean condition 
      if (a<100) { 
         //If the condition is true print the following statement 
         println("The value is less than 100"); 
      } 
   } 
}
In the above example, we are first initializing a variable to a value of 2. We are then evaluating the value of the variable and then deciding whether the println statement should be executed. The output of the above code would be −
The value is less than 100


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
TypeScript - Calling a Function

A function must be called so as to execute it. This process is termed as function invocation.
Function_name()

The following example illustrates how a function can be invoked −
function test() {   // function definition    
   console.log("function called") 
} 
test()              // function invocation

On compiling, it will generate the same JavaScript code.
function test() { 
   console.log("function called"); 
} 
test();    // function invocation

It will produce the following output −
function called


    45 Lectures 
     4 hours 

 Antonio Papa

    41 Lectures 
     7 hours 

 Haider Malik

    60 Lectures 
     2.5 hours 

 Skillbakerystudios

    77 Lectures 
     8 hours 

 Sean Bradley

    77 Lectures 
     3.5 hours 

 TELCOMA Global

    19 Lectures 
     3 hours 

 Christopher Frewin
 Print
 Add Notes
 Bookmark this page
Why addEventListener to 'select' element does not work in JavaScript?

Instead, use querySelector() along with addEventListener().
Following is the code −
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<link rel="stylesheet"
href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
   <select id="selectDemo">
      <option value="Java">Java</option>
      <option value="Javascript">Javascript</option>
      <option value="MySQL">MySQL</option>
      <option value="MongoDB">MongoDB</option>
   </select>
</body>
<script>
   document.querySelector('#selectDemo').addEventListener('change', subjectMarks);
   function subjectMarks() {
      console.log(58);
   }
</script>
</html>
To run the above program, save the file name anyName.html(index.html) and right click on the
file. Select the option “Open with live server” in VS Code editor.
This will produce the following output −
Now, select the value from dropdown list −
This will produce the following output −
Python Tkinter – Scale Widget

23 Dec, 2021
Tkinter is a GUI toolkit used in python to make user-friendly GUIs.Tkinter is the most commonly used and the most basic GUI framework available in python. Tkinter uses an object-oriented approach to make GUIs.
Note: For more information, refer to Python GUI – tkinter
The Scale widget is used whenever we want to select a specific value from a range of values. It provides a sliding bar through which we can select the values by sliding from left to right or top to bottom depending upon the orientation of our sliding bar.
Syntax:
S = Scale(root, bg, fg, bd, command, orient, from_, to, ..) 

Optional parameters
root – root window.
bg – background colour
fg – foreground colour
bd – border
orient – orientation(vertical or horizontal)
from_ – starting value
to – ending value
troughcolor – set colour for trough.
state – decides if the widget will be responsive or unresponsive.
sliderlength – decides the length of the slider.
label – to display label in the widget.
highlightbackground – the colour of the focus when widget is not focused.
cursor – The cursor on the widget which could be arrow, circle, dot etc.
Methods
set(value) – set the value for scale.
get() – get the value of scale.
Example 1: Creating a horizontal bar
# Python program to demonstrate# scale widget  from tkinter import *     root = Tk()  root.geometry("400x300")   v1 = DoubleVar()  def show1():            sel = "Horizontal Scale Value = " + str(v1.get())    l1.config(text = sel, font =("Courier", 14))      s1 = Scale( root, variable = v1,            from_ = 1, to = 100,            orient = HORIZONTAL)     l3 = Label(root, text = "Horizontal Scaler")  b1 = Button(root, text ="Display Horizontal",             command = show1,             bg = "yellow")    l1 = Label(root)    s1.pack(anchor = CENTER) l3.pack()b1.pack(anchor = CENTER)l1.pack()   root.mainloop()
Output:
Example 2: Creating a vertical slider
from tkinter import *  root = Tk()  root.geometry("400x300") v2 = DoubleVar()  def show2():          sel = "Vertical Scale Value = " + str(v2.get())     l2.config(text = sel, font =("Courier", 14))  s2 = Scale( root, variable = v2,           from_ = 50, to = 1,           orient = VERTICAL)   l4 = Label(root, text = "Vertical Scaler")  b2 = Button(root, text ="Display Vertical",            command = show2,            bg = "purple",             fg = "white")  l2 = Label(root)  s2.pack(anchor = CENTER) l4.pack()b2.pack()l2.pack()  root.mainloop()
Output:
avtarkumar719
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Enumerate() in Python
Different ways to create Pandas Dataframe
Read a file line by line in Python
How to Install PIP on Windows ?
Python String | replace()
Python OOPs Concepts
NLP | Part of speech tagged – word corpus

11 Apr, 2022
What is Part-of-speech (POS) tagging ? It is a process of converting a sentence to forms – list of words, list of tuples (where each tuple is having a form (word, tag)). The tag in case of is a part-of-speech tag, and signifies whether the word is a noun, adjective, verb, and so on. 
Example of Part-of-speech (POS) tagged corpus 
The/at-tl expense/nn and/cc time/nn involved/vbn are/ber astronomical/jj ./.
format for a tagged corpus is of the form word/tag. Each word is with a tag denoting its POS. For example, nn refers to a noun, vb is a verb. 
Code #1 : Creating a TaggedCorpusReader. for words 
Python3
# Using TaggedCorpusReaderfrom nltk.corpus.reader import TaggedCorpusReader   # initializingx = TaggedCorpusReader('.', r'.*\.pos')   words = x.words()print ("Words : \n", words)   tag_words = x.tagged_words()print ("\ntag_words : \n", tag_words)
Output : 
Words : 
['The', 'expense', 'and', 'time', 'involved', 'are', ...]

tag_words : 
[('The', 'AT-TL'), ('expense', 'NN'), ('and', 'CC'), ...]
Code #2 : For sentence  
Python3
tagged_sent = x.tagged_sents()print ("tagged_sent : \n", tagged_sent)
Output : 
tagged_sent : 
[[('The', 'AT-TL'), ('expense', 'NN'), ('and', 'CC'), ('time', 'NN'),
('involved', 'VBN'), ('are', 'BER'), ('astronomical', 'JJ'), ('.', '.')]]
Code #3 : For paragraphs  
Python3
para = x.para()print ("para : \n", para)   tagged_para = x.tagged_paras()print ("\ntagged_paras : \n", tagged_paras)
Output : 
para: 
[[['The', 'expense', 'and', 'time', 'involved', 'are', 'astronomical', '.']]]

tagged_paras : 
[[[('The', 'AT-TL'), ('expense', 'NN'), ('and', 'CC'), ('time', 'NN'),
('involved', 'VBN'), ('are', 'BER'), ('astronomical', 'JJ'), ('.', '.')]]] 
 
simranarora5sos
abhisheksharma975689
rkbhola5
Natural-language-processing
Python-nltk
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Overlapping Histograms with Matplotlib in Python

26 Nov, 2020
Histograms are a way of visualizing the data. Here, we will learn how to plot overlapping histograms in python using Matplotlib library. matplotlib.pyplot.hist() is used for making histograms.
Let’s take the iris dataset and plot various overlapping histograms with Matplotlib.
Step 1: Import the libraries
Python3
# importing librariesimport matplotlib.pyplot as pltimport seaborn as sns
Step 2: Load the dataset
Python3
# load the iris datasetdata = sns.load_dataset('iris')  # view the datasetprint(data.head(5))
Step 3: Let us plot histograms for sepal_length and petal_length.
Python3
# plotting histogramsplt.hist(data['petal_length'],          label='petal_length')  plt.hist(data['sepal_length'],          label='sepal_length')  plt.legend(loc='upper right')plt.title('Overlapping')plt.show()
Here, we can see that some part of the histogram for ‘petal_length’ has been hidden behind the histogram for ‘sepal_length’. To properly visualize both the histograms, we need to set the transparency parameter, alpha to a suitable value. So let’s check various values for alpha and find out the suitable one.
Step 4: Set alpha=0.5 for both sepal_length and petal_length
Python3
plt.hist(data['petal_length'],          alpha=0.5, # the transaparency parameter         label='petal_length')  plt.hist(data['sepal_length'],         alpha=0.5,         label='sepal_length')  plt.legend(loc='upper right')plt.title('Overlapping with both alpha=0.5')plt.show()
Step 5: Set alpha=0.1 for sepal_length and 0.9 for petal_length
Python3
plt.hist(data['petal_length'],          alpha=0.9,         label='petal_length')  plt.hist(data['sepal_length'],         alpha=0.1,         label='sepal_length')  plt.legend(loc='upper right')plt.title('Overlapping with alpha=0.1 and 0.9 for sepal and petal')plt.show()
Through the above two steps, we can infer that for a better visualization for both the histograms, alpha=0.5 would be the most suitable option for the transparency parameter.
Now, to plot more than two overlapping histograms where we need custom colors, let’s follow step 6.
Step 6: Create more than 2 overlapping histograms with customized colors.
Python3
# plotting more than 2 overlapping histogramsplt.hist(data['sepal_width'],          alpha=0.5,          label='sepal_width',         color='red') # customized color parameter  plt.hist(data['petal_width'],          alpha=0.5,         label='petal_width',         color='green')  plt.hist(data['petal_length'],          alpha=0.5,         label='petal_length',         color='yellow')  plt.hist(data['sepal_length'],          alpha=0.5,         label='sepal_length',         color='purple')  plt.legend(loc='upper right')plt.show()
Thus, in this article, we learned how to plot overlapping histograms using Matplotlib, how to set their transparency values, and customize their colors.
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to apply a theme to an activity only in Android?

This example demonstrates how do I apply theme to an activity in android.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity">
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Hello World!"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintLeft_toLeftOf="parent"
      app:layout_constraintRight_toRightOf="parent"
      app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
Step 3 − Add the following code to src/MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity" android:theme="@style/Theme.AppCompat.Dialog.MinWidth">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Click here to download the project code.
Apex - if elseif else statement

An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement.
The syntax of an if...else if...else statement is as follows −
if boolean_expression_1 {
   /* Executes when the boolean expression 1 is true */
} else if boolean_expression_2 {
   /* Executes when the boolean expression 2 is true */
} else if boolean_expression_3 {
   /* Executes when the boolean expression 3 is true */
} else {
   /* Executes when the none of the above condition is true */
}

Suppose, our Chemical company has customers of two categories – Premium and Normal. Based on the customer type we should provide them discount and other benefits like after sales service and support. Following program shows an implementation of the same.
//Execute this code in Developer Console and see the Output
String customerName = 'Glenmarkone'; //premium customer
Decimal discountRate = 0;
Boolean premiumSupport = false;
if (customerName == 'Glenmarkone') {
   discountRate = 0.1; //when condition is met this block will be executed
   premiumSupport = true;
   System.debug('Special Discount given as Customer is Premium');
}else if (customerName == 'Joe') {
   discountRate = 0.5; //when condition is met this block will be executed
   premiumSupport = false;
   System.debug('Special Discount not given as Customer is not Premium');
}else {
   discountRate = 0.05; //when condition is not met and customer is normal
   premiumSupport = false;
   System.debug('Special Discount not given as Customer is not Premium');
}

    14 Lectures 
     2 hours 

 Vijay Thapa

    7 Lectures 
     2 hours 

 Uplatz

    29 Lectures 
     6 hours 

 Ramnarayan Ramakrishnan

    49 Lectures 
     3 hours 

 Ali Saleh Ali

    10 Lectures 
     4 hours 

 Soham Ghosh

    48 Lectures 
     4.5 hours 

 GUHARAJANM
 Print
 Add Notes
 Bookmark this page
How to subset a data frame by excluding a specific text value in an R data frame?

To create a subset based on text value we can use rowSums function by defining the sums for the text equal to zero, this will help us to drop all the rows that contains that specific text value. For example, if we have a data frame df that contains A in many columns then all the rows of df excluding A can be selected as−
df[rowSums(df=="A")==0,,drop=FALSE]
 Live Demo
Consider the below data frame −
set.seed(951)
x1<−sample(LETTERS[1:3],20,replace=TRUE)
x2<−sample(LETTERS[1:4],20,replace=TRUE)
x3<−sample(LETTERS[1:5],20,replace=TRUE)
x4<−sample(LETTERS[2:5],20,replace=TRUE)
x5<−sample(LETTERS[3:5],20,replace=TRUE)
df<−data.frame(x1,x2,x3,x4,x5)
df
  x1 x2 x3 x4 x5
1  A  D  B  C C
2  B  D  D  D D
3  B  A  D  D D
4  B  D  C  D E
5  C  D  C  C C
6  A  D  C  D E
7  B  D  E  B E
8  A  D  E  D C
9  A  B  C  E E
10 C  B  C  B C
11 A  D  D  B D
12 B  C  B  D E
13 A  C  E  E D
14 C  A  D  C E
15 C  C  D  B D
16 A  C  A  D E
17 C  A  B  C E
18 A  A  E  E D
19 B  A  D  D C
20 B  D  C  D C
Subsetting rows that do not include A −
df[rowSums(df=="A")==0,,drop=FALSE]
  x1 x2 x3 x4 x5
2 B  D  D  D  D
4 B  D  C  D  E
5 C  D  C  C  C
7 B  D  E  B  E
10 C B  C  B  C
12 B C  B  D  E
15 C C  D  B  D
20 B D  C  D  C
Subsetting rows that do not include B −
df[rowSums(df=="B")==0,,drop=FALSE]
x1 x2 x3 x4 x5
5 C D C C C
6 A D C D E
8 A D E D C
13 A C E E D
14 C A D C E
16 A C A D E
18 A A E E D
Subsetting rows that do not include C −
df[rowSums(df=="C")==0,,drop=FALSE]
x1 x2 x3 x4 x5
2 B D D D D
3 B A D D D
7 B D E B E
11 A D D B D
18 A A E E D
Subsetting rows that do not include D −
df[rowSums(df=="D")==0,,drop=FALSE]
x1 x2 x3  x4  x5
9 A  B  C  E  E
10 C B  C  B  C
17 C A  B  C  E
Subsetting rows that do not include E −
df[rowSums(df=="E")==0,,drop=FALSE]
 x1 x2 x3 x4 x5
1 A  D  B  C C
2 B  D  D  D D
3 B  A  D  D D
5 C  D  C  C C
10 C B  C  B C
11 A D  D  B D
15 C C  D  B D
19 B A  D  D C
20 B D  C  D C
Compare Two Java int Arrays in Java

To compare two Java short arrays, use the Arrays.equals() method.
Let us first declare and initialize some int arrays.
int[] arr1 = new int[] { 33, 66, 12, 56, 99 };
int[] arr2 = new int[] { 33, 66, 12, 56, 99 };
int[] arr3 = new int[] { 33, 66, 15, 56, 90 };
Now let us compare any two of the above arrays.
Arrays.equals(arr1, arr2));
In the same way, work it for other arrays and compare them
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String[] args) {
      int[] arr1 = new int[] { 33, 66, 12, 56, 99 };
      int[] arr2 = new int[] { 33, 66, 12, 56, 99 };
      int[] arr3 = new int[] { 33, 66, 15, 56, 90 };
      System.out.println(Arrays.equals(arr1, arr2));
      System.out.println(Arrays.equals(arr2, arr3));
      System.out.println(Arrays.equals(arr3, arr1));
   }
}
true
false
false
HTML - <aside> Tag

The HTML <aside> tag is used to specify a section of a page aside from the related section. This tag can be used for glossary definitions, author biography, author profile etc.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML aside Tag</title>
   </head>

   <body>
      <aside>
         <h3>Java History</h3> 
         <p>Java is a programming language developed by James Gosling in 1994.</p>
      </aside>
   </body>

</html>
This will produce the following result −
Java is a programming language developed by James Gosling in 1994.
This tag supports all the global attributes described in HTML Attribute Reference
This tag supports all the event attributes described in HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
Generalized Linked List - GeeksforGeeks

14 Nov, 2019
A Generalized Linked List L, is defined as a finite sequence of n>=0 elements, l1, l2, l3, l4, ..., ln, such that li are either atom or the list of atoms. ThusL = (l1, l2, l3, l4, ..., ln)where n is total number of nodes in the list.To represent a list of items there are certain assumptions about the node structure.
Flag = 1 implies that down pointer exists
Flag = 0 implies that next pointer exists
Data means the atom
Down pointer is the address of node which is down of the current node
Next pointer is the address of node which is attached as the next node
Why Generalized Linked List?Generalized linked lists are used because although the efficiency of polynomial operations using linked list is good but still, the disadvantage is that the linked list is unable to use multiple variable polynomial equation efficiently. It helps us to represent multi-variable polynomial along with the list of elements.
Typical ‘C’ structure of Generalized Linked List
typedef struct node {    char c;                    //Data    int index;                 //Flag    struct node *next, *down;   //Next & Down pointer}GLL;
Example of GLL {List representation}( a, (b, c), d)When first field is 0, it indicates that the second field is variable. If first field is 1 means the second field is a down pointer, means some list is starting.
Polynomial Representation using Generalized Linked ListThe typical node structure will be:
Here Flag = 0 means variable is present
Flag = 1 means down pointer is present
Flag = 2 means coefficient and exponent is present
Example:9x5 + 7xy4 + 10xz
In the above example the head node is of variable x. The temp node shows the first field as 2 means coefficient and exponent are present.
Since temp node is attached to head node and head node is having variable x, temp node having coefficient = 9 and exponent = 5. The above two nodes can be read as 9x5.Similarly, in the above figure, the node temp1 can be read as x4.
The flag field is 1 means down pointer is there
temp2 = y
temp3 = coefficient = 7
exponent = 1
flag = 2 means the node contains coefficient and exponent values.
temp2 is attached to temp3 this means 7y1 and temp2 is also attached to temp1 means
temp1 x temp2
x4 x 7y1 = 7x4y1 value is represented by above figure
Linked List
Linked List
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
LinkedList in Java
Doubly Linked List | Set 1 (Introduction and Insertion)
Linked List vs Array
Implementing a Linked List in Java using Class
Merge two sorted linked lists
Queue - Linked List Implementation
Implement a stack using singly linked list
Circular Linked List | Set 1 (Introduction and Applications)
Merge Sort for Linked Lists
Remove duplicates from a sorted linked list