code-rag-bench/online-tutorials huggingface dataset:
JSP | ScriptletTag - GeeksforGeeks

09 Aug, 2018
Java Server Page (JSP) is a technology for controlling the content or appearance of Web pages through the use of servlets. Small programs that are specified in the Web page and run on the Web server to modify the Web page before it is sent to the user who requested it.
There are total three Scripting Element in JSP
Scriptlet tagExpression tagDeclaration tag
Scriptlet tag
Expression tag
Declaration tag
Using these tags we can insert our java code in JSP.
Scriptlet tag
This tag allow user to insert java code in JSP. The statement which is written will be moved to jspservice() using JSP container while generating servlet from JSP. When client make a request, JSP service method is invoked and after that the content which is written inside the scriptlet tag executes.
<html>  <body>  <% out.print("GeeksforGeeks"); %>  <!-- scriptlet tag --></body>  </html> 
Explanation
The Syntax of JSP Sriptlet tag is begin with ”.
We can write our java code inside this tag.
In java we use System.out.println for printing anything on console. In JSP, we use only out.print to write something on console because the out we’re referring to isn’t System.out, it’s a variable in the effective method that wraps our JSP page.
System.out writes to the servlet container’s console (usually a log file); out is a different class entirely which writes to the output stream for the generated response.
Here we are creating and HTML file to take username from user.save this file as index.html.
<!--index.html  --><!-- Example of JSP code which prints the Username  --><html>  <body>  <form action="Geeks.jsp"> <!-- move the control to Geeks.jsp when Submit button is click -->  Enter Username:<input type="text" name="username">  <input type="submit" value="Submit"><br/>    </form>  </body>  </html>  
Here we are creating A jsp file names as Geeks.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"    pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>  <head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Insert title here</title></head>  <body><%  String name=request.getParameter("username");  out.print("Hello "+name);  %>  </body>  </html>
output
Java-JSP
Articles
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Time Complexity and Space Complexity
Mutex vs Semaphore
Analysis of Algorithms | Set 2 (Worst, Average and Best Cases)
Understanding "extern" keyword in C
SQL | Views
How to write a Pseudo Code?
SQL | GROUP BY
Recursive Practice Problems with Solutions
Little and Big Endian Mystery
Card Flipping Game in C++

Suppose on a table are N cards, with a positive integer printed on both side of each card (possibly different). We have to flip any number of cards, and after we choose one card. If the number X on the back side of the chosen card is not on the front of any card, then the number X is known as good. We have to find the smallest number that is good? When no number is good, return 0. Here, fronts[i] and backs[i] represent the number on the front and back side of card i. A flip will swap the front and back numbers, so the value on the front is now on the back and vice versa.
So if the input is like fronts = [1,2,4,4,7] and backs = [1,3,4,1,3], then the output will be 2. So if we flip the second card, the front value will be [1,3,4,4,7], and the backs will be [1,2,4,1,3]. We will choose the second card, which has number 2 on the back, and it is not on the front of any card, so 2 is a good number.
To solve this, we will follow these steps −
define a set s, n := size of fronts, ret := inf
for i in range 0 to n – 1if fronts[i] = back[i], then insert fronts[i] into s
if fronts[i] = back[i], then insert fronts[i] into s
for i in range 0 to n – 1if fronts[i] in set then ret := minimum of ret and fronts[i]
if fronts[i] in set then ret := minimum of ret and fronts[i]
for i in range 0 to n – 1if backs[i] not in set then ret := minimum of ret and backs[i]
if backs[i] not in set then ret := minimum of ret and backs[i]
return 0 when ret = inf, otherwise ret.
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
   public:
   int flipgame(vector<int>& fronts, vector<int>& backs) {
      set <int> s;
      int n = fronts.size();
      int ret = INT_MAX;
      for(int i = 0; i < n; i++){
         if(fronts[i] == backs[i])s.insert(fronts[i]);
      }
      for(int i = 0; i <n; i++ ){
         if(s.count(fronts[i]) == 0) ret = min(ret, fronts[i]);
      }
      for(int i = 0; i <n; i++ ){
         if(s.count(backs[i]) == 0) ret = min(ret, backs[i]);
      }
      return ret == INT_MAX? 0 : ret;
   }
};
main(){
   vector<int> v1 = {1,2,4,4,7};
   vector<int> v2 = {1,3,4,1,3};
   Solution ob;
   cout << (ob.flipgame(v1, v2));
}
[1,2,4,4,7]
[1,3,4,1,3]
2
What is aggregation in Java?

When an object A contains a reference to another object B or we can say Object A has a HAS-A relationship with Object B, then it is termed as Aggregation.
Aggregation helps in reusing the code. Object B can have utility methods and which can be utilized by multiple objects. Whichever class has object B then it can utilize its methods.
public class Vehicle{}
public class Speed{}

public class Van extends Vehicle {
   private Speed sp;
}
This shows that class Van HAS-A Speed. By having a separate class for Speed, we do not have to put the entire code that belongs to speed inside the Van class, which makes it possible to reuse the Speed class in multiple applications.
In the Object-Oriented feature, the users do not need to bother about which object is doing the real work. To achieve this, the Van class hides the implementation details from the users of the Van class. So, basically what happens is the users would ask the Van class to do a certain action and the Van class will either do the work by itself or ask another class to perform the action.
This concept of containing an object to do action is termed as Aggregation.
Degree of Vertex of a Graph

It is the number of vertices adjacent to a vertex V.
Notation − deg(V).
In a simple graph with n number of vertices, the degree of any vertices is −
deg(v) = n – 1 ∀ v ∈ G
A vertex can form an edge with all other vertices except by itself. So the degree of a vertex will be up to the number of vertices in the graph minus 1. This 1 is for the self-vertex as it cannot form a loop by itself. If there is a loop at any of the vertices, then it is not a Simple Graph.
Degree of vertex can be considered under two cases of graphs −
Undirected Graph
Directed Graph
An undirected graph has no directed edges. Consider the following examples.
Take a look at the following graph −
In the above Undirected Graph,
deg(a) = 2, as there are 2 edges meeting at vertex 'a'.
deg(a) = 2, as there are 2 edges meeting at vertex 'a'.
deg(b) = 3, as there are 3 edges meeting at vertex 'b'.
deg(b) = 3, as there are 3 edges meeting at vertex 'b'.
deg(c) = 1, as there is 1 edge formed at vertex 'c'So 'c' is a pendent vertex.
deg(c) = 1, as there is 1 edge formed at vertex 'c'
So 'c' is a pendent vertex.
deg(d) = 2, as there are 2 edges meeting at vertex 'd'.
deg(d) = 2, as there are 2 edges meeting at vertex 'd'.
deg(e) = 0, as there are 0 edges formed at vertex 'e'.So 'e' is an isolated vertex.
deg(e) = 0, as there are 0 edges formed at vertex 'e'.
So 'e' is an isolated vertex.
Take a look at the following graph −
In the above graph,
deg(a) = 2, deg(b) = 2, deg(c) = 2, deg(d) = 2, and deg(e) = 0.
The vertex 'e' is an isolated vertex. The graph does not have any pendent vertex.
In a directed graph, each vertex has an indegree and an outdegree.
Indegree of vertex V is the number of edges which are coming into the vertex V.
Indegree of vertex V is the number of edges which are coming into the vertex V.
Notation − deg−(V).
Notation − deg−(V).
Outdegree of vertex V is the number of edges which are going out from the vertex V.
Outdegree of vertex V is the number of edges which are going out from the vertex V.
Notation − deg+(V).
Notation − deg+(V).
Consider the following examples.
Take a look at the following directed graph. Vertex 'a' has two edges, 'ad' and 'ab', which are going outwards. Hence its outdegree is 2. Similarly, there is an edge 'ga', coming towards vertex 'a'. Hence the indegree of 'a' is 1.
The indegree and outdegree of other vertices are shown in the following table −
Take a look at the following directed graph. Vertex 'a' has an edge 'ae' going outwards from vertex 'a'. Hence its outdegree is 1. Similarly, the graph has an edge 'ba' coming towards vertex 'a'. Hence the indegree of 'a' is 1.
The indegree and outdegree of other vertices are shown in the following table −
\blacktriangledown - Tex Command

\blacktriangledown - Used to draw black triangle down symbol.
{ \blacktriangledown }
\blacktriangledown command draws black triangle down symbol.

\blacktriangledown 

▾



\blacktriangledown 

▾


\blacktriangledown 

    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
What is the groups() method in regular expressions in Python?

This method returns a tuple containing all the subgroups of the match, from 1 up to however many groups are in the pattern. The default argument is used for groups that did not participate in the match; it defaults to None.  In later versions (from 1.5.1 on), a singleton tuple is returned in such cases.
>>> m = re.match(r"(\d+)\.(\d+)", "27.1835")
>>> m.groups()
('27', '1835')
If we make the decimal place and everything after it optional, not all groups might participate in the match. These groups will default to None unless the default argument is given −
>>> m = re.match(r"(\d+)\.?(\d+)?", "27")
>>> m.groups()      # Second group defaults to None.
('27', None)
>>> m.groups('0')   # Now, the second group defaults to '0'.
('27', '0')
fg command in Linux with examples - GeeksforGeeks

15 May, 2019
fg command in linux used to put a background job in foreground.
Syntax:
fg [job_spec]
job_spec may be:
%n : Refer to job number n.%str : Refer to a job which was started by a command beginning with str.%?str : Refer to a job which was started by a command containing str.%% or %+ : Refer to the current job. fg and bg will operate on this job if no job_spec is given.%- : Refer to the previous job.
Options for fg command :
fg [JOB_SPEC] : This command is used to put the mentioned job running inbackground to foreground.“sleep 500” is a command which is used to create a dummy job which runs for 500 seconds.
fg –help : It displays help information.
linux-command
Linux-system-commands
Picked
Technical Scripter 2018
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
tar command in Linux with examples
curl command in Linux with Examples
UDP Server-Client implementation in C
diff command in Linux with examples
Conditional Statements | Shell Script
Cat command in Linux with examples
'crontab' in Linux with Examples
touch command in Linux with Examples
echo command in Linux with Examples
Compiling with g++
Calculating the completeness score using sklearn in Python - GeeksforGeeks

26 May, 2021

An entirely complete clustering is one where each cluster has information that directs a place toward a similar class cluster. Completeness portrays the closeness of the clustering algorithm to this (completeness_score) perfection. 
This metric is autonomous of the outright values of the labels. A permutation of the cluster label values won’t change the score value in any way.
Syntax: sklearn.metrics.completeness_score(labels_true, labels_pred)
Parameters:
labels_true:<int array, shape = [n_samples]>: It accepts the ground truth class labels to be used as a reference.
labels_pred: <array-like of shape (n_samples,)>: It accepts the cluster labels to evaluate.
Returns: completeness score between 0.0 and 1.0. 1.0 stands for perfectly completeness labeling.
Switching label_true with label_pred will return the homogeneity_score.
Example 1:
Python3
 

 
 










# Importing the modules
import pandas as pd  
from sklearn import datasets
from sklearn.cluster import KMeans  
from sklearn.metrics import completeness_score
 
# Loading the data  
digits = datasets.load_digits()
 
# Separating the dependent and independent variables  
Y = digits.target
X = digits.data
 
# Building the clustering model  
kmeans = KMeans(n_clusters = 2)  
 
# Training the clustering model  
kmeans.fit(X)  
 
# Storing the predicted Clustering labels  
labels = kmeans.predict(X)  
 
# Evaluating the performance  
print(completeness_score(Y, labels))






Output:
0.8471148027985769
Example 2: Perfectly completeness:
Python3
 

 
 










# Importing the module
from sklearn.metrics.cluster import completeness_score
 
# Evaluating the score
Cscore = completeness_score([0, 1, 0, 1], 
                            [1, 0, 1, 0])
print(Cscore)






 Output: 
1.0 
Example 3: Non-perfect labeling that further split classes into more clusters can be perfectly completeness:
Python3
 

 
 










# Importing the module
from sklearn.metrics.cluster import completeness_score
 
# Evaluating the score
Cscore = completeness_score([0, 1, 2, 3], 
                            [0, 0, 1, 1])
print(Cscore)






Output:
0.9999999999999999
Example 4: Include samples from different classes don’t make for completeness labeling:
Python3
 

 
 










# Importing the module
from sklearn.metrics.cluster import completeness_score
 
# Evaluating the score
Cscore = completeness_score([0, 0, 0, 0], 
                            [0, 1, 2, 3])
print(Cscore)






Output:
0.0
 
sweetyty

ML-Clustering


Python

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Python | Get unique values from a list
Python | Pandas dataframe.groupby()
Defaultdict in Python
Ruby | Array select() function - GeeksforGeeks

06 Dec, 2019
Array#select() : select() is a Array class method which returns a new array containing all elements of array for which the given block returns a true value.
Syntax: Array.select()
Parameter: Array
Return: A new array containing all elements of array for which the given block returns a true value.
Example #1 :
# Ruby code for select() method  # declaring arraya = [18, 22, 33, 3, 5, 6]  # declaring arrayb = [1, 4, 1, 1, 88, 9]  # declaring arrayc = [18, 22, 3, 3, 50, 6]  # selectputs "select method : #{a.select {|num| num > 10 }}\n\n"  # selectputs "select method : #{b.select {|x| x.odd? }}\n\n"
Output :
select method : [18, 22, 33]

select method : [1, 1, 1, 9]


Example #2 :
# Ruby code for select() method  # declaring arraya = [18, 22, 33, 3, 5, 6]  # declaring arrayb = [1, 4, 1, 1, 88, 9]  # declaring arrayc = [18, 22, 3, 3, 53, 6]  # selectputs "select method : #{c.select {|num| num > 10 }}\n\n"  # selectputs "select method : #{c.select {|num| num.even? }}\n\n"
Output :
select method : [18, 22, 53]

select method : [18, 22, 6]


Ruby Array-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Ruby | Array count() operation
Ruby | Array slice() function
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Hash delete() function
Ruby | Enumerator each_with_index function
Ruby | Data Types
Ruby | Numeric round() function
Ruby For Beginners
Ruby | Decision Making (if, if-else, if-else-if, ternary) | Set - 1
Introduction to Semantic UI - GeeksforGeeks

21 Jan, 2022
Semantic UI is an open-source framework that uses CSS and jQuery to build great user interfaces. It is the same as a bootstrap for use and has great different elements to use to make your website look more amazing.How to use Semantic UI ? Just google CDN semantic UI and you will get the CDN link for semantic UI and just put it in your head tag of your HTML and you are good to go.Let’s see the code for how to put semantic UI CDN in HTML.  
<!DOCTYPE html><html>    <head>        <title>Semantic UI</title>        <link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"         rel="stylesheet" />    </head>    <body>        <h1>This is How to integrate semantic-ui</h1>        <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js">        </script>    </body></html>
And you can remove the link from the head to see the difference.The second way of using is downloading the min.css file of the Semantic UI whose link you can find on semantic UI official site and use it directly and it helps offline.Now let’s see an example of using Semantic-UI.  
<!DOCTYPE html><html>    <head>        <title>Semantic UI</title>        <link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"         rel="stylesheet" />    </head>    <body>        <div class="container">            <h1>GeeksforGeeks</h1>            <p>This is a simple example of using semantic-ui</p>        </div>        <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js">         </script>    </body></html>
Output:  
Let’s see another example of Semantic-UI loader.  
<!DOCTYPE html><html>    <head>        <title>Semantic UI</title>        <link href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.css"         rel="stylesheet" />    </head>    <body>        <div class="ui inverted segment">            <div class="ui active inverted loader"></div>            <br>            <br>            <br>            <br>          </div>        <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/semantic.min.js">         </script>    </body></html>
Output:  
You can directly run these examples by clicking on run on IDE. 
clintra
Semantic-UI
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
How to apply style to parent if it has child with CSS?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Groovy - xxxValue()

This method takes on the Number as the parameter and returns a primitive type based on the method which is invoked. Following are the list of methods available −
byte byteValue() 
short shortValue() 
int intValue() 
long longValue() 
float floatValue() 
double doubleValue()
Parameters − No parameters required.
Return Value − The return value is the primitive type returned depending on the value function which is called.
Following is an example of the usage of the method values.
class Example { 
   static void main(String[] args) {  
      Integer x = 5; 
		
      // Converting the number to double primitive type
      println(x.doubleValue()); 
		
      // Converting the number to byte primitive type 
      println(x.byteValue()); 
		
      // Converting the number to float primitive type 
      println(x.floatValue());
		
      // Converting the number to long primitive type 
      println(x.longValue()); 
		
      // Converting the number to short primitive type 
      println(x.shortValue()); 
		
      // Converting the number to int primitive type 
      println(x.intValue());  
   } 
}
When we run the above program, we will get the following result −
First() and Last()Function in MS Access

14 Sep, 2020
1. First() Function :In MS Access, the First() function is used to return a field value from the first record in the result set returned by a query.
Syntax :
First(expr)

Parameter :
expr : It represents a string expression identifying the field that contains the data we want to use or an expression that performs a calculation using the data in that field.
Returns : It returns the first record in the result set.
Example-1 :
SELECT First(Emp_id) AS EmployeeId FROM Employee_Details;

Output :
Example-2 :
SELECT First(Emp_Name) AS FirstEmployee FROM Employee_Details;

Output :
2. Last() Function :In MS Access, the Last() function is used to return a field value from the last record in the result set returned by a query.
Syntax :
Last(expr)

Parameter :
expr : It represents a string expression identifying the field that contains the data we want to use or an expression that performs a calculation using the data in that field.
Returns : It returns the last record in the result set.
Example-2 :
SELECT Last(Emp_id) AS EmployeeId FROM Employee_Details;

Output :
Example-2 :
SELECT Last(Emp_Name) AS LastEmployee FROM Employee_Details;

Output :
DBMS-SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL Interview Questions
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Difference between DDL and DML in DBMS
SQL | GROUP BY
Window functions in SQL
SQL Correlated Subqueries
Difference between DELETE and TRUNCATE
SQL | Sub queries in From Clause
ISO 9000 Certification in Software Engineering

23 Nov, 2020
The International organization for Standardization is a world wide federation of national standard bodies. The International standards organization (ISO) is a standard which serves as a for contract between independent parties. It specifies guidelines for development of quality system.
Quality system of an organization means the various activities related to its products or services. Standard of ISO addresses to both aspects i.e. operational and organizational aspects which includes responsibilities, reporting etc. An ISO 9000 standard contains set of guidelines of production process without considering product itself.
ISO 9000 Certification
Why ISO Certification required by Software Industry?There are several reasons why software industry must get an ISO certification. Some of reasons are as follows :
This certification has become a standards for international bidding.
It helps in designing high-quality repeatable software products.
It emphasis need for proper documentation.
It facilitates development of optimal processes and totally quality measurements.
Features of ISO 9001 Requirements :
Document control –All documents concerned with the development of a software product should be properly managed and controlled.
Planning –Proper plans should be prepared and monitored.
Review –For effectiveness and correctness all important documents across all phases should be independently checked and reviewed .
Testing –The product should be tested against specification.
Organizational Aspects –Various organizational aspects should be addressed e.g., management reporting of the quality team.
Advantages of ISO 9000 Certification :Some of the advantages of the ISO 9000 certification process are following :
Business ISO-9000 certification forces a corporation to specialize in “how they are doing business”. Each procedure and work instruction must be documented and thus becomes a springboard for continuous improvement.
Employees morale is increased as they’re asked to require control of their processes and document their work processes
Better products and services result from continuous improvement process.
Increased employee participation, involvement, awareness and systematic employee training are reduced problems.
Shortcomings of ISO 9000 Certification :Some of the shortcoming of the ISO 9000 certification process are following :
ISO 9000 does not give any guideline for defining an appropriate process and does not give guarantee for high quality process.
ISO 9000 certification process have no international accreditation agency exists.
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Unit Testing | Software Testing
Software Engineering | Classical Waterfall Model
Software Requirement Specification (SRS) Format
Difference between Spring and Spring Boot
Software Engineering | Requirements Engineering Process
Software Testing Life Cycle (STLC)
Difference between IAAS, PAAS and SAAS
Equivalence Partitioning Method
Software Engineering | SDLC V-Model
Levels in Data Flow Diagrams (DFD)
Python unittest – assertIsNone() function

29 Aug, 2020
assertIsNone() in Python is a unittest library function that is used in unit testing to check that input value is None or not. This function will take two parameters as input and return a boolean value depending upon assert condition. If input value is equal to None assertIsNone() will return true else return false.
Syntax: assertIsNone(testValue, message)
Parameters: assertIsNone() accept two parameters which are listed below with explanation:
testValue:  test variable as the input value to check equality with None
message: a string sentence as a message which got displayed when the test case got failed.
Listed below are two different examples illustrating the positive and negative test case for given assert function:
Example 1: Negative Test case
Python3
# unit test caseimport unittest  class DummyClass:  x = 5  class TestMethods(unittest.TestCase):    # test function     def test_negative(self):        firstValue = "geeks"        # error message in case if test case got failed        message = "Test value is not none."        # assertIsNone() to check that if input value is none        self.assertIsNone(firstValue, message)  if __name__ == '__main__':    unittest.main()
Output:
F
======================================================================
FAIL: test_negative (__main__.TestMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "p1.py", line 14, in test_negative
    self.assertIsNone(firstValue, message)
AssertionError: 'geeks' is not None : Test value is not none.

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (failures=1)


Example 2: Positive Test case
Python3
# unit test caseimport unittest  class DummyClass:  x = 5  class TestMethods(unittest.TestCase):    # test function     def test_positive(self):        firstValue = None        # error message in case if test case got failed        message = "Test value is not none."        # assertIsNone() to check that if input value is none        self.assertIsNone(firstValue, message)  if __name__ == '__main__':    unittest.main()
Output:
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK


Reference: https://docs.python.org/3/library/unittest.html
Python unittest-library
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 | os.path.join() method
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
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
How to Append Pandas DataFrame to Existing CSV File?

22 Dec, 2021
In this article, we will discuss how to append Pandas  dataframe to the existing CSV file using Python.
Appending dataframe means adding data rows to already existing files. To add a dataframe row-wise to an existing CSV file, we can write the dataframe to the CSV file in append mode by the parameter a using the pandas to_csv() function.
Syntax:
df.to_csv(‘existing.csv’, mode=’a’, index=False, header=False)
Parameters:
existing.csv: Name of the existing CSV file.
mode: By default mode is ‘w’ which will overwrite the file. Use ‘a’ to append data into the file.
index: False means do not include an index column when appending the new data. True means include an index column when appending the new data.
header: False means do not include a header when appending the new data. True means include a header when appending the new data.
Below are the steps to Append Pandas DataFrame to Existing CSV File.
First, find the CSV file in which we want to append the dataframe.  We have an existing CSV file with player name and runs, wickets, and catch done by the player. And we want to append some more player data to this CSV file. This is how the existing CSV file looks:
Now let’s say we want to add more players to this CSV file. First create a dataframe of that player with their corresponding run, wicket, and catch. And make their pandas dataframe. We will append this to the existing CSV file.
Let’s append the dataframe to the existing CSV file. Below is the python code.
Python3
# Append Pandas DataFrame to Existing CSV File# importing pandas moduleimport pandas as pd # data of Player and their performancedata = {    'Name': ['Hardik', 'Pollard', 'Bravo'],    'Run': [50, 63, 15],    'Wicket': [0, 2, 3],    'Catch': [4, 2, 1]} # Make data frame of above datadf = pd.DataFrame(data) # append data frame to CSV filedf.to_csv('GFG.csv', mode='a', index=False, header=False) # print messageprint("Data appended successfully.")
Output:
surindertarika1234
Picked
Python pandas-io
Python-pandas
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
Python Script to Restart Computer

14 Jul, 2019
As we know, Python is a popular scripting language because of its versatile features. In this article, we will write a Python script to restart a computer. Let’s start with how to restart the system with Python.
Note: For this to work, you have to import os library in the ide. If you don’t have it, then ‘pip install os‘ through the Command Prompt.
Causion: Please ensure that you save and close all the program before running this code on the IDLE, as the below program will immediately restart your computer.
Below is the Python implementation –
import os  restart = input("Do you wish to restart your computer ? (yes / no): ")  if restart == 'no':    exit()else:    os.system("shutdown /r /t 1")
Output:Here is the Python Program which will ask the user to restart the computer providing the option of Yes or No. Also, when you type yes & then press the ENTER key, the system will be restart instantly.
python-utility
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Read a file line by line in Python
How to Install PIP on Windows ?
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
SQL - Syntax

SQL is followed by a unique set of rules and guidelines called Syntax. This tutorial gives you a quick start with SQL by listing all the basic SQL Syntax.
All the SQL statements start with any of the keywords like SELECT, INSERT, UPDATE, DELETE, ALTER, DROP, CREATE, USE, SHOW and all the statements end with a semicolon (;).
The most important point to be noted here is that SQL is case insensitive, which means SELECT and select have same meaning in SQL statements. Whereas, MySQL makes difference in table names. So, if you are working with MySQL, then you need to give table names as they exist in the database.
SELECT column1, column2....columnN
FROM   table_name;

SELECT DISTINCT column1, column2....columnN
FROM   table_name;

SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION;

SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION-1 {AND|OR} CONDITION-2;

SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name IN (val-1, val-2,...val-N);

SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name BETWEEN val-1 AND val-2;

SELECT column1, column2....columnN
FROM   table_name
WHERE  column_name LIKE { PATTERN };

SELECT column1, column2....columnN
FROM   table_name
WHERE  CONDITION
ORDER BY column_name {ASC|DESC};

SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name;

SELECT COUNT(column_name)
FROM   table_name
WHERE  CONDITION;

SELECT SUM(column_name)
FROM   table_name
WHERE  CONDITION
GROUP BY column_name
HAVING (arithematic function condition);

CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY( one or more columns )
);

DROP TABLE table_name;

CREATE UNIQUE INDEX index_name
ON table_name ( column1, column2,...columnN);

ALTER TABLE table_name
DROP INDEX index_name;

DESC table_name;

TRUNCATE TABLE table_name;

ALTER TABLE table_name {ADD|DROP|MODIFY} column_name {data_ype};

ALTER TABLE table_name RENAME TO new_table_name;

INSERT INTO table_name( column1, column2....columnN)
VALUES ( value1, value2....valueN);

UPDATE table_name
SET column1 = value1, column2 = value2....columnN=valueN
[ WHERE  CONDITION ];

DELETE FROM table_name
WHERE  {CONDITION};

CREATE DATABASE database_name;

DROP DATABASE database_name;

USE database_name;

COMMIT;

ROLLBACK;


    42 Lectures 
     5 hours 

 Anadi Sharma

    14 Lectures 
     2 hours 

 Anadi Sharma

    44 Lectures 
     4.5 hours 

 Anadi Sharma

    94 Lectures 
     7 hours 

 Abhishek And Pukhraj

    80 Lectures 
     6.5 hours 

 Oracle Master Training | 150,000+ Students Worldwide

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
Creating a 3D plot in Matplotlib from a 3D numpy array

To create a 3D plot from a 3D numpy array, we can create a 3D array using numpy and extract the x, y,
and z points.
Create a new figure or activate an existing figure using figure() method.
Add an '~.axes.Axes' to the figure as part of a subplot arrangement using add_subplot() method.
Create a random data of size=(3, 3, 3).
Extract x, y, and z data from the 3D array.
Plot 3D scattered points on the created axis
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
data = np.random.random(size=(3, 3, 3))
z, x, y = data.nonzero()
ax.scatter(x, y, z, c=z, alpha=1)
plt.show()
How to Check Timezone in Linux - GeeksforGeeks

17 Jun, 2021
There are a number of time management utilities available on Linux such as timedatectl, date, etc by which you can view the current timezone in your Linux system. In this article, we will be discussing some ways by which you can check the system timezone in Linux. 
We can use the timedatectl command to display the timezone along with other information. We can check for the timezone-related info from the output.
Syntax : 
timedatectl
Example :
Using the command  timedatectl to display timezone
As we can see in the above example, we can easily find the timezone-related info which is “Asia/Kolkata ( IST, +0530)” in the above output screenshot.
We can use the pipeline feature of Linux ( output from one command becomes the input of another command ) to find out the timezone. In this case, the output generated from the timedatectl command is searched for a keyword, which in our case is “Time Zone” and we only get the relevant output finally.
Syntax :
timedatectl | grep "Time zone"
Example :
Using pipeline feature of Linux on timedatectl and grep to display timezone
In the above example, we have only got the required output “Time zone: Asia/Kolkata ( IST, +0530)” as compared to the previous method in which the only timedatectl was used. This can be a better method if you do not want to search for the required line in the output by yourself as in the previous method.
We can use the cat command and the required file to display the timezone. the cat command displays the contents of a file and for our case, in order to find the timezone, we will search for a file named timezone in /etc Linux directory. etc is a Linux directory that contains all the system configuration files.
Syntax :
cat /etc/timezone

OR

cd /etc
cat timezone
Example 1:
Using the first command “cat /etc/timezone”
using cat /etc/timezone commands to find the timezone
Example 2:
First go to the Linux directory /etc and then type the command cat timezone. 
A step by step process to display timezone using cd and cat commands
We can use the date command to view the timezone. Simply type the Linux command date in the terminal and you will get the required output.
Syntax :
date
Example :
Using date command to display timezone
As we can see from the above example, We have used the date command and timezone is displayed, which in our case is IST.
linux-command
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Thread functions in C/C++
nohup Command in Linux with Examples
scp command in Linux with Examples
chown command in Linux with Examples
Array Basics in Shell Scripting | Set 1
mv command in Linux with examples
Basic Operators in Shell Scripting
SED command in Linux | Set 2
Docker - COPY Instruction
Named Pipe or FIFO with example C program
LISP - Functions

A function is a group of statements that together perform a task.
You can divide up your code into separate functions. How you divide up your code among different functions is up to you, but logically the division usually is so each function performs a specific task.
The macro named defun is used for defining functions. The defun macro needs three arguments −
Name of the function
Parameters of the function
Body of the function
Syntax for defun is −
(defun name (parameter-list) "Optional documentation string." body)
Let us illustrate the concept with simple examples.
Let's write a function named averagenum that will print the average of four numbers. We will send these numbers as parameters.
Create a new source code file named main.lisp and type the following code in it.
(defun averagenum (n1 n2 n3 n4)
   (/ ( + n1 n2 n3 n4) 4)
)
(write(averagenum 10 20 30 40))
When you execute the code, it returns the following result −
25

Let's define and call a function that would calculate the area of a circle when the radius of the circle is given as an argument.
Create a new source code file named main.lisp and type the following code in it.
(defun area-circle(rad)
   "Calculates area of a circle with given radius"
   (terpri)
   (format t "Radius: ~5f" rad)
   (format t "~%Area: ~10f" (* 3.141592 rad rad))
)
(area-circle 10)
When you execute the code, it returns the following result −
Radius:  10.0
Area:   314.1592

Please note that −
You can provide an empty list as parameters, which means the function takes no arguments, the list is empty, written as ().
You can provide an empty list as parameters, which means the function takes no arguments, the list is empty, written as ().
LISP also allows optional, multiple, and keyword arguments.
LISP also allows optional, multiple, and keyword arguments.
The documentation string describes the purpose of the function. It is associated with the name of the function and can be obtained using the documentation function.
The documentation string describes the purpose of the function. It is associated with the name of the function and can be obtained using the documentation function.
The body of the function may consist of any number of Lisp expressions.
The body of the function may consist of any number of Lisp expressions.
The value of the last expression in the body is returned as the value of the function.
The value of the last expression in the body is returned as the value of the function.
You can also return a value from the function using the return-from special operator.
You can also return a value from the function using the return-from special operator.
Let us discuss the above concepts in brief. Click following links to find details −
Optional Parameters
Optional Parameters
Rest Parameters
Rest Parameters
Keyword Parameters
Keyword Parameters
Returning Values from a Function
Returning Values from a Function
Lambda Functions
Lambda Functions
Mapping Functions
Mapping Functions

    79 Lectures 
     7 hours 

 Arnold Higuit
 Print
 Add Notes
 Bookmark this page
How to match a word in python using Regular Expression?

The following code matches the word ‘meeting’ in the given string.
It uses positive look-ahead and look-behind assertions to respect enclosing characters but without including them in the match.
import re
s = """http://www.google.com/meeting_agenda_minutes.html"""
result = re.findall(r'(?<=[\W_])meeting(?=[\W_])', s)
print result
['meeting']
What is InputMisMatchException in Java how do we handle it?

From Java 1.5 Scanner class was introduced. This class accepts a File, InputStream, Path and, String objects, reads all the primitive data types and Strings (from the given source) token by token using regular expressions.
To read various datatypes from the source using the nextXXX() methods provided by this class namely, nextInt(), nextShort(), nextFloat(), nextLong(), nextBigDecimal(), nextBigInteger(), nextLong(), nextShort(), nextDouble(), nextByte(), nextFloat(), next().
Whenever you take inputs from the user using a Scanner class. If the inputs passed doesn’t match the method or an InputMisMatchException is thrown. For example, if you reading an integer data using the nextInt() method and the value passed in a String then, an exception occurs.
import java.util.Scanner;
public class StudentData{
   int age;
   String name;
   public StudentData(String name, int age){
      this.age = age;
      this.name = name;
   }
   public void display() {
      System.out.println("Name of the student is: "+name);
      System.out.println("Age of the student is: "+age);
   }
   public static void main (String args[]){
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter your name: ");
      String name = sc.next();
      System.out.println("Enter your age: ");
      int age = sc.nextInt();
      StudentData obj = new StudentData(name, age);
      obj.display();
   }
}
Enter your name:
Krishna
Enter your age:
twenty
Exception in thread "main" java.util.InputMismatchException
   at java.util.Scanner.throwFor(Unknown Source)
   at java.util.Scanner.next(Unknown Source)
   at java.util.Scanner.nextInt(Unknown Source)
   at java.util.Scanner.nextInt(Unknown Source)
   at july_set3.StudentData.main(StudentData.java:20)
The only way to handle this exception is to make sure that you enter proper values while passing inputs. It is suggested to specify required values with complete details while reading data from user using scanner class.
Concatenate date and time from separate columns into a single column in MySQL

For this, concatenate both the date and time using CONCAT() function. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> ShippingDate date,
   -> ShippingTime time,
   -> ShippingDatetime datetime
   -> );
Query OK, 0 rows affected (0.50 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(ShippingDate,ShippingTime) values('2019-01-10', '10:40:20');
Query OK, 1 row affected (0.13 sec)

mysql> insert into DemoTable(ShippingDate,ShippingTime) values('2019-06-14', '04:00:10');
Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
+--------------+--------------+------------------+
| ShippingDate | ShippingTime | ShippingDatetime |
+--------------+--------------+------------------+
| 2019-01-10   | 10:40:20     | NULL             |
| 2019-06-14   | 04:00:10     | NULL             |
+--------------+--------------+------------------+
2 rows in set (0.00 sec)
Here is the query to concatenate date and time from separate columns into a single column in MySQL −
mysql> update DemoTable set ShippingDatetime=concat(ShippingDate,' ',ShippingTime);
Query OK, 2 rows affected (0.11 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Let us check table records once again −
mysql> select *from DemoTable;
+--------------+--------------+---------------------+
| ShippingDate | ShippingTime | ShippingDatetime    |
+--------------+--------------+---------------------+
| 2019-01-10   | 10:40:20     | 2019-01-10 10:40:20 |
| 2019-06-14   | 04:00:10     | 2019-06-14 04:00:10 |
+--------------+--------------+---------------------+
2 rows in set (0.00 sec)
T-SQL - ORDER BY Clause

The MS SQL Server ORDER BY clause is used to sort the data in ascending or descending order, based on one or more columns. Some database sort query results in ascending order by default.
Following is the basic syntax of ORDER BY clause.
SELECT column-list  
FROM table_name  
[WHERE condition]  
[ORDER BY column1, column2, .. columnN] [ASC | DESC];

You can use more than one column in the ORDER BY clause. Make sure whatever column you are using to sort, that column should be in column-list.
Consider the CUSTOMERS table having the following records −
ID  NAME       AGE       ADDRESS            SALARY 
1   Ramesh     32        Ahmedabad          2000.00 
2   Khilan     25        Delhi              1500.00 
3   kaushik    23        Kota               2000.00 
4   Chaitali   25        Mumbai             6500.00 
5   Hardik     27        Bhopal             8500.00 
6   Komal      22        MP                 4500.00 
7   Muffy      24        Indore             10000.00 

Following command is an example, which would sort the result in ascending order by NAME and SALARY.
SELECT * FROM CUSTOMERS 
   ORDER BY NAME, SALARY 
The above command will produce the following output.
ID  NAME       AGE       ADDRESS           SALARY 
4   Chaitali   25        Mumbai            6500.00 
5   Hardik     27        Bhopal            8500.00 
3   kaushik    23        Kota              2000.00 
2   Khilan     25        Delhi             1500.00 
6   Komal      22        MP                4500.00 
7   Muffy      24        Indore            10000.00 
1   Ramesh     32        Ahmedabad         2000.00 

Following command is an example, which would sort the result in descending order by NAME.
SELECT * FROM CUSTOMERS 
   ORDER BY NAME DESC
The above command will produce the following result −
ID  NAME       AGE       ADDRESS            SALARY 
1   Ramesh     32        Ahmedabad          2000.00
7   Muffy      24        Indore             10000.00  
6   Komal      22        MP                 4500.00 
2   Khilan     25        Delhi              1500.00 
3   kaushik    23        Kota               2000.00
5   Hardik     27        Bhopal             8500.00
4   Chaitali   25        Mumbai             6500.00  


    12 Lectures 
     2 hours 

 Nishant Malik

    10 Lectures 
     1.5 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    20 Lectures 
     2 hours 

 Asif Hussain

    10 Lectures 
     1.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain
 Print
 Add Notes
 Bookmark this page