code-rag-bench/online-tutorials huggingface dataset:
jQuery | disable/enable an input element

28 Mar, 2019
The disable/enable an input element in jQuery can be done by using prop() method. The prop() method is used to set or return properties and values for the selected elements.
Example 1: This example uses prop() method to disable the input text field.
<!DOCTYPE html>  <html>    <head>     <title>         JavaScript enable/disable        an input element    </title>          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script></head>           <body style = "text-align:center;">        <h1 style = "color:green;" >          GeeksForGeeks      </h1>                    <input id = "input" type="text" name="input"/>               <button onclick="enable_disable()">         Enable/Disable    </button>               <!-- Script to disable input text area -->    <script>         function enable_disable() {            $("input").prop('disabled', true);        }    </script> </body>    </html>
Output:
Before clicking the button:
After clicking the button:
Example 2: This example uses prop() method to enable the input text field.
<!DOCTYPE html>  <html>    <head>     <title>         JavaScript enable/disable        an input element    </title>          <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script></head>           <body style = "text-align:center;">        <h1 style = "color:green;" >          GeeksForGeeks      </h1>           <input id = "input" type="text" name="input" disabled/>           <button onclick="enable_disable()">         Enable/Disable    </button>           <!-- Script to enable input text fields -->           <script>         function enable_disable() {            $("input").prop('disabled', false);        }    </script> </body>    </html>
Output:
Before clicking the button:
After clicking the button:
JQuery
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Overriding the save method – Django Models

09 Jul, 2021
The save method is an inherited method from models.Model which is executed to save an instance into a particular Model. Whenever one tries to create an instance of a model either from admin interface or django shell, save() function is run. We can override save function before storing the data in the database to apply some constraint or fill some ready only fields like SlugField. Technically it is not recommended to override the save method to implement such functionalities because any error in save method lets to crash of whole database. So either if you are perfect at writing save method and error handling or don’t try save method and try to implement these functionalities either in forms, views, models, etc. 
Illustration of overriding the save method using an Example. Consider a project named geeksforgeeks having an app named geeks.  
Refer to the following articles to check how to create a project and an app in Django.  
How to Create a Basic Project using MVT in Django?
How to Create an App in Django ?
Enter the following code into models.py file of geeks app. We will be using CharField for experimenting for all field options. We will override the save method to fill up the SlugField automatically.  
Python3
from django.db import models # importing slugify from djangofrom django.utils.text import slugify # Create your models here.class GeeksModel(models.Model):    title = models.CharField(max_length = 200)    slug = models.SlugField()     def save(self, *args, **kwargs):        self.slug = slugify(self.title)        super(GeeksModel, self).save(*args, **kwargs)
Let us explain what happens in above code. save() method from its parent class is to be overridden so we use super keyword. slugify is a function that converts any string into a slug. so we are converting the title to form a slug basically. Let us try to create an instance with “Gfg is the best website”.  
Let us check what we have created in admin interface.  
 
As defined in the starting of this article it is often not recommended to override the save method. Let us check why? The above code recreates the slug every time the save method is used or if any change is done to the model. The second reason is if one needs to change the title only but not slug since slug is redirecting to a particular link and is ranking on some search engine. A great issue would be created in a production server. This makes the use of this method of validation unfortunately incorrect. There can be multiple ways to solve above problem, one can declare slug as read-only field and then before making any changes to slug in overridden method we can check if it is empty. This may resolve the problem. So as recommended until you are able to handle errors in save method, don’t override it. 
sweetyty
Django-models
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Console.Read and Console.ReadLine in C#

05 Apr, 2022
In C#, to take input from the standard input device, the following method are used – Console.Read() and Console.ReadLine() method. Console is a predefined class of System namespace. While Read() and ReadLine() both are the Console Class methods.
The only difference between the Read() and ReadLine() is that Console.Read is used to read only single character from the standard output device, while Console.ReadLine is used to read a line or string from the standard output device.
Program 1: Example of Console.Read() in C#.
C#
// C# program to show the difference// between Console.Read() and// Console.ReadLine() method   using System; public class GFG{       static void Main(string[] args)    {        // use of Read() method        Console.Write(Convert.ToChar(Console.Read()));        Console.Write(Convert.ToChar(Console.Read()));        Console.Write(Convert.ToChar(Console.Read()));    }}
Input:
Geeks
Output:
Gee
Program 2: Example of Console.ReadLine() in C#.
C#
// C# program to show the difference// between Console.Read() and// Console.ReadLine() method   using System; public class GFG{       static void Main(string[] args)    {        // use of ReadLine() method        Console.Write(Console.ReadLine());        Console.Write(Console.ReadLine());        Console.Write(Console.ReadLine());    }}
Input:
Geeks
For
Geeks
Output:
GeeksForGeeks
In the above code, program 1 shows that it will read only single character and program 2 shows it will read string until new line character is not found.
Let us see the differences in Tabular Form -:
Its syntax is -:
public static int Read ();
Its syntax is -:
public static string ReadLine ();
mayank007rawa
C#
Difference Between
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2001 | Question 32

28 Jun, 2021
Consider the following problem X.
Given a Turing machine M over the input alphabet Σ, any
state q of M And a word w∈Σ*, does the computation of M
on w visit the state q? 
Which of the following statements about X is correct?(A) X is decidable(B) X is undecidable but partially decidable(C) X is undecidable and not even partially decidable(D) X is not a decision problemAnswer: (B)Explanation:This problem is a State Entry Problem. State entry problem can be reduced to halting problem.We construct a turing machine M with final state ‘q’. We run a turing machine R (for state entry problem)with inputs : M, q, w .We give ‘w’ as input to M.If M halts in the final state ‘q’ then R accepts the input. So, the given problem is partially decidable.
If M goes in an infinite loop then M can not output anything. So, R rejects the input. So, the given problem becomes undecidable. Thus, option (B) is the answer. Please comment below if you find anything wrong in the above post.Quiz of this Question
GATE-CS-2001
GATE-GATE-CS-2001
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to check whether specified values are present in NumPy array?

22 Sep, 2020
Sometimes we need to test whether certain values are present in an array. Using Numpy array, we can easily find whether specific values are present or not. For this purpose, we use the “in” operator. “in” operator is used to check whether certain element and values are present in a given sequence and hence return Boolean values ‘True” and “False“.
Example 1:
Python3
# importing Numpy packageimport numpy as np  # creating a Numpy arrayn_array = np.array([[2, 3, 0],                    [4, 1, 6]])  print("Given array:")print(n_array)  # Checking whether specific values# are present in "n_array" or notprint(2 in n_array)print(0 in n_array)print(6 in n_array)print(50 in n_array)print(10 in n_array)
Output:
Given array:
[[2 3 0]
[4 1 6]]
True
True
True
False
False

In the above example, we check whether values 2, 0, 6, 50, 10 are present in Numpy array ‘n_array‘ using the ‘in‘ operator.
Example 2: 
Python3
# importing Numpy packageimport numpy as np  # creating a Numpy arrayn_array = np.array([[2.14, 3, 0.5],                    [4.5, 1.2, 6.2],                    [20.2, 5.9, 8.8]])  print("Given array:")print(n_array)  # Checking whether specific values# are present in "n_array" or notprint(2.14 in n_array)print(5.28 in n_array)print(6.2 in n_array)print(5.9 in n_array)print(8.5 in n_array)
Output:
Given array:
[[ 2.14  3.    0.5 ]
[ 4.5   1.2   6.2 ]
[20.2   5.9   8.8 ]]
True
False
True
True
False

In the above example, we check whether values 2.14, 5.28, 6.2, 5.9, 8.5 are present in Numpy array ‘n_array‘.
Example 3:
Python3
# importing Numpy packageimport numpy as np  # creating a Numpy arrayn_array = np.array([[4, 5.5, 7, 6.9, 10],                    [7.1, 5.3, 40, 8.8, 1],                    [4.4, 9.3, 6, 2.2, 11],                    [7.1, 4, 5, 9, 10.5]])    print("Given array:")print(n_array)  # Checking whether specific values# are present in "n_array" or notprint(2.14 in n_array)print(5.28 in n_array)print(8.5 in n_array)
Output:
Given array:
[[ 4.   5.5  7.   6.9 10. ]
[ 7.1  5.3 40.   8.8  1. ]
[ 4.4  9.3  6.   2.2 11. ]
[ 7.1  4.   5.   9.  10.5]]
False
False
False

In the above example, we check whether values 2.14, 5.28, 8.5 are present in Numpy array ‘n_array‘.
Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
SSTable in Apache Cassandra

10 Jul, 2020
In this article, we are going to discuss SSTable which is one of the storage engines in Cassandra and SSTable components and also, we will cover what type of information kept in different database file in SSTable. Let’s discuss one by one.
SSTable :It is one of the storage engines in Apache Cassandra i.e storage for Immutable data file for row storage. In Cassandra, SSTable uses for persisting data on disk.
Key points :
In Apache Cassandra, as you will check how data stores then data in SSTables and SSTables are flushed to disk from Memtables or are streamed from other nodes.
In Cassandra, while inserting data the timestamp is included in every write when it was written.
In Cassandra, compaction is a concept that combines multiple SSTable into one big SSTable, and once new SSTable has been written after that old SSTables can be removed.only, the latest timestamp is kept.
Components of SSTable :In Cassandra, SSTable has multiple components that stored in multiple files as following.
Data.db –In SSTable, Data.db stores the actual data, i.e. the contents of rows.
Index.db –It is the component of SSTable in which an index from partition keys to positions in the Data.db file. It may also include an index to rows within a partition.
Summary.db –In Cassandra, SSTable component Summary.db has a sampling of (by default) every 128th entry in the Index.db file.
Filter.db –In SSTable, It is a Bloom Filter of the partition keys.
CompressionInfo.db –In SSTable, It is the component that kept the Metadata about the offsets. CompressionInfo.db kept the lengths of compression chunks in the Data.db file.
Statistics.db –It is one of the important components in SSTable which kept the statistics of data. In Cassandra, It is an SSTable component that Stores metadata about the SSTable and including information about timestamps, tombstones, clustering keys, compaction, repair, compression, Time to Live (TTL) values, and more.
Digest.crc32 –In Cassandra, this SSTable component has a CRC-32 digest of the Data.db file.
TOC.txt –In Cassandra, this SSTable component has a plain text list of the component files for the SSTable. In SSTable, Within the Data.db file, rows are organized by partition. These partitions are stored in token order such that by a hash of the partition key when Murmur3Partition chosen rows are stored in the order of their clustering keys.
Note –In Apache Cassandra, SSTables can be optionally compressed using block-based compression.
Apache
NoSQL
DBMS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to create hash from string in JavaScript ?

14 Aug, 2019
In order to create a unique hash from a specific string, it can be implemented using their own string to hash converting function. It will return the hash equivalent of a string. Also, a library named Crypto can be used to generate various types of hashes like SHA1, MD5, SHA256 and many more.
Note: The hash value of an empty string is always zero.
Example 1:
<!DOCTYPE html><html>  <head>    <title>        How to convert hash from        string in JavaScript ?    </title>          <style>        h1 {            color: green;        }    </style></head>  <body>    <center>        <h1>GeeksforGeeks</h1>          <h3>Creating hash from string in JavaScript?</h3>          <p>The hash value of string "GeeksforGeeks" is .</p>          <p id="geek"></p>          <script>                      // Convert to 32bit integer            function stringToHash(string) {                                  var hash = 0;                                  if (string.length == 0) return hash;                                  for (i = 0; i < string.length; i++) {                    char = string.charCodeAt(i);                    hash = ((hash << 5) - hash) + char;                    hash = hash & hash;                }                                  return hash;            }                          // String printing in hash            var gfg = "GeeksforGeeks"                          document.getElementById("geek").innerHTML                        = stringToHash(gfg);        </script>    </center></body>  </html>
Output:Example 2:
<script>      // Importing 'crypto' module    const crypto = require('crypto'),      // Returns the names of supported hash algorithms     // such as SHA1,MD5    hash = crypto.getHashes();      // Create hash of SHA1 type    x = "Geek"      // 'digest' is the output of hash function containing     // only hexadecimal digits    hashPwd = crypto.createHash('sha1').update(x).digest('hex');      console.log(hash); </script>
Output:
321cca8846c784b6f2d6ba628f8502a5fb0683ae
javascript-string
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
How to append HTML code to a div using JavaScript ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
File getParent() method in Java with Examples

30 Jan, 2019
The getParent() method is a part of File class. This function returns the Parent of the given file object. The function returns a string object which contains the Parent of the given file object.If the abstract path does not contain any Parent then a null string is returned.
Function Signature:
public String getParent()
Function Syntax:
file.getParent()
Parameters: This function does not accept any parameters.
Return value: The function returns a String value which is the Parent of the given File object.
Below programs will illustrate the use of the getParent() function:
Example 1: We are given a file object of a file, we have to get the Parent of the file object.
// Java program to demonstrate the// use of getParent() function  import java.io.*;  public class solution {    public static void main(String args[])    {          // try-catch block to handle exceptions        try {              // Create a file object            File f                = new File("c:\\users\\program.txt");              // Get the Parent            // of the given file f            String Parent = f.getParent();              // Display the file Parent            // of the file object            System.out.println("File Parent : "                               + Parent);        }        catch (Exception e) {            System.err.println(e.getMessage());        }    }}
Output:
File Parent : c:\users

Example 2: We are given a file object of a directory, we have to get the Parent of the file object.
// Java program to demonstrate the// use of getParent() function  import java.io.*;  public class solution {    public static void main(String args[])    {          // try-catch block to handle exceptions        try {              // Create a file object            File f                = new File("c:\\users\\program");              // Get the Parent            // of the given file f            String Parent = f.getParent();              // Display the file Parent            // of the file object            System.out.println("File Parent : "                               + Parent);        }        catch (Exception e) {            System.err.println(e.getMessage());        }    }}
Output:
File Parent : c:\users

The programs might not run in an online IDE. please use an offline IDE and set the Parent of the file
Java-File Class
Java-Functions
Java-IO package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to print N times without using loops or recursion ?

07 Jul, 2022
How to print “Hello” N times (where N is user input) without using loop or recursion or goto.
Input : N, that represent the number of times you want to print the statement. Output : Statement for N times
First, we create a class. After that, we need to initialize the constructor of the class by writing the statement you want to print inside a cout/print statement. The basic idea used here that “The no. of times you create the object of the class, the constructor of that class is called that many times.” 
CPP
// CPP program to print a sentence N times// without loop and recursion.// Author : Rohan Prasad#include <iostream>using namespace std;class Print { public:  Print()  {    cout << "Hello" << endl;  }}; int main(){  int N = 5;  Print a[N];  return 0;}
Hello
Hello
Hello
Hello
Hello
Time Complexity: O(N) Auxiliary Space: O(1), no extra space is required, so it is a constant.
manthu
jayanth_mkv
cpp-constructor
cpp-puzzle
C++
C++ Programs
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set in C++ Standard Template Library (STL)
Bitwise Operators in C/C++
Priority Queue in C++ Standard Template Library (STL)
vector erase() and clear() in C++
unordered_map in C++ STL
Const keyword in C++
Processing strings using std::istringstream
Sorting a Map by value in C++ STL
Expression must have class type error in C++
C++ Program For Merge Sort Of Linked Lists
GATE | GATE CS 2019 | Question 59

20 Feb, 2019
What is the minimum number of 2-input NOR gates required to implement 4-variable function expressed in sum-of-minterms from as f = Σ(0, 2, 5, 7, 8, 10, 13, 15)? Assume that all the inputs and their complements are available. Answer ________ .
Note: This was Numerical Type question.(A) 3(B) 4(C) 5(D) 6Answer: (A)Explanation: K-map for given,
f = Σ(0, 2, 5, 7, 8, 10, 13, 15)
Therefore,
f = BD +B'D' 
= (B' + D).(B + D')
Since all the inputs and their complements are available, so circuit implementation using NOR gate:
F can be implemented using 3 NOR gates.
So, option (A) is correct.Quiz of this Question
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE CS 2008 | Question 46
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2011 | Question 49
GATE | GATE-CS-2004 | Question 31
GATE | GATE CS 1996 | Question 63
JavaScript contextmenu MouseEvent

06 Oct, 2021
When we click the right mouse button on our desktop, a menu-like box appears and this box is called the context menu. In JavaScript, a context menu event runs when a user tries to open a context menu. This can be done by clicking the right mouse button. 
This article demonstrates executing any operation when we click the right mouse button. For example, we want to change the background color of a box when we click the right mouse button.
HTML
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8" />    <meta http-equiv="X-UA-Compatible"          content="IE=edge" />    <meta name="viewport"          content="width=device-width, initial-scale=1.0" />  </head>   <!-- Adding some CSS -->  <style>    .context {      border: 1px solid black;      background: gREEN;      width: 200px;      padding: 10px;      color: white;    }  </style>   <body>    <div class="context">       <p>Click right mouse button</p>     </div>     <!-- JavaScript code to change content when         we click right mouse button -->    <script>           // To prevent default operation of right mouse click      document.addEventListener("contextmenu", (e) => {        e.preventDefault();      });       const contextMenu = document.querySelector(".context");      contextMenu.addEventListener("contextmenu", (e) => {        e.preventDefault();        contextMenu.textContent = "GeeksForGeeks";      });    </script>  </body></html>
Output : The following output will be shown in the browser and when we click the right mouse button on the box in the above image.
Before right click:  
After right click:  
Note: Using this method we can perform a lot of things, we can add a menu on our right-click.
prachisoda1234
JavaScript-Events
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
How to Configure the Eclipse with Apache Hadoop?

25 Jan, 2021
Eclipse is an IDE(Integrated Development Environment) that helps to create and build an application as per our requirement. And Hadoop is used for storing and processing big data. And if you have requirements to configure eclipse with Hadoop then you can follow this section step by step. Here, we will discuss 8 steps in which you will see the download, installation, and configuration part of an eclipse and will see how you can configure the Hadoop while installing and configuring an eclipse.
Step 1: Download and Install Eclipse IDE
It is the most popular IDE for developing java applications. It is easy to use and powerful IDE that is the reason behind the trust of many programmers. It can be downloaded from the given link below as follows.                           
http://www.eclipse.org/downloads/eclipse-packages
You will get a file named eclipse-committers-photon-R-linux-gtk.tar.gz.
We need to extract it using the command tar –zxvf eclipse-committers-photon-R-linux-gtk.tar.gz
Step 2: Move the eclipse folder to the home directory
In this step, you can see how to move the eclipse folder to the home directory. You can check the screenshot for your reference.
Step 3: Open Eclipse
Now, in this step, you can see the eclipse icon once you will successfully download and extract it to the required folder. And double click to open. You can see the screenshot for your reference.
Step 4: Execute Eclipse
Now choose a workspace directory and then click LAUNCH.
Step 5: Download required files 
Hadoop-core-1.2.1.jar
commons-cli-1.2.jar
Step 6: Creating Java Project
Create a java project in the package explorer.  
file—>new—>java project—>finish 
right click—>new—>package—>finish 
right click on package—>new—>class_name
Step 7: Adding Reference libraries
 Now add the following reference libraries as follows. First, we need to go to build path –>configure build path –> configure build path
Step 8: Adding .jar Files
Click on add external jars and browse to the folder where the files are downloaded and click open and select these two files i.e. hadoop-core-1.2.1.jar , commons-cli-1.2.jar.
Hadoop
MapReduce
Hadoop
How To
Hadoop
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Create Table in Hive?
Apache Hive
What is Hadoop Streaming?
What is Schema On Read and Schema On Write in Hadoop?
MapReduce - Understanding With Real-Life Example
How to Install PIP on Windows ?
How to install Jupyter Notebook on Windows?
How to Install FFmpeg on Windows?
How to Find the Wi-Fi Password Using CMD in Windows?
ReactJS | State vs props

30 Jul, 2020
We know that in react components are the building blocks which can be reused again and again in building the UI. Before jumping into the main difference between the state and props, let’s see how a component in react is related to a normal function in javascript Example:  
javascript
// simple componentclass FakeComponent extends React.component{ render(){    return <div>Hello World!</div>    }}// simple javascript functionconst FakeFunction = () => console.log('Hello World!');
In the above code we declared a simple react component by extending the React.component native method and then we simply render a div which contains ‘Hello World’ inside it as text. After the function we have a simple javascript function inside it which contains a simple console.log which does the same thing inside it, printing ‘Hello World!’. So now we know that a React component works similar to a normal javascript function. Let’s take a look at state  
A state is a variable which exists inside a component, that cannot be accessed and modified outside the component and can only be used inside the component. Works very similarly to a variable that is declared inside a function that cannot be accessed outside the scope of the function in normal javascript.State Can be modified using this.setState. State can be asynchronous.Whenever this.setState is used to change the state class is rerender itself.Let’s see with the help an example: Example:  
javascript
// componentclass FakeComponent extends React.component{  state = {      name : 'Mukul';   }  render(){      return <div>Hello {this.state.name}</div>   }}// simple js functionconst FakeFunction = () => {  let name = 'Mukul';  console.log(`Hey ${name}`);}
In the above code we simply declare a name property inside a component and used it while rendering, similar is the case with a normal function in javascript. It should also be noted that the state is mutable in nature, and should not be accessed from child components.  
We know that components in React are used again and again in the UI, but we don’t normally render the same component with the same data. Sometimes we need to change the content inside a component. Props come to play in these cases, as they are passed into the component and the user. Let’s see how they work: Example:  
javascript
// componentclass FakeComponent extends React.component{ render(){    return <div>Hello {this.props.name}</div>    }}// passing the props<FakeComponent name='Mukul' /><FakeComponent name='Mayank' />
A simple component and then we passes the props as attributes and then access them inside our component using this.props. So props makes components reusable by giving components the ability to receive data from the parent component in the form of props. They are immutable. 
zack_aayush
react-js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Convert numeric words to numbers

22 Apr, 2020
Sometimes, while working with python Strings, we can have a problem in which we need to convert the strings that are in form of named numbers to actual numbers. This has application in Mathematical domains and Data Science domains. Lets discuss certain ways in which this task can be performed.
Method #1 : Using loop + join() + split()One of the ways to solve this problem is to use a map, where one can map the numeric with words and then split the strings and rejoin using mapping to numbers.
# Python3 code to demonstrate working of # Convert numeric words to numbers# Using join() + split()  help_dict = {    'one': '1',    'two': '2',    'three': '3',    'four': '4',    'five': '5',    'six': '6',    'seven': '7',    'eight': '8',    'nine': '9',    'zero' : '0'}  # initializing stringtest_str = "zero four zero one"  # printing original stringprint("The original string is : " + test_str)  # Convert numeric words to numbers# Using join() + split()res = ''.join(help_dict[ele] for ele in test_str.split())  # printing result print("The string after performing replace : " + res) 
The original string is : zero four zero one
The string after performing replace : 0401

 
Method #2 : Using word2number libraryThis problem can also be solved using PyPI library word2number. It has inbuilt functions that converts words to numbers.
# Python3 code to demonstrate working of # Convert numeric words to numbers# Using word2numberfrom word2number import w2n  # initializing stringtest_str = "zero four zero one"  # printing original stringprint("The original string is : " + test_str)  # Convert numeric words to numbers# Using word2numberres = w2n.word_to_num(test_str)  # printing result print("The string after performing replace : " + str(res)) 
The original string is : zero four zero one
The string after performing replace : 0401

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterate over a list in Python
Rotate axis tick labels in Seaborn and Matplotlib
Enumerate() in Python
Deque in Python
Stack in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Iterate over characters of a string in Python
Python | Convert set into a list
Python program to convert a list to string
How to check if value exists with MySQL SELECT 1?

Use SELECT 1 for this as in the below syntax −
select 1 from yourTableName where yourColumnName=yourValue;
If the above returns 1, that means value exists in the MySQL database. Let us first see an example and create a table −
mysql> create table DemoTable
(
   StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   StudentName varchar(40),
   StudentAge int
);
Query OK, 0 rows affected (0.46 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable(StudentName,StudentAge) values('Chris',21);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable(StudentName,StudentAge) values('David',20);
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable(StudentName,StudentAge) values('Bob',22);
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable(StudentName,StudentAge) values('Tom',19);
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+-------------+------------+
| StudentId | StudentName | StudentAge |
+-----------+-------------+------------+
|        1 | Chris        |         21 |
|        2 | David        |         20 |
|        3 | Bob          |         22 |
|        4 | Tom          |         19 |
+-----------+-------------+------------+
4 rows in set (0.00 sec)
Let us now check if value exists in MySQL database −
mysql> select 1 from DemoTable where StudentName='Bob';
This will produce the following output −
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
What is the difference between a string and a byte string in Python?

A string is a sequence of characters; these are an abstract concept, and can't be directly stored on disk. A byte string is a sequence of bytes - things that can be stored on disk. The mapping between them is an encoding - there are quite a lot of these (and infinitely many are possible) - and you need to know which applies in the particular case in order to do the conversion, since a different encoding may map the same bytes to a different string. For example, the same byte string can represent 2 different strings in 2 different encodings.
>>> b'\xcf\x84o\xcf\x81\xce\xbdo\xcf\x82'.decode('utf-16')
'蓏콯캁澽苏'
>>> b'\xcf\x84o\xcf\x81\xce\xbdo\xcf\x82'.decode('utf-8')
'τoρνoς'
Once you know which encoding to use, you can use the .decode() method of the byte string to get the right character string from it. The .encode() method of a character string goes the opposite way and encodes the character string as a byte string.
PostgreSQL - SUM Function

PostgreSQL SUM function is used to find out the sum of a field in various records.
To understand the SUM function consider the table COMPANY having records as follows −
testdb# select * from COMPANY;
 id | name  | age | address   | salary
----+-------+-----+-----------+--------
  1 | Paul  |  32 | California|  20000
  2 | Allen |  25 | Texas     |  15000
  3 | Teddy |  23 | Norway    |  20000
  4 | Mark  |  25 | Rich-Mond |  65000
  5 | David |  27 | Texas     |  85000
  6 | Kim   |  22 | South-Hall|  45000
  7 | James |  24 | Houston   |  10000
(7 rows)
Now, based on the above table, suppose you want to calculate the total of all the salary, then you can do so by using the following command −
testdb# SELECT SUM(salary) FROM company;
The above given PostgreSQL statement will produce the following result −
  sum
--------
 260000
(1 row)

You can take the sum of various records set using the GROUP BY clause. The following example will sum up all the records related to a single person and you will have salary for each person.
testdb# SELECT name, SUM(salary) FROM company GROUP BY name;
The above given PostgreSQL statement will produce the following result −
 name  |  sum
-------+-------
 Teddy | 20000
 Paul  | 20000
 Mark  | 65000
 David | 85000
 Allen | 15000
 Kim   | 45000
 James | 10000
(7 rows)


    23 Lectures 
     1.5 hours 

 John Elder

    49 Lectures 
     3.5 hours 

 Niyazi Erdogan

    126 Lectures 
     10.5 hours 

 Abhishek And Pukhraj

    35 Lectures 
     5 hours 

 Karthikeya T

    5 Lectures 
     51 mins

 Vinay Kumar

    5 Lectures 
     52 mins

 Vinay Kumar
 Print
 Add Notes
 Bookmark this page
Python program to find all duplicate characters in a string

In this tutorial, we are going to learn how to find all duplicate values in a string. We can do it in different ways in Python. Let's explore them one by one.
The aim of the program we are going to write is to find the duplicate characters present in a string. For example, we have a string tutorialspoint the program will give us t o i as output. In simple words, we have to find characters whose count is greater than one in the string. Let's see.
Writing programs without using any modules. We can use different methods of Python to achieve our goal. First, we will find the duplicate characters of a string using the count method. Let's see the procedure first.
Initialize a string.
Initialize an empty list
Loop over the string.Check whether the char frequency is greater than one or not using the count method.
Check whether the char frequency is greater than one or not using the count method.
If greater than one check whether it's present in the list or not.
If not present append to the list
Print the characters
## initializing string
string = "tutorialspoint"
## initializing a list to append all the duplicate characters
duplicates = []
for char in string:
   ## checking whether the character have a duplicate or not
   ## str.count(char) returns the frequency of a char in the str
   if string.count(char) > 1:
   ## appending to the list if it's already not present
   if char not in duplicates:
   duplicates.append(char)
print(*duplicates)
If you run the above program, you will get the following results.
t o i
Now we will find the duplicate characters of string without any methods. We are going to use the dictionary data structure to get the desired output. Let's see the procedure first.
Initialize a string.
Initialize an empty dictionary
Loop over the string.Check whether the char is already present in the dictionary or notInitialize the count of the char to 1
Check whether the char is already present in the dictionary or not
Initialize the count of the char to 1
Increase the count
## initializing string
string = "tutorialspoint"
## initializing a dictionary
duplicates = {}
for char in string:
   ## checking whether the char is already present in dictionary or not
   if char in duplicates:
      ## increasing count if present
      duplicates[char] += 1
   else:
      ## initializing count to 1 if not present
      duplicates[char] = 1
for key, value in duplicates.items():
   if value > 1:
      print(key, end = " ")
print()
If you run the above program,
t o i
VBA - Constants

Constant is a named memory location used to hold a value that CANNOT be changed during the script execution. If a user tries to change a Constant value, the script execution ends up with an error. Constants are declared the same way the variables are declared.
Following are the rules for naming a constant.
You must use a letter as the first character.
You must use a letter as the first character.
You can't use a space, period (.), exclamation mark (!), or the characters @, &, $, # in the name.
You can't use a space, period (.), exclamation mark (!), or the characters @, &, $, # in the name.
Name can't exceed 255 characters in length.
Name can't exceed 255 characters in length.
You cannot use Visual Basic reserved keywords as variable name.
You cannot use Visual Basic reserved keywords as variable name.
In VBA, we need to assign a value to the declared Constants. An error is thrown, if we try to change the value of the constant.
Const <<constant_name>> As <<constant_type>> = <<constant_value>>

Let us create a button "Constant_demo" to demonstrate how to work with constants.
Private Sub Constant_demo_Click() 
   Const MyInteger As Integer = 42 
   Const myDate As Date = #2/2/2020# 
   Const myDay As String = "Sunday" 
   
   MsgBox "Integer is " & MyInteger & Chr(10) & "myDate is " 
      & myDate & Chr(10) & "myDay is " & myDay  
End Sub
Upon executing the script, the output will be displayed as shown in the following screenshot.

    101 Lectures 
     6 hours 

 Pavan Lalwani

    41 Lectures 
     3 hours 

 Arnold Higuit

    80 Lectures 
     5.5 hours 

 Prashant Panchal

    25 Lectures 
     2 hours 

 Prashant Panchal

    26 Lectures 
     2 hours 

 Arnold Higuit

    92 Lectures 
     10.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
Get list of column headers from a Pandas DataFrame - GeeksforGeeks

17 Aug, 2020
Let us see how to get all the column headers of a Pandas DataFrame as a list. The df.columns.values attribute will return a list of column headers.
Example 1 :
# importing pandas as pdimport pandas as pd  # creating the dataframedf = pd.DataFrame({'PassengerId': [892, 893, 894, 895,                                    896, 897, 898, 899],                   'PassengerClass': [1, 1, 2, 1, 3, 3, 2, 2],                   'PassengerName': ['John', 'Prity', 'Harry',                                      'Smith', 'James', 'Amora',                                      'Kiara', 'Joseph'],                    'Age': [32, 54, 71, 21, 37, 9, 11, 54]})  display("The DataFrame :")display(df)  # print the list of all the column headersdisplay("The column headers :")display(list(df.columns.values))
Output :
Example 2 :
# importing pandas as pdimport pandas as pd  # creating the dataframemy_df = {'Students': ['A', 'B', 'C', 'D'],          'BMI': [22.7, 18.0, 21.4, 24.1],          'Religion': ['Hindu', 'Islam',                       'Christian', 'Sikh']}df = pd.DataFrame(my_df)display("The DataFrame :")display(df)  # print the list of all the column headersdisplay("The column headers :")display(list(df.columns.values))
Output :
pandas-dataframe-program
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Python String | replace()
sum() function in Python
Python | Get unique values from a list
Python string length | len()
*args and **kwargs in Python
Check if element exists in list in Python
How do we set the Java environment variable in cmd.exe?

When you install Java in your system first of all you need to set the environment variables which are path and class path.
PATH− The path environment variable is used to specify the set of directories which contains executional programs.When you try to execute a program from command line, the operating system searches for the specified program in the current directly, if available, executes it.In case the programs are not available in the current directory, operating system verifies in the set of directories specified in the ‘PATH’ environment variable.You need to set path for compiler (javac.exe) and JVM(java.exe),which exists in the bin folder of the JDK.
PATH− The path environment variable is used to specify the set of directories which contains executional programs.
When you try to execute a program from command line, the operating system searches for the specified program in the current directly, if available, executes it.
In case the programs are not available in the current directory, operating system verifies in the set of directories specified in the ‘PATH’ environment variable.
You need to set path for compiler (javac.exe) and JVM(java.exe),which exists in the bin folder of the JDK.
CLASSPATH − The class path environment variable is used to specify the location of the classes and packages.When we try to import classes and packages other that those that are available with Java Standard Library.JVM verifies the current directly for them, if not available it verifies the set of directories specified in the ‘CLASSPATH’ environment variable.The rt.jar file in the lib folder of JRE contains all the basic packages for Java therefore, you need to set classpath for this folder.
CLASSPATH − The class path environment variable is used to specify the location of the classes and packages.
When we try to import classes and packages other that those that are available with Java Standard Library.
JVM verifies the current directly for them, if not available it verifies the set of directories specified in the ‘CLASSPATH’ environment variable.
The rt.jar file in the lib folder of JRE contains all the basic packages for Java therefore, you need to set classpath for this folder.
To set path −
Open command prompt.
Copy the location of the javac and java commands i.e. bin folder of JDK example: C:\Program Files\Java\jdk1.8.0_101\bin
Using the SET command set the path variable in the command prompt as −
SET PATH=C:\Program Files\Java\jdk_version\bin
To set classpath −
Open command prompt.
Copy the location of the rt.jar file i.e. lib folder of JDK example: C:\Program Files\Java\jdk1.8.0_101\lib
Using the SET command set the classpath variable in the command prompt as −
SET CLASSPATH= C:\Program Files\Java\jdk1.8.0_101\lib
IDE | GeeksforGeeks | A computer science portal for geeks

Please enter your email address or userHandle.
12345678910111213141516171819202122232425262728293031323334353637https://c.mi.com/thread-3967156-1-1.html https://forums.ubisoft.com/showthread.php/2371427-44-Free-Cookie-Run-Cookies-Generator-2022iwd?p=15523073#post15523073https://cash-app-free-gift-card-code.tumblr.comhttps://garena-free-fire-diamonds-2022.tumblr.comhttps://dragon-ball-crystals-2022.tumblr.comhttps://free-coc-gems-generator-2022.tumblr.comhttps://coin-master-free-spins-generator.tumblr.comhttps://google-play-gift-card-codes.tumblr.comhttps://cash-app-free-money-generator.tumblr.comhttps://fifa-22-free-coins-generator.tumblr.comhttps://mobile-legends-free-diamonds.tumblr.comhttps://among-us-free-pets-skins.tumblr.comhttps://among-us-pets-skins-hats-2022.tumblr.comhttps://forums.ubisoft.com/showthread.php/2371430-IUuy3f3009f98ue0e-wfe4wfff4?p=15523076#post15523076http://zacriley.ning.com/photo/albums/wfdewfoiewfwef-we4fr4rf445t5thttps://paiza.io/projects/fylW-6np9rBzhtLSaRlrYg?language=phphttps://jsfiddle.net/a2ebu819/https://notes.io/ABDihttps://onecompiler.com/java/3xq29geuahttps://paste2.org/ykVtXAwehttps://pasteio.com/xVXvgREx400xhttps://ideone.com/PZrZpwhttps://authors.curseforge.com/paste/bc9967f1https://paste.feed-the-beast.com/view/6989eb88http://cpp.sh/7cjoahttps://brainly.co.id/tugas/47544095https://pasteall.org/Lktnhttps://ide.geeksforgeeks.org/pbSMl0qoXkhttps://pastebin.com/https://paste.centos.org/view/ac106b53https://paste.in/mNdSuFhttps://ctxt.io/2/AABgqeCsFAhttps://wow.curseforge.com/paste/932882fbhttp://paste.jp/c24e28f0/https://paste.ofcode.org/FWYYPpDUAHGMv5Q8yAzBYBhttps://www.onfeetnation.com/profiles/blogs/efe0ofier9gf9ekr-vgfer4gt54rhttps://www.mydigoo.com/forums-topicdetail-393715.htmlההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
https://ide.geeksforgeeks.org/qIQMPK9mJd
prog.c:1:6: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before â:â token