code-rag-bench/online-tutorials huggingface dataset:
What are static members of a C# Class?

We can define class members as static using the static keyword. When we declare a member of a class as static, it means no matter how many objects of the class are created, there is only one copy of the static member.
The keyword static implies that only one instance of the member exists for a class. Static variables are used for defining constants because their values can be retrieved by invoking the class without creating an instance of it. Static variables can be initialized outside the member function or class definition. You can also initialize static variables inside the class definition.
The following is an example −
 Live Demo
using System;

namespace StaticVarApplication {
   class StaticVar {
      public static int num;

      public void count() {
         num++;
      }

      public int getNum() {
         return num;
      }
   }

   class StaticTester {
      static void Main(string[] args) {
         StaticVar s1 = new StaticVar();
         StaticVar s2 = new StaticVar();

         s1.count();
         s1.count();
         s1.count();

         s2.count();
         s2.count();
         s2.count();

         Console.WriteLine("Variable num for s1: {0}", s1.getNum());
         Console.WriteLine("Variable num for s2: {0}", s2.getNum());
         Console.ReadKey();
      }
   }
}
Variable num for s1: 6
Variable num for s2: 6
How to center a div on the screen using jQuery?

To center a div on the screen, use the jQuery centering function jQuery.fn.center. You can try to run the following code to learn how to center a div on the screen:
Live Demo
<!DOCTYPE html>
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
      jQuery.fn.center = function(parent) {
        if (parent) {
          parent = this.parent();
        } else {
          parent = window;
        }
      this.css({
       "position": "absolute",
       "top": ((($(parent).height() - this.outerHeight()) / 2) + $(parent).scrollTop() + "px"),
       "left": ((($(parent).width() - this.outerWidth()) / 2) + $(parent).scrollLeft() + "px")
      });
     return this;
     }
     $("div.myclass:nth-child(1)").center(true);
     $("div.myclass:nth-child(2)").center(false);
   });
</script>
<style>
  div.box {
    width:300px;
    height:300px;
    border:2px solid #000000;
    position:relative;
    top:10px;
    left:10px;
  }
  div.myclass {
    width:50px;
    height:50px;
    color:white;
    background: #000000;
    border-radius: 4px;
    text-align:center;
  }
 </style>
</head>
<body>
  <div class="box">
    <div class="myclass">1<br>parent</div>
    <div class="myclass">2<br>window</div>
  </div>
</body>
</html>
Benefits of inline functions in C++?

C++ inline function is a powerful concept that is commonly used with classes. If a function is inline, the compiler places a copy of the code of that function at each point where the function is called at compile time.
Any change to an inline function could require all clients of the function to be recompiled because compiler would need to replace all the code once again otherwise it will continue with old functionality.
To inline a function, place the keyword inline before the function name and define the function before any calls are made to the function. The compiler can ignore the inline qualifier in case defined function is more than a line.
A function definition in a class definition is an inline function definition, even without the use of the inline specifier.
Following is an example, which makes use of inline function to return max of two numbers −
#include <iostream>
using namespace std;
inline int Max(int x, int y) {
   return (x > y)? x : y;
}
// Main function for the program
int main() {
   cout << "Max (20,10): " << Max(20,10) << endl;
   cout << "Max (0,200): " << Max(0,200) << endl;
   cout << "Max (100,1010): " << Max(100,1010) << endl;
   return 0;
}
Max (20,10): 20
Max (0,200): 200
Max (100,1010): 1010
Now let us see, what are the benefits of using the inline functions in our code −
Here the function call overhead does not occur.
Here the function call overhead does not occur.
It saves the overhead of the push and pop variables on the stack, when the function is called.
It saves the overhead of the push and pop variables on the stack, when the function is called.
It saves the overhead of return call from a function.
It saves the overhead of return call from a function.
When one inline function is created, the compiler may perform context
specific optimization on the body of the function. This kind of optimizations are not performed for normal functions.
When one inline function is created, the compiler may perform context
specific optimization on the body of the function. This kind of optimizations are not performed for normal functions.
Using of small inline functions may be useful for embedded systems, because inline can yield less code than the function call preamble and return.
Using of small inline functions may be useful for embedded systems, because inline can yield less code than the function call preamble and return.
Finding all the Elements of a Range from Start to End in C# - GeeksforGeeks

28 Jun, 2021
The Range Structure is introduced in C# 8.0. It represents a range that has a start and end indexes. You are allowed to find all the range object starting from the start index to end with the help of All Property provided by the Range struct. This property always returns 0..^0 range.Syntax:  
public static property Range All { Range get(); };
Here, Range represents the index from start to end.Example 1: 
CSharp
// C# program to illustrate the use of the// All property of the Range structusing System; namespace range_example { class GFG {     // Main Method    static void Main(string[] args)    {        // Creating range        // using Range Constructor        var r = new Range(0, 5);         // Getting the range objects from        // the starting index to end        // Using All property        var new_r = Range.All;        Console.WriteLine(new_r);    }}}
Output:  
0..^0
Example 2: 
CSharp
// C# program to illustrate how to use// All property of the Range structusing System;  namespace range_example {  class GFG {      // Main Method    static void Main(string[] args)    {        // Creating and initializing an array        int[] arr = new int[10] {23, 45, 67, 78,                        89, 34, 89, 43, 67, 89};          // Finding all the range        // Using All Property        // of Range struct        var value = Range.All;        var a = arr[value];          // Displaying range and elements        Console.WriteLine("Range: " + value);        Console.WriteLine("Numbers: ");          foreach(var i in a)            Console.Write($"{i}, ");    }}}
Output:  
Range: 0..^0
Numbers:
23,  45,  67,  78,  89,  34,  89,  43,  67,  89, 
 
saurabh1990aror
CSharp-8.0
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Difference between Ref and Out keywords in C#
C# | Delegates
C# | Constructors
Extension Method in C#
Introduction to .NET Framework
C# | Class and Object
C# | Abstract Classes
C# | Data Types
HashSet in C# with Examples
MySQL Stored Procedure DEFINER=`root`@`%` is not working in localhost?

First of all, you need to check the host. The host can be ‘localhost’ or ‘%’. Check the existence of user accounts with host −
mysql> select user,host from MySQL.user;
This will produce the following output −
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| Bob              | %         |
| User2            | %         |
| mysql.infoschema | %         |
| mysql.session    | %         |
| mysql.sys        | %         |
| root             | %         |
| @UserName@       | localhost |
| Adam Smith       | localhost |
| David            | localhost |
| James            | localhost |
| John             | localhost |
| John Doe         | localhost |
| User1            | localhost |
| am               | localhost |
| hbstudent        | localhost |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
+------------------+-----------+
17 rows in set (0.00 sec)
Now, we are going to change the definer for user Bob and host is ‘%’. Following is the query to create a stored procedure with definer −
mysql> DELIMITER //
   mysql> CREATE DEFINER=`Bob`@`%` PROCEDURE `Message`()
      BEGIN
        select "Hello World";
        END
        //
   Query OK, 0 rows affected (0.14 sec)
mysql> DELIMITER ;
Now call the stored procedure with the help of CALL command −
mysql> call `Message`();
This will produce the following output −
+-------------+
| Hello World |
+-------------+
| Hello World |
+-------------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
How to render Pandas DataFrame as HTML Table?

28 Feb, 2022
Pandas in Python has the ability to convert Pandas DataFrame to a table in the HTML web page. pandas.DataFrame.to_html()  method is used for render a Pandas DataFrame.
Syntax : DataFrame.to_html()Return : Return the html format of a dataframe.
Let’s understand with examples:
First, create a Dataframe:
Python3
# importing pandas as pdimport pandas as pdfrom IPython.display import HTML  # creating the dataframedf = pd.DataFrame({"Name": ['Anurag', 'Manjeet', 'Shubham',                             'Saurabh', 'Ujjawal'],                                        "Address": ['Patna', 'Delhi', 'Coimbatore',                               'Greater noida', 'Patna'],                                        "ID": [20123, 20124, 20145, 20146, 20147],                                        "Sell": [140000, 300000, 600000, 200000, 600000]})  print("Original DataFrame :")display(df)
Output:
Convert Dataframe to Html table:
Python3
result = df.to_html()print(result)
Output:
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Name</th>
      <th>Address</th>
      <th>ID</th>
      <th>Sell</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>Anurag</td>
      <td>Patna</td>
      <td>20123</td>
      <td>140000</td>
    </tr>
    <tr>
      <th>1</th>
      <td>Manjeet</td>
      <td>Delhi</td>
      <td>20124</td>
      <td>300000</td>
    </tr>
    <tr>
      <th>2</th>
      <td>Shubham</td>
      <td>Coimbatore</td>
      <td>20145</td>
      <td>600000</td>
    </tr>
    <tr>
      <th>3</th>
      <td>Saurabh</td>
      <td>Greater noida</td>
      <td>20146</td>
      <td>200000</td>
    </tr>
    <tr>
      <th>4</th>
      <td>Ujjawal</td>
      <td>Patna</td>
      <td>20147</td>
      <td>600000</td>
    </tr>
  </tbody>
</table>

Let write the script for convert DataFrame into HTML file:
Python3
html = df.to_html()  # write html to filetext_file = open("index.html", "w")text_file.write(html)text_file.close()
Note: The HTML file will be created with HTML data in the current working directory.
Output:
Let’s display HTML data in the form of a table-stripped
Python3
HTML(df.to_html(classes='table table-stripped'))
Output:
adnanirshad158
Python pandas-dataFrame
Python Pandas-exercise
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Convert integer to string in Python
Python OOPs Concepts
Introduction To PYTHON
How to place a thousand separator in MySQL records?

Use the FORMAT() method for this. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Amount DECIMAL(10,2)
   -> );
Query OK, 0 rows affected (0.45 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(84848757.60);
Query OK, 1 row affected (0.14 sec)

mysql> insert into DemoTable values(95868685.50);
Query OK, 1 row affected (0.15 sec)

mysql> insert into DemoTable values(4242342.36);
Query OK, 1 row affected (0.21 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
+-------------+
| Amount      |
+-------------+
| 84848757.60 |
| 95868685.50 |
|  4242342.36 |
+-------------+
3 rows in set (0.00 sec)
Following is the query to set separator in MySQL −
mysql> select format(Amount,2) from DemoTable;
+------------------+
| format(Amount,2) |
+------------------+
| 84,848,757.60    |
| 95,868,685.50    |
| 4,242,342.36     |
+------------------+
3 rows in set (0.00 sec)
HTML5 <article> Tag

17 Mar, 2022
The <article> tag is one of the new sectioning element in HTML5. The HTML <article> tag is used to represent an article. More specifically, the content within the <article> tag is independent of the other content of the site (even though it can be related).
In other words, The article element represents a component of a page that consists of self-contained composition in a document, page, or site. For Ex. in syndication.
A potential source for Article Element are:
A magazine/newspaper article
A blog entry
A forum post
A user-submitted a comment
This tag is most often used in two contexts:
On a page with a single piece of content, a single <article> element can be used to contain the main content and set it off from the rest of the page.
On a page with multiple pieces of content (a blog index page, a search results page, a category page, news feed), multiple <article> elements can be used to contain each individual piece of content.
Either way, it is similar to the <div> element and displays the stylish work the same. However, using the <article> element instead of <div> provides more semantic information to screen readers, search engines, and third-party applications.
Note: This tag does not render as anything special in a browser, you have to use CSS for that.
Default CSS setting: Most browsers will display the Article element with the following values.
HTML
<article> {     display:block; } 
Example: Using inline styling in an article element
HTML
<!DOCTYPE html><html>  <body>    <article      style="        width: 300px;        border: 2px solid gray;        padding: 10px;        border-radius: 10px;        margin: 5px;      "    >      <img        src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"        alt=""        width="300"        height="250"        class="alignnone size-medium wp-image-560930"      />      <h1>GeeksforGeeks</h1>        <p>        Sandeep Jain(FOUNDER) An IIT Roorkee alumnus and         founder of GeeksforGeeks. Apart from GeeksforGeeks,         he has worked with DE Shaw and Co. as a software         developer and JIIT Noida as an assistant professor.      </p>      </article>  </body></html>
Output: 
Supported Browsers: 
Google Chrome 6.0 and above
Internet Explorer 9.0 and above
Firefox 4.0 and above
Opera 11.1 and above
Safari 5.0 and above
nidhi_biet
shubhamyadav4
HTML-Tags
HTML5
Picked
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Ruby | String include? Method

09 Dec, 2019
include? is a String class method in Ruby which is used to return true if the given string contains the given string or character.
Syntax: str.include?
Parameters: Here, str is the given string.
Returns: true if the given string contains the given string or character otherwise false.
Example 1:
# Ruby program to demonstrate # the include?  method        # Taking a string and # using the methodputs "Ruby".include? "by"                 puts "String".include? "ui"
Output:
true
false

Example 2:
# Ruby program to demonstrate # the include?  method        # Taking a string and # using the methodputs "Sample".include? "am"                 puts "Input".include? "pt"
Output:
true
false

Ruby String-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Ruby | Array count() operation
Include v/s Extend in Ruby
Global Variable in Ruby
Ruby | Enumerator each_with_index function
Ruby | Case Statement
Ruby | Array select() function
Ruby | Hash delete() function
Ruby | unless Statement and unless Modifier
Ruby | Data Types
Python | Adding K to each element in a list of integers

28 Jan, 2019
While working with the Python lists, we can come over a situation in which we require to add the integer k to each element in the list. We possibly need to iterate and add k to each element but that would increase the line of code. Let’s discuss certain shorthands to perform this task.
Method #1 : Using List ComprehensionList comprehension is just the short way to perform the task we perform using the naive method. This is mainly useful to save time and also is best among others when it comes to readability of the code.
# Python3 code to demonstrate # adding K to each element# using list comprehension  # initializing list  test_list = [4, 5, 6, 3, 9]  # printing original listprint ("The original list is : " + str(test_list))  # initializing KK = 4  # using list comprehension# adding K to each elementres = [x + K for x in test_list]  # printing result print ("The list after adding K to each element : " +  str(res))
Output :
The original list is : [4, 5, 6, 3, 9]
The list after adding K to each element : [8, 9, 10, 7, 13]

Method #2 : Using map() + lambdamap function can be used to pair each element with the lambda function which performs the task of adding K to each element in the list.
# Python3 code to demonstrate # adding K to each element# using map() + lambda  # initializing list  test_list = [4, 5, 6, 3, 9]  # printing original listprint ("The original list is : " + str(test_list))  # initializing KK = 4  # using map() + lambda# adding K to each elementres = list(map(lambda x : x + K, test_list))  # printing result print ("The list after adding K to each element : " +  str(res))
Output :
The original list is : [4, 5, 6, 3, 9]
The list after adding K to each element : [8, 9, 10, 7, 13]

Method #3 : Using map() + operator.addThis is similar to the above function but uses the operator.add to add each element to other element from the other list of K formed before applying the map function. It adds the similar index elements of list.
# Python3 code to demonstrate # adding K to each element# using map() + operator.addimport operator  # initializing list  test_list = [4, 5, 6, 3, 9]  # printing original listprint ("The original list is : " + str(test_list))  # initializing K listK_list = [4] * len(test_list)  # using map() + operator.add# adding K to each elementres = list(map(operator.add, test_list, K_list))  # printing result print ("The list after adding K to each element : " +  str(res))
Output :
The original list is : [4, 5, 6, 3, 9]
The list after adding K to each element : [8, 9, 10, 7, 13]

Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Series.rank()

11 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.rank() function compute numerical data ranks (1 through n) along axis. Equal values are assigned a rank that is the average of the ranks of those values.
Syntax: Series.rank(axis=0, method=’average’, numeric_only=None, na_option=’keep’, ascending=True, pct=False)
Parameter :axis : index to direct rankingmethod : {‘average’, ‘min’, ‘max’, ‘first’, ‘dense’}numeric_only : Include only float, int, boolean data. Valid only for DataFrame or Panel objectsna_option : {‘keep’, ‘top’, ‘bottom’}ascending : False for ranks by high (1) to low (N)pct : Computes percentage rank of data
Returns : ranks : same type as caller
Example #1: Use Series.rank() function to rank the underlying data of the given Series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([10, 25, 3, 11, 24, 6])  # Create the Indexindex_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp']  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.rank() function to return the rank of the underlying data of the given Series object.
# assign rankresult = sr.rank()  # Print the resultprint(result)
Output :
As we can see in the output, the Series.rank() function has assigned rank to each element of the given Series object.
Example #2: Use Series.rank() function to rank the underlying data of the given Series object. The given data also contains some equal values.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([10, 25, 3, 11, 24, 6, 25])  # Create the Indexindex_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp', 'Appy']  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.rank() function to return the rank of the underlying data of the given Series object.
# assign rankresult = sr.rank()  # Print the resultprint(result)
Output :
As we can see in the output, the Series.rank() function has assigned rank to each element of the given Series object. Notice equal values has been assigned a rank which is the average of their ranks.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Convert integer to string in Python
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
PyQt5 QProgressBar – How to create progress bar ?

22 Apr, 2020
In this article we will see how we can create the progress bar in PyQt5. In order to create progress bar object we will use QProgressBar.
A progress bar is a graphical control element used to visualize the progression of an extended computer operation, such as a download, file transfer, or installation. Sometimes, the graphic is accompanied by a textual representation of the progress in a percent format.
Syntax :
pbar = QProgressBar(self)
Code :
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5.QtCore import * import sysimport time  class Example(QWidget):      def __init__(self):        super().__init__()          # calling initUI method        self.initUI()      # method for creating widgets    def initUI(self):          # creating progress bar        self.pbar = QProgressBar(self)          # setting its geometry        self.pbar.setGeometry(30, 40, 200, 25)          # creating push button        self.btn = QPushButton('Start', self)          # changing its position        self.btn.move(40, 80)          # adding action to push button        self.btn.clicked.connect(self.doAction)          # setting window geometry        self.setGeometry(300, 300, 280, 170)          # setting window action        self.setWindowTitle("Python")          # showing all the widgets        self.show()      # when button is pressed this method is being called    def doAction(self):          # setting for loop to set value of progress bar        for i in range(101):              # slowing down the loop            time.sleep(0.05)              # setting value to progress bar            self.pbar.setValue(i)  # main methodif __name__ == '__main__':                # create pyqt5 app    App = QApplication(sys.argv)      # create the instance of our Window    window = Example()      # start the app    sys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Retrieve the Records Based on a Date from Oracle Database?

28 Oct, 2021
DATE is a SQL-defined data type that is used to store dates in a column, different database management systems store dates in different formats. MySQL uses 3 bytes to store dates. It stores DATE in a format like ‘YYYY-MM-DD’. The DATE value ranges from 1000-01-01 to 9999-12-31. Oracle database management system stores DATE in a format like ‘MM-DD-YYYY’. 
Here ‘MM’ is month, ‘DD’ is day and ‘YYYY’ is the year. Microsoft SQL Server stores date in the same format as MySQL stores it. 
Step 1: Create a database
Query:
CREATE DATABASE geeksforgeeks;
Step 2: Let’s create a table named employees.
Query:
CREATE TABLE employee
(emp_id INT, emp_fname VARCHAR(45), 
emp_lname VARCHAR(45),join_date DATE, 
PRIMARY KEY(emp_id));
Step 3: Now we will insert values in the employee table. 
Query:
INSERT INTO employee VALUES 
(100181, 'Utkarsh', 'Tyagi', '1996-01-31'),
 (100182, 'Abhishek', 'Singh', '1996-03-21'), 
(100183, 'Jake', 'Johnson', '1997-06-14'), 
(100184, 'Abhimanyu', 'Rana', '1997-11-06'), 
(100185, 'Akansha', 'Sharma', '1998-11-23'), 
(100186, 'Priya', 'Yadav', '1999-10-10'),
(100187, 'Naina', 'Singhal', '2000-06-13');
Step 4: Now let’s see the contents of our table.
Query:
SELECT * FROM employee;
Output:
Step 5: We want to print only those records whose join_date is ‘2000-06-13’.
Retrieving records based on DATE using the ‘=’ operator.
Query:
SELECT * FROM employee WHERE join_date = '2000-06-13';
Output:
We have only one employee whose join_date is on ‘2000-06-13’.
Retrieving records based on DATE using LIKE keyword
We will be using the same employee table that we have used in the above example. Now our task is to retrieve those records whose join_date is in the year 1996 irrespective of day and month.
Query:
SELECT * FROM employee WHERE join_date LIKE '1996-%';
So we have two records whose join_date is in the year 1996.
 Retrieving records based on DATE using BETWEEN keyword
We want to retrieve those records where join_date in between years 1996 and 1997.
Query:
SELECT * FROM employee WHERE join_date BETWEEN '1996-01-01' AND '1997-12-31';
So there are four employees who joined the company between that time interval.
Oracle
Picked
SQL
Oracle
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?
Window functions in SQL
What is Temporary Table in SQL?
SQL | Sub queries in From Clause
SQL using Python
RANK() Function in SQL Server
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
How to Write a SQL Query For a Specific Date Range and Date Time?
Append to JSON file using Python

31 Aug, 2021
The full form of JSON is JavaScript Object Notation. It means that a script (executable) file which is made of text in a programming language, is used to store and transfer the data. Python supports JSON through a built-in package called JSON. To use this feature, we import the JSON package in Python script. The text in JSON is done through quoted-string which contains the value in key-value mapping within { }.  
json.loads(): json.loads() function is present in python built-in ‘json’ module. This function is used to parse the JSON string. 
Syntax: json.loads(json_string)Parameter: It takes JSON string as the parameter.Return type: It returns the python dictionary object.  
 
json.dumps(): json.dumps() function is present in python built-in ‘json’ module. This function is used to convert Python object into JSON string. 
Syntax: json.dumps(object)Parameter: It takes Python Object as the parameter.Return type: It returns the JSON string.  
 
update(): This method updates the dictionary with elements from another dictionary object or from an iterable key/value pair. 
Syntax: dict.update([other])Parameters: Takes another dictionary or an iterable key/value pair.Return type: Returns None.  
 
Example 1: Updating a JSON string.  
Python3
# Python program to update# JSON  import json  # JSON data:x =  '{ "organization":"GeeksForGeeks",        "city":"Noida",        "country":"India"}' # python object to be appendedy = {"pin":110096} # parsing JSON string:z = json.loads(x)  # appending the dataz.update(y) # the result is a JSON string:print(json.dumps(z))
Output: 
{“pin”: 110096, “organization”: “GeeksForGeeks”, “country”: “India”, “city”: “Noida”}  
Example 2: Updating a JSON file. Suppose the JSON file looks like this. 
We want to add another JSON data after emp_details. Below is the implementation.
Python3
# Python program to update# JSON  import json  # function to add to JSONdef write_json(new_data, filename='data.json'):    with open(filename,'r+') as file:          # First we load existing data into a dict.        file_data = json.load(file)        # Join new_data with file_data inside emp_details        file_data["emp_details"].append(new_data)        # Sets file's current position at offset.        file.seek(0)        # convert back to json.        json.dump(file_data, file, indent = 4)     # python object to be appendedy = {"emp_name":"Nikhil",     "email": "nikhil@geeksforgeeks.org",     "job_profile": "Full Time"    }     write_json(y)
Output: 
 
Akanksha_Rai
c0dezer019
erielcruz
sagar0719kumar
Python-json
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
LinkedList clear() Method in Java

10 Dec, 2018
The Java.util.LinkedList.clear() method is used to remove all the elements from a linked list. Using the clear() method only clears all the element from the list and not deletes the list. In other words we can say that the clear() method is used to only empty an existing LinkedList.
Syntax:
void clear()

Parameters: This function does not accept any parameter.
Return Value: This method does not return any value.
Below program illustrate the Java.util.LinkedList.clear() method:
// Java code to illustrate boolean clear()import java.io.*;import java.util.LinkedList;  public class LinkedListDemo {    public static void main(String args[])    {          // Creating an empty LinkedList        LinkedList<String> list = new LinkedList<String>();          // Using add() method to add elements in the list        list.add("Geeks");        list.add("for");        list.add("Geeks");        list.add("10");        list.add("20");          // Displaying the List        System.out.println("Original LinkedList:" + list);          // Clearing the list        list.clear();          // Accessing the List after clearing it        System.out.println("List after clearing all elements: " + list);          // Adding elements after clearing the list        list.add("Geeks");        list.add("for");        list.add("Geeks");          // Displaying the List        System.out.println("After adding elements to empty list:" + list);    }}
Output:
Original LinkedList:[Geeks, for, Geeks, 10, 20]
List after clearing all elements: []
After adding elements to empty list:[Geeks, for, Geeks]

Java - util package
Java-Collections
Java-Functions
java-LinkedList
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
Stream In Java
Collections in Java
Multidimensional Arrays in Java
Singleton Class in Java
Stack Class in Java
Set in Java
Set a blue border to an element in Bootstrap

Use the border-primary class to set a blue border to an element.
For a blue border, add the class, as if you add it for <div> or any other element −
<div class="demo border border-primary">
</div>
Let us see an example to set a blue border −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
    <style>
    .demo {
      width: 350px;
      height: 170px;
      margin: 10px;
    }
    </style>
  </head>
  <body>
    <div class="container">
      <h2>Demo Heading</h2>
      <div class="demo border border-primary">This rectangle has blue border</div>
    </div>
  </body>
</html>
C Program to find sum of two numbers without using any operator

In this section we will see how to print the sum of two numbers without using any type of operator into our program.
This problem is tricky. To solve this problem we are using minimum width field of printf() statement. For an example if we want to put x number of spaces before “Hello” using printf() we can write this. Here printf() takes the width and then the character that will be printed. In this case we are writing blank space.
#include<stdio.h>
main() {
   int x = 10;
   printf("%*cHello", x, ' ');
}
Hello
Now let us see how this functionality can help us to get the result of sum in our code. We take x and y as input to get result of x + y. So using this procedure we will create x number of spaces followed by y number of spaces. Then we take the returned value of the printf() as our result. We know that the printf() returns the length of that string.
#include<stdio.h>
int add(int x, int y) {
   int len;
   len = printf("%*c%*c", x, ' ', y, ' ');
   return len;
}
main() {
   int x = 10, y = 20;
   int res = add(x, y);
   printf("\nThe result is: %d", res);
}
The result is: 30
Components in Angular 8 - GeeksforGeeks

04 Nov, 2020
The component is the basic building block of Angular. It has a selector, template, style, and other properties, and it specifies the metadata required to process the component. 
Creating a Component in Angular 8:
To create a component in any angular application, follow the below steps:
Get to the angular app via your terminal.
Create a component using the following command:
ng g c <component_name> 
OR
ng generate component <component_name> 
Following files will be created after generating the component:
Using a component in Angular 8:
Go to the component.html file and write the necessary HTML code.
Go to the component.css file and write the necessary CSS code.
Write the corresponding code in component.ts file.
Run the Angular app using ng serve –open
Implementation code: Please note that the name of the component in the below code is gfg component.
gfg.component.html:
<h1>GeeksforGeeks</h1>
gfg.component.css:
h1{    color: green;    font-size: 30px;}
gfg.component.ts:
import { Component, OnInit } from '@angular/core';  @Component({  selector: 'app-gfg',  templateUrl: './gfg.component.html',  styleUrls: ['./gfg.component.css']})export class GfgComponent{    a ="GeeksforGeeks";}
app.module.ts:
import { NgModule } from '@angular/core';import { BrowserModule } from '@angular/platform-browser';  import { AppComponent } from './app.component';import { GfgComponent } from './gfg/gfg.component';      @NgModule({  imports:      [ BrowserModule ],  declarations: [ AppComponent, GfgComponent ],  bootstrap:    [ AppComponent ]})export class AppModule { }
Output:
bunnyram19
AngularJS-Basics
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Auth Guards in Angular 9/10/11
How to bundle an Angular app for production?
What is AOT and JIT Compiler in Angular ?
Angular PrimeNG Dropdown Component
How to set focus on input field automatically on page load in AngularJS ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Program for factorial of a number in C program

Given with the number n the task is to calculate the factorial of a number. Factorial of a number is calculated by multiplying the number with its smallest or equal integer values.
Factorial is calculated as −
0! = 1
1! = 1
2! = 2X1 = 2
3! = 3X2X1 = 6
4! = 4X3X2X1= 24
5! = 5X4X3X2X1 = 120
.
.
.
N! = n * (n-1) * (n-2) * . . . . . . . . . .*1
Input 1 -: n=5
   Output : 120
Input 2 -: n=6
   Output : 720
There are multiple methods that can be used −
Through the loops
Through recursion which is not at all effective
 Through a function
Given below is the implementation using functions
Start
Step 1 -> Declare function to calculate factorial
   int factorial(int n)
      IF n = 0
         return 1
      End
      return n * factorial(n - 1)
step 2 -> In main()
   Declare variable as int num = 10
   Print factorial(num))
Stop
#include<stdio.h>
// function to find factorial
int factorial(int n){
   if (n == 0)
   return 1;
   return n * factorial(n - 1);
}
int main(){
   int num = 10;
   printf("Factorial of %d is %d", num, factorial(num));
   return 0;
}
Factorial of 10 is 3628800
#include<iostream>
using namespace std;
// function to find factorial
int factorial(int n){
   if (n == 0)
   return 1;
   return n * factorial(n - 1);
}
   int main(){
   int num = 7;
   cout << "Factorial of " << num << " is " << factorial(num) << endl;
   return 0;
}
Factorial of 7 is 5040
Perl eval Function

This function evaluates EXPR at execution time as if EXPR were a separate Perl script. This allows you to use a separate, perhaps user-supplied, piece of Perl script within your program. An eval EXPR statement is evaluated separately each time the function is called.
The second form evaluates BLOCK when the rest of the script is parsed (before execution).
Following is the simple syntax for this function −
eval EXPR

eval BLOCK

This function returns value of last evaluated statement in EXPR or BLOCK

    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
How to find consonants in a given string using Java?

One way to find the vowels in a given String is to compare every character in it using the charAt() method with the vowel letters.
Live Demo
public class FindingConsonants {
   public static void main(String args[]) {
      String str = new String("Hi Welcome to Tutorialspoint");
      for(int i=0; i<str.length(); i++) {
      
      if(str.charAt(i) == 'a'|| str.charAt(i) == 'e'|| str.charAt(i) == 'i' ||
         str.charAt(i) == 'o' || str.charAt(i) == 'u'|| str.charAt(i) == ' ') {
         } else {
            System.out.println("Given string contains "+str.charAt(i)+" at the index "+i);
         }
      }
   }
}
Given string contains i at the index 1
Given string contains e at the index 4
Given string contains o at the index 7
Given string contains e at the index 9
Given string contains o at the index 12
Given string contains u at the index 15
Given string contains o at the index 17
Given string contains i at the index 19
Given string contains a at the index 20
Given string contains o at the index 24
Given string contains i at the index 25
Python File readlines() Method

Python file method readlines() reads until EOF using readline() and returns a list containing the lines. If the optional sizehint argument is present, instead of reading up to EOF, whole lines totalling approximately sizehint bytes (possibly after rounding up to an internal buffer size) are read.
An empty string is returned only when EOF is encountered immediately.
Following is the syntax for readlines() method −
fileObject.readlines( sizehint );

sizehint − This is the number of bytes to be read from the file.
sizehint − This is the number of bytes to be read from the file.
This method returns a list containing the lines.
The following example shows the usage of readlines() method.
This is 1st line
This is 2nd line
This is 3rd line
This is 4th line
This is 5th line

#!/usr/bin/python

# Open a file
fo = open("foo.txt", "rw+")
print "Name of the file: ", fo.name

# Assuming file has following 5 lines
# This is 1st line
# This is 2nd line
# This is 3rd line
# This is 4th line
# This is 5th line

line = fo.readlines()
print "Read Line: %s" % (line)

line = fo.readlines(2)
print "Read Line: %s" % (line)

# Close opend file
fo.close()
When we run above program, it produces following result −
Name of the file:  foo.txt
Read Line: ['This is 1st line\n', 'This is 2nd line\n', 'This is 3rd line\n', 'This is 4th line\n', 'This is 5th line']
Read Line: []


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to add copyright symbol to your HTML document ? - GeeksforGeeks

06 Aug, 2021
Various symbols, including technical, mathematical, and currency symbols aren’t found on a normal keyboard.
There are three ways to add such symbols to an HTML document
Using HEX CodeUsing HTML CodeUsing HTML Entity
Using HEX Code
Using HTML Code
Using HTML Entity
In this article we will illustrate how to add the copyright © symbol.
1. Using HEX Code: The HEX code for the copyright symbol is “©“.
HTML
<!DOCTYPE html><html>  <head>    <title>Add copyright symbol</title></head>  <body>    <h2>Welcome To GFG</h2>    <p>© Copyright, GFG</p></body>  </html>
 
Output:
2. Using HTML Code:The HTML code for the copyright symbol is “©“.
HTML
<!DOCTYPE html><html>  <head>    <title>Add copyright symbol</title></head>  <body>    <h2>Welcome To GFG</h2>    <p>© Copyright, GFG</p></body>  </html>
Output:
3. Using HTML Entity: The HTML entity for the copyright symbol is “©“.
HTML
<!DOCTYPE html><html>  <head>    <title>Add copyright symbol</title></head>  <body>    <h2>Welcome To GFG</h2>    <p>© Copyright, GFG</p></body>  </html>
Output:
Other symbols can also be added similarly, using their respective codes.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Questions
HTML5
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Form validation using jQuery
How to place text on image using HTML and CSS?
How to auto-resize an image to fit a div container using CSS?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
What is the C++ equivalent of sprintf?

The sprint() function is present inside the C and C++ also. This function is used to store something inside a string. The syntax is like the printf() function, the only difference is, we have to specify the string into it.
In C++ also, we can do the same by using ostringstream. This ostringstream is basically the output string stream. This is present in the sstrem header file. Let us see how to use this.
#include<iostream>
#include<sstream>
using namespace std;
int main() {
   string my_str;
   ostringstream os;
   os << "This is a string. We will store " << 50 << " in it. We can store " << 52.32 << " also.";
   my_str = os.str(); //now convert stream to my_str string
   cout << my_str;
}
This is a string. We will store 50 in it. We can store 52.32 also.
How to convert milliseconds to date format in Android using Kotlin?

This example demonstrates how to convert milliseconds to date format in Android using Kotlin.
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"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   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:layout_centerHorizontal="true"
      android:layout_marginTop="70dp"
      android:background="#008080"
      android:padding="5dp"
      android:text="TutorialsPoint"
      android:textColor="#fff"
      android:textSize="24sp"
      android:textStyle="bold" />
   <TextView
      android:id="@+id/textView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerInParent="true"
      android:textColor="@android:color/holo_orange_dark"
      android:textSize="24sp"
      android:textStyle="bold" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.kt
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import java.text.SimpleDateFormat
class MainActivity : AppCompatActivity() {
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinApp"
      val textView: TextView = findViewById(R.id.textView)
      val simpleDateFormat = SimpleDateFormat("dd/MM/yyyy")
      val dateString = simpleDateFormat.format(9897546853323L)
      textView.text = String.format("Date: %s", dateString)
   }
}
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="com.example.q11">
   <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">
         <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 the Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen