code-rag-bench/online-tutorials huggingface dataset:
How to Read and Print an Integer value in C++

09 May, 2022
The given task is to take an integer as input from the user and print that integer in C++ language.  In below program, the syntax and procedures to take the integer as input from the user is shown in C++ language. 
Steps:
The user enters an integer value when asked.
This value is taken from the user with the help of cin method. The cin method, in C++, reads the value from the console into the specified variable. 
Syntax:
cin >> variableOfXType;

where >> is the extraction operator
and is used along with the object cin
for reading inputs. The extraction operator 
extracts the data from the object cin
which is entered using the keyboard.
For an integer value, the X is replaced with type int. The syntax of cin method becomes as follows then: 
Syntax:
cin >> variableOfIntType;
This entered value is now stored in the variableOfIntType.
Now to print this value, cout method is used. The cout method, in C++, prints the value passed as the parameter to it, on the console screen. 
Syntax:
cout << variableOfXType;

where << is the insertion operator.
The data needed to be displayed on the screen 
is inserted in the standard output stream (cout)
using the insertion operator (<<).
For an integer value, the X is replaced with type int. The syntax of cout() method becomes as follows then: 
Syntax:
cout << variableOfIntType;
Hence, the integer value is successfully read and printed.
Program: 
C++
// C++ program to take an integer// as input and print it #include <iostream>using namespace std; int main(){     // Declare the variables    int num;     // Input the integer    cout << "Enter the integer: ";    cin >> num;     // Display the integer    cout << "Entered integer is: " << num;     return 0;}
Output:
Enter the integer: 10
Entered integer is: 10
sweetyty
CPP-Basics
C++
School Programming
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
move_to_element_with_offset method – Action Chains in Selenium Python

15 May, 2020
Selenium’s Python Module is built to perform automated testing with Python. ActionChains are a way to automate low-level interactions such as mouse movements, mouse button actions, keypress, and context menu interactions. This is useful for doing more complex actions like hover over and drag and drop. Action chain methods are used by advanced scripts where we need to drag an element, click an element, double click, etc.This article revolves around move_to_element_with_offset method on Action Chains in Python Selenium. move_to_element_with_offset method is used to move the mouse by an offset of the specified element. Offsets are relative to the top-left corner of the element.Syntax –
move_to_element_with_offset(to_element, xoffset, yoffset)
to_element: The WebElement to move to.
xoffset: X offset to move to.
yoffset: Y offset to move to.
Example –
<input type ="text" name ="passwd" id ="passwd-id" />
To find an element one needs to use one of the locating strategies, For example,
element = driver.find_element_by_id("passwd-id")element = driver.find_element_by_name("passwd")
Now one can use move_to_element_with_offset method as an Action chain as below –
move_to_element_with_offset(to_element=element, 100, 200)

To demonstrate, move_to_element_with_offset method of Action Chains in Selenium Python. Let’ s visit https://www.geeksforgeeks.org/ and operate on an element.
Program –
# import webdriverfrom selenium import webdriver  # import Action chains from selenium.webdriver.common.action_chains import ActionChains  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # get  element element = driver.find_element_by_link_text("Courses")  # create action chain objectaction = ActionChains(driver)  # perform the operationaction.move_to_element_with_offset(element, 100, 200).click().perform()
Output –
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Data Lake and Data Warehouse

09 Feb, 2022
1. Data Lake : It is the concept where all sorts of data can be landed at a low cost but exceedingly adaptable storage/zone.to be examined afterward for potential insights. It is another advancement of what ETL/DWH pros called the Landing Zone of data. Only presently we are looking at ALL sorts of information .independent of construction, structure, metadata, etc. One of the thoughts behind Data Lake is that presently innovation has made it conceivable to store ALL information that a firm generates/buys (prior it would be a case where the firm HAD to select the pertinent information and store in a structured distribution center.). 
2. Data Warehouse : It is essentially a social database facilitated on cloud or an endeavor centralized computer server. It collects information from shifted, heterogeneous sources for the most reason for supporting the investigation and choice-making preparation of administration of any business. A data warehouse is characterized as Subject-oriented, coordinates, time-variant, and non-unstable collection of information in arrange to supply business insights and help within the choice-making process. 
Difference between Data Lake and Data Warehouse 
ashushrma378
varshagumber28
Picked
DBMS
Difference Between
GBlog
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to play a custom ringtone/alarm sound in Android?

This example demonstrates about How to play a custom ringtone/alarm sound in Android
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<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">
   <Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerInParent="true"
      android:gravity="center"
      android:onClick="playRingtone"
      android:text="Play Ringtone" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
package app.com.sample;
import androidx.appcompat.app.AppCompatActivity;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
   public void playRingtone(View view) {
      try {
         Uri path = Uri.parse("android.resource://" + getPackageName() + "/raw/ringtone.mp3");
         RingtoneManager.setActualDefaultRingtoneUri(
            getApplicationContext(), RingtoneManager.TYPE_RINGTONE, path
         );
         Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), path);
         r.play();
      } catch (Exception e) {
         e.printStackTrace();
      }
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Click here to download the project code.
ES6 - Array Method concat()

concat() method returns a new array comprised of this array joined with two or more arrays.
array.concat(value1, value2, ..., valueN);

valueN − Arrays and/or values to concatenate to the resulting array.
valueN − Arrays and/or values to concatenate to the resulting array.
Returns a new array.
var alpha = ["a", "b", "c"]; 
var numeric = [1, 2, 3];
var alphaNumeric = alpha.concat(numeric); 
console.log("alphaNumeric : " + alphaNumeric ); 
alphaNumeric : a,b,c,1,2,3


    32 Lectures 
     3.5 hours 

 Sharad Kumar

    40 Lectures 
     5 hours 

 Richa Maheshwari

    16 Lectures 
     1 hours 

 Anadi Sharma

    50 Lectures 
     6.5 hours 

 Gowthami Swarna

    14 Lectures 
     1 hours 

 Deepti Trivedi

    31 Lectures 
     1.5 hours 

 Shweta
 Print
 Add Notes
 Bookmark this page
How do you force MySQL LIKE to be case sensitive?

To force MySQL LIKE to be case sensitive with the help of LIKE BINARY, the following is the syntax −
select yourColumnName like binary 'anyStringValue' from yourTableName;
To understand the above concept, let us create a table. The following is the query to create a table −
mysql> create table LikeBinaryDemo
   −> (
   −> Name varchar(200)
   −> );
Query OK, 0 rows affected (0.58 sec)
Now you can insert records with small letters to force the MySQL LIKE to be case sensitive −
mysql> insert into LikeBinaryDemo values('john');
Query OK, 1 row affected (0.12 sec)
Display the records in the table. The query is as follows −
mysql> select *from LikeBinaryDemo;
The following is the output −
+------+
| Name |
+------+
| john |
+------+
1 row in set (0.00 sec)
Now you can use LIKE BINARY to force the MySQL Like to be case sensitive.
LIKE BINARY. In this case, we will get value 0 when we compare ‘john’ with ‘JOHN’. The query is as follows −
mysql> select Name like binary 'JOHN' from LikeBinaryDemo;
The following is the output −
+-------------------------+
| Name like binary 'JOHN' |
+-------------------------+
|                       0 |
+-------------------------+
1 row in set (0.00 sec)
Now let us see what will happen when we are not using BINARY. The query is as follows −
mysql> select Name like 'JOHN' from LikeBinaryDemo;
The following is the output −
+------------------+
| Name like 'JOHN' |
+------------------+
| 1 |
+------------------+
1 row in set (0.00 sec)
You can use LIKE BINARY to force MySQL to be case sensitive.
Convert.ToInt64 Method in C#

Convert a specified value to a 64-bit signed integer using Convert.ToInt64 Method.
Let us take a double value.
double doubleNum = 193.834;
Now, convert it to Int64 i.e. long.
long res;
res = Convert.ToInt32(doubleNum);
 Live Demo
using System;
public class Demo {
   public static void Main() {
      double doubleNum = 193.834;
      long res;
      res = Convert.ToInt32(doubleNum);
      Console.WriteLine("Converted {0} to {1}", doubleNum, res);
   }
}
Converted 193.834 to 194
How to assign the result of a MySQL query into a variable?

Use @anyVariableName to assign the result of a query into a variable. Let us first create a table −
mysql> create table DemoTable1864
     (
     Id int,
     FirstName varchar(20),
     LastName varchar(20)
     );
Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1864 values(101,'Chris','Brown');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1864 values(102,'David','Miller');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1864 values(103,'Adam','Smith');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1864 values(104,'John','Doe');
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from  DemoTable1864;
This will produce the following output −
+------+-----------+----------+
| Id   | FirstName | LastName |
+------+-----------+----------+
|  101 | Chris     |    Brown |
|  102 | David     |   Miller |
|  103 | Adam      |    Smith |
|  104 | John      |      Doe |
+------+-----------+----------+
4 rows in set (0.00 sec)
Here is the query to assign the result of a query into a variable −
mysql> select @fName:=FirstName,@lName:=LastName
     from DemoTable1864
     where Id=103;
This will produce the following output −
+-------------------+------------------+
| @fName:=FirstName | @lName:=LastName |
+-------------------+------------------+
| Adam              |            Smith |
+-------------------+------------------+
1 row in set (0.00 sec)
How to check whether a number is prime or not using Python?

Principle used in following solution to this problem is to divide given number with all from 3 its square root, a number's square root is largest possible factor beyond which it is not necessary to check if it is divisible by any other number to decide that it is prime number.
The function returns false for all numbers divisible by 2 and less than 2. For others return value of all) function will be false if it is divisible by any number upto its square root and true if it is not divisible by any number
def is_prime(a):
    if a < 2:
        return False
    elif a!=2 and a % 2 == 0:
        return False
    else:
        return all (a % i for i in range(3, int(a**0.5)+1) )
num=int(input('enter a number'))
if is_prime(num)==True:
    print ("{} is a prime number".format(num))
else:
    print ("{} is not a prime number".format(num))
Sample run of above program −
enter a number24
24 is not a prime number
enter a number47
47 is a prime number
How to declare and initialize a dictionary in C#?

Dictionary is a collection of keys and values in C#. Dictionary is included in the System.Collection.Generics namespace.
To declare and initialize a Dictionary −
IDictionary d = new Dictionary();
Above, types of key and value are set while declaring a dictionary object. An int is a type of key and string is a type of value. Both will get stored in a dictionary object named d.
Let us now see an example −
 Live Demo
using System;
using System.Collections.Generic;

public class Demo {
   public static void Main() {
      IDictionary<int, int> d = new Dictionary<int, int>();
      d.Add(1,97);
      d.Add(2,89);
      d.Add(3,77);
      d.Add(4,88);

      // Dictionary elements
      Console.WriteLine("Dictionary elements: "+d.Count);
   }
}
Dictionary elements: 4
What is a parameterized constructor in C# programs?

In a constructor you can also add parameters. Such constructors are called parameterized constructors. This technique helps you to assign initial value to an object at the time of its creation.
The following is an example −
// class
class Demo
Parameterized constructor with a prarameter rank −
public Demo(int rank) {
Console.WriteLine("RANK = {0}", rank);
}
Here is the complete example displaying how to work with parameterized constructor in C# −
 Live Demo
using System;

namespace Demo {
   class Line {
      private double length; // Length of a line
     
      public Line(double len) { //Parameterized constructor
         Console.WriteLine("Object is being created, length = {0}", len);
         length = len;
      }

      public void setLength( double len ) {
         length = len;
      }

      public double getLength() {
         return length;
      }

      static void Main(string[] args) {
         Line line = new Line(10.0);
         Console.WriteLine("Length of line : {0}", line.getLength());

         // set line length
         line.setLength(6.0);
         Console.WriteLine("Length of line : {0}", line.getLength());
         Console.ReadKey();
      }
   }
}
Object is being created, length = 10
Length of line : 10
Length of line : 6
Mensuration 3D- Hollow sphere

12 Jun, 2020
In this article we shall calculate the volume, Curved surface area (CSA) and Total surface area of a hollow sphere or a spherical shell. Below shown is a diagram of a hollow sphere.
As we can see in the figure, the outer radius of hollow sphere is ‘R’ and the inner radius is ‘r’.
Volume of hollow sphere :Volume of a 3D figure is defined as the capacity of the figure or the amount of the content it can hold. The volume of hollow sphere is equal to the volume of inner sphere subtracted from the volume of the outer sphere. It can be calculated as –
We know that volume of sphere,
= 4/3 πR3 
Thus volume of hollow sphere= volume of outer sphere- volume of inner sphere
= 4/3 πR3-4/3 πr3
= 4/3 π(R3-r3) 
Curved surface area (CSA) :The Curved surface area of hollow sphere is the area of the paper that can completely cover the surface of the hollow sphere. It is equal to the CSA of inner sphere subtracted from the CSA of outer sphere.
CSA of hollow sphere,
= CSA of outer sphere - CSA of inner sphere
= 4 πR2 - 4 πr2
= 4 π(R2-r2) 
Total surface area of hollow sphere :The total surface area of a hollow sphere is equal to the CSA of hollow sphere as a hollow sphere has only one surface that constitutes it.Thus CSA=TSA for a hollow sphere
Example-1:Calculate the volume and TSA of hollow sphere with outer and inner radii 5cm and 3cm respectively.
Explanation :
Given outer radius = R = 5cm
Inner radius = r = 3cm

Volume = 4/3 π(R3-r3)
= 4/3*3.14*(125-27)
= 410.29 cm3

TSA = 4 π(R2-r2) = 4*3.14*(25-9)
= 200.96 cm2 
Example-2:Water is being poured into hollow sphere of outer radius 10 cm and inner radius 5 cm at the rate of 10 cm3/s. Calculate the time required to fill the hollow sphere.
Explanation :
Outer radius = R = 10 cm
Inner radius = r = 5 cm

Volume of hollow sphere = 4/3*3.14*(1000-125)
= 3500 cm3

Rate at which water is being poured = 10 cm3/s
Time required = Volume of sphere/Rate of pouring water
= 3500/10 = 350 s 
Aptitude
placement
Engineering Mathematics
Placements
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Propositional Logic and Predicate Logic
Activation Functions
Logic Notations in LaTeX
Modular Arithmetic
Mathematics | Introduction of Set theory
SDE SHEET - A Complete Guide for SDE Preparation
Must Do Coding Questions Company-wise
Numbers
TCS Placement Paper | MCQ 1
Top 20 Puzzles Commonly Asked During SDE Interviews
Python | Sort given list of strings by part of string

11 May, 2020
Given a list of string, the task is to sort the list by part of the string which is separated by some character. In this scenario, we are considering the string to be separated by space, which means it has to be sorted by second part of each string.
Given below are a few methods to solve the given task.
Method #1: Using sort
# Python code to demonstrate to sort list # containing string by part of string  # Initialising listini_list = ["GeeksForGeeks abc", "manjeet xab", "akshat bac"]  # printing initial listprint ("initial list", str(ini_list))  # code to sort listini_list.sort(key = lambda x: x.split()[1])      # printing resultprint ("result", str(ini_list))
initial list ['GeeksForGeeks abc', 'manjeet xab', 'akshat bac']
result ['GeeksForGeeks abc', 'akshat bac', 'manjeet xab']

 Method #2: Using sorted
# Python code to demonstrate to sort list # containing string by part of string  # Initialising listini_list = ["GeeksForGeeks abc", "manjeet xab", "akshat bac"]  # printing initial listprint ("initial list", str(ini_list))  # code to sort listres = sorted(ini_list, key = lambda x: x.split()[1])      # printing resultprint ("result", res)
initial list ['GeeksForGeeks abc', 'manjeet xab', 'akshat bac']
result ['GeeksForGeeks abc', 'akshat bac', 'manjeet xab']

Python list-programs
Python string-programs
Python-sort
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Detect Cycle in a Directed Graph

In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a directed graph, we need to check whether the graph contains a cycle or not. The output should be true if the given graph contains at least one cycle, otherwise false.
Now let’s observe the solution in the implementation below −
 Live Demo
# collections module
from collections import defaultdict
# class for creation of graphs
class Graph():
   # constructor
   def __init__(self, vertices):
      self.graph = defaultdict(list)
      self.V = vertices
   def addEdge(self, u, v):
      self.graph[u].append(v)
   def isCyclicUtil(self, v, visited, recStack):
      # Marking current node visited and addition to recursion stack
      visited[v] = True
      recStack[v] = True
      # if any neighbour is visited and in recStack then graph is cyclic in nature
      for neighbour in self.graph[v]:
         if visited[neighbour] == False:
            if self.isCyclicUtil(neighbour, visited, recStack) == True:
               return True
         elif recStack[neighbour] == True:
            return True
      # pop the node after the end of recursion
      recStack[v] = False
      return False
   # Returns true if graph is cyclic
   def isCyclic(self):
      visited = [False] * self.V
      recStack = [False] * self.V
      for node in range(self.V):
         if visited[node] == False:
            if self.isCyclicUtil(node, visited, recStack) == True:
               return True
      return False
g = Graph(4)
g.addEdge(0, 3)
g.addEdge(0, 2)
g.addEdge(3, 2)
g.addEdge(2, 0)
g.addEdge(1, 3)
g.addEdge(2, 1)
if g.isCyclic() == 1:
   print ("Graph is cyclic in nature")
else:
   print ("Graph is non-cyclic in nature")
Graph is cyclic in nature
All the variables are declared in the local scope and their references are seen in the figure above.
In this article, we have learned about how we can make a Python Program to Detect Cycle in a Directed Graph
Hashtable elements() Method in Java

28 Jun, 2018
The java.util.Hashtable.elements() method of Hashtable class in Java is used to get the enumeration of the values present in the hashtable.
Syntax:
Enumeration enu = Hash_table.elements()
Parameters: The method does not take any parameters.
Return value: The method returns an enumeration of the values of the Hashtable.
Below programs are used to illustrate the working of the java.util.Hashtable.elements() method:Program 1:
// Java code to illustrate the elements() methodimport java.util.*;  public class Hash_Table_Demo {    public static void main(String[] args)    {          // Creating an empty Hashtable        Hashtable<Integer, String> hash_table =                     new Hashtable<Integer, String>();          // Inserting elements into the table        hash_table.put(10, "Geeks");        hash_table.put(15, "4");        hash_table.put(20, "Geeks");        hash_table.put(25, "Welcomes");        hash_table.put(30, "You");          // Displaying the Hashtable        System.out.println("The Table is: " + hash_table);          // Creating an empty enumeration to store        Enumeration enu = hash_table.elements();          System.out.println("The enumeration of values are:");          // Displaying the Enumeration        while (enu.hasMoreElements()) {            System.out.println(enu.nextElement());        }    }}
The Table is: {10=Geeks, 20=Geeks, 30=You, 15=4, 25=Welcomes}
The enumeration of values are:
Geeks
Geeks
You
4
Welcomes

Program 2 :
// Java code to illustrate the elements() methodimport java.util.*;  public class Hash_Table_Demo {    public static void main(String[] args)    {          // Creating an empty Hashtable        Hashtable<String, Integer> hash_table =                    new Hashtable<String, Integer>();          // Inserting elements into the table        hash_table.put("Geeks", 10);        hash_table.put("4", 15);        hash_table.put("Geeks", 20);        hash_table.put("Welcomes", 25);        hash_table.put("You", 30);          // Displaying the Hashtable        System.out.println("The Table is: " + hash_table);          // Creating an empty enumeration to store        Enumeration enu = hash_table.elements();          System.out.println("The enumeration of values are:");          // Displaying the Enumeration        while (enu.hasMoreElements()) {            System.out.println(enu.nextElement());        }    }}
The Table is: {You=30, Welcomes=25, 4=15, Geeks=20}
The enumeration of values are:
30
25
15
20

Java - util package
Java-Collections
Java-HashTable
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Split() String method in Java with examples
Arrays.sort() in Java with examples
Object Oriented Programming (OOPs) Concept in Java
Reverse a string in Java
For-each loop in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
Stream In Java
Scala String hashCode() method with example

03 Oct, 2019
The hashCode() method is utilized to find the hash code of the stated string.
Method Definition: int hashCode()Return Type: It returns an integer hash code of the string given.
Example #1:
// Scala program of int hashCode()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying hashCode method        val result = "Nidhi".hashCode()                  // Displays output        println(result)          }} 
75262122

Example #2:
// Scala program of int hashCode()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying hashCode method        val result = " ".hashCode()                  // Displays output        println(result)              }} 
32

Scala
Scala-Method
Scala-Strings
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Class and Object in Scala
Type Casting in Scala
Scala Tutorial – Learn Scala with Step By Step Guide
Scala Lists
Operators in Scala
Scala | Arrays
Scala Constructors
Scala String substring() method with example
Lambda Expression in Scala
Scala Singleton and Companion Objects
Convert Set to String in Python

15 Oct, 2020
In this article, we will discuss how to convert a set to a string in Python. It can done using two ways –
Method 1: Using str()We will convert a Set into a String in Python using the str() function.
Syntax : str(object, encoding = ’utf-8?, errors = ’strict’)
Parameters :
object : The object whose string representation is to be returned.
encoding : Encoding of the given object.
errors : Response when decoding fails.
Returns : String version of the given object
Example 1 :
# create a sets = {'a', 'b', 'c', 'd'}print("Initially")print("The datatype of s : " + str(type(s)))print("Contents of s : ", s)  # convert Set to Strings = str(s)print("\nAfter the conversion")print("The datatype of s : " + str(type(s)))print("Contents of s : " + s)
Output :
Initially
The datatype of s : <class 'set'>
Contents of s :  {'c', 'd', 'a', 'b'}

After the conversion
The datatype of s : <class 'str'>
Contents of s : {'c', 'd', 'a', 'b'}

Example 2 :
# create a sets = {'g', 'e', 'e', 'k', 's'}print("Initially")print("The datatype of s : " + str(type(s)))print("Contents of s : ", s)  # convert Set to Strings = str(s)print("\nAfter the conversion")print("The datatype of s : " + str(type(s)))print("Contents of s : " + s)
Output :
Initially
The datatype of s : <class 'set'>
Contents of s :  {'k', 'g', 's', 'e'}

After the conversion
The datatype of s : <class 'str'>
Contents of s : {'k', 'g', 's', 'e'}

Method 2: Using Join()
The join() method is a string method and returns a string in which the elements of sequence have been joined by str separator.
Syntax:
string_name.join(iterable) 
# create a sets = {'a', 'b', 'c', 'd'}print("Initially")print("The datatype of s : " + str(type(s)))print("Contents of s : ", s)   # convert Set to StringS = ', '.join(s)print("The datatype of s : " + str(type(S)))print("Contents of s : ", S)
Output:
Initially
The datatype of s : <class 'set'>
Contents of s :  {'c', 'd', 'a', 'b'}
The datatype of s : <class 'str'>
Contents of s :  c, d, a, b
python-set
python-string
Python
python-set
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Create a directory in Python
C Program to Check if a Given String is a Palindrome?

A palindrome is a word, number, phrase, or other sequences of characters which reads the same backward as forward. Words such as madam or racecar or the number 10801 are a palindrome.
For a given string if reversing the string gives the same string then we can say that the given string is a palindrome. Which means to check for the palindrome, we need to find whether the first and last, second and last-1, and so on elements are equal or not.
Input − naman 
Output − string is a palindrome 
Input − tutorials point 
Output − string is not a palindrome
In C++ Program to Check if a Given String is a Palindrome. The entered string is copied to a new string, and then we compare the first letter with the last letter of string and second letter with second last letter and so on till the end of the string. If both of the letters have the same sequence of characters, i.e., they are identical then the string is a palindrome otherwise not.
#include <iostream>
#include<string.h>
using namespace std; {
   int main(){
      char string1[]={"naman"};
      int i, length;
      int flag = 0;
      length = strlen(string1);
      for(i=0;i < length ;i++){
         if(string1[i] != string1[length-i-1]) {
            flag = 1;
            break;
         }
      }
      if (flag==1){
         printf(" string is not a palindrome");
      } else {
         printf(" string is a palindrome");
      }
      return 0;
   }
}
string is a palindrome
Note - The program is case sensitive.
How to create an unordered list with square bullets in HTML ?

13 Jan, 2022
In this article, we will see how to create an unordered list with square bullets using HTML. To create an unordered list with square bullets, we will use CSS list-style-type: square property.
The list-style-type property in CSS specifies the appearance of the list item marker (such as a disc, character, or custom counter style).
Syntax:
list-style-type: disc|circle|square|decimal|lower-roman|upper-roman|
lower-greek|lower-latin|upper-latin|lower-alpha|upper-alpha|none|
inherit;
Approach: In the below example, we will create an unordered list items using <ul> and <li> tags and add CSS list-style-type: square style on <ul> element to make square bullets.
Example:
HTML
<!DOCTYPE html><html lang="en">  <head>    <title>        How to create an unordered list         with square bullets in HTML?    </title></head>  <body>    <h1 style="color:green;">        GeeksforGeeks    </h1>    <h3>        How to create an unordered list         <br>with square bullets in HTML?    </h3>      <p>Web Development Technologies - </p>    <ul style="list-style-type:square">        <li>HTML</li>        <li>CSS</li>        <li>JavaScript</li>        <li>jQuery</li>    </ul></body>  </html>
Output:
HTML-Attributes
HTML-Questions
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Angular File Upload
Form validation using jQuery
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Writer flush() method in Java with Examples

29 Jan, 2019
The flush() method of Writer Class in Java is used to flush the writer. By flushing the writer, it means to clear the writer of any element that may be or maybe not inside the writer. It neither accepts any parameter nor returns any value.
Syntax:
public void flush()
Parameters: This method do not accepts any parameter.
Return Value: This method do not returns any value. It just flushes the writer.
Below methods illustrates the working of flush() method:
Program 1:
// Java program to demonstrate// Writer flush() method  import java.io.*;  class GFG {    public static void main(String[] args)    {          // The string to be written in the writer        String str = "GeeksForGeeks";          try {              // Create a Writer instance            Writer writer                = new PrintWriter(System.out);              // Write the above string to this writer            // This will put the string in the writer            // till it is printed on the console            writer.write(str);              // Now clear the writer            // using flush() method            writer.flush();        }        catch (Exception e) {            System.out.println(e);        }    }}
GeeksForGeeks

Program 2:
// Java program to demonstrate// Writer flush() method  import java.io.*;  class GFG {    public static void main(String[] args)    {          try {              // Create a Writer instance            Writer writer                = new PrintWriter(System.out);              // Write the char to this writer            // This will put the char in the writer            // till it is printed on the console            writer.write(65);              // Now clear the writer            // using flush() method            writer.flush();        }        catch (Exception e) {            System.out.println(e);        }    }}
A

Java-Functions
Java-IO package
Java-Writer
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
Stream In Java
ArrayList in Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Set in Java
How to find common elements between two Vector using STL in C++?

19 Mar, 2019
Given two vectors, find common elements between these two vectors using STL in C++.
Example:
Input:vec1 = {1, 45, 54, 71, 76, 12},vec2 = {1, 7, 5, 4, 6, 12}Output: {1, 12}
Input:vec1 = {1, 7, 5, 4, 6, 12},vec2 = {10, 12, 11}Output: {1, 4, 12}
Approach: Common elements can be found with the help of set_intersection() function provided in STL.
Syntax:
set_intersection (InputIterator1 first1, InputIterator1 last1,
           InputIterator2 first2, InputIterator2 last2,
           OutputIterator result);

// C++ program to find common elements// between two Vectors using STL  #include <bits/stdc++.h>using namespace std;  int main(){      // Get the vector    vector<int> vector1 = { 1, 45, 54, 71, 76, 12 };    vector<int> vector2 = { 1, 7, 5, 4, 6, 12 };      // Sort the vector    sort(vector1.begin(), vector1.end());    sort(vector2.begin(), vector2.end());      // Print the vector    cout << "First Vector: ";    for (int i = 0; i < vector1.size(); i++)        cout << vector1[i] << " ";    cout << endl;      cout << "Second Vector: ";    for (int i = 0; i < vector2.size(); i++)        cout << vector2[i] << " ";    cout << endl;      // Initialise a vector    // to store the common values    // and an iterator    // to traverse this vector    vector<int> v(vector1.size() + vector2.size());    vector<int>::iterator it, st;      it = set_intersection(vector1.begin(),                          vector1.end(),                          vector2.begin(),                          vector2.end(),                          v.begin());      cout << "\nCommon elements:\n";    for (st = v.begin(); st != it; ++st)        cout << *st << ", ";    cout << '\n';      return 0;}
First Vector: 1 12 45 54 71 76 
Second Vector: 1 4 5 6 7 12 

Common elements:
1, 12,

cpp-vector
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Groovy - put()

Associates the specified value with the specified key in this Map. If this Map previously contained a mapping for this key, the old value is replaced by the specified value.
Object put(Object key, Object value)

Key – The key to be put in the map
Value – The associated value for the key
The returned key-value pair which is inserted.
Following is an example of the usage of this method −
class Example { 
   static void main(String[] args) { 
      def mp = ["TopicName" : "Maps", "TopicDescription" : "Methods in Maps"] 
      mp.put("TopicID","1");
      println(mp); 
   } 
}
When we run the above program, we will get the following result −
[TopicName:Maps, TopicDescription:Methods in Maps, TopicID:1]


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
How to create and store property file dynamically in Java?

The .propertiesis an extension in java which is used to store configurable application. It is represented by the Properties class in Java, you can store a properties file and read from it using the methods of this class. This class inherits the HashTable class.
To create a properties file −
Instantiate the Properties class.
Populate the created Properties object using the put() method.
Instantiate the FileOutputStream class by passing the path to store the file, as a parameter.
The Following Java program creates a properties file in the path D:/ExampleDirectory/
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class CreatingPropertiesFile {
   public static void main(String args[]) throws IOException {
      //Instantiating the properties file
      Properties props = new Properties();
      //Populating the properties file
      props.put("Device_name", "OnePlus7");
      props.put("Android_version", "9");
      props.put("Model", "GM1901");
      props.put("CPU", "Snapdragon855");
      //Instantiating the FileInputStream for output file
      String path = "D:\\ExampleDirectory\\myFile.properties";
      FileOutputStream outputStrem = new FileOutputStream(path);
      //Storing the properties file
      props.store(outputStrem, "This is a sample properties file");
      System.out.println("Properties file created......");
   }
}
Properties file created......
If you observe the output file you can see the created contents as −
You can store the properties file in XMLformat using the storeToXML() method.
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class CreatingPropertiesFile {
   public static void main(String args[]) throws IOException {
      //Instantiating the properties file
      Properties props = new Properties();
      //Populating the properties file
      props.put("Device_name", "OnePlus7");
      props.put("Android_version", "9");
      props.put("Model", "GM1901");
      props.put("CPU", "Snapdragon855");
      //Instantiating the FileInputStream for output file
      String outputPath = "D:\\ExampleDirectory\\myFile.xml";
      FileOutputStream outputStrem = new FileOutputStream(outputPath);
      //Storing the properties file in XML format
      props.storeToXML(outputStrem, "This is a sample properties file");
      System.out.println("Properties file created......");
   }
}
Properties file created......
If you observe the output file you can see the created contents as −
What does int argc, char *argv[] mean in C/C++?

argc stands for argument count and argv stands for argument values. These are variables passed to the main function when it starts executing. When we run a program we can give arguments to that program like −
$ ./a.out hello
Here hello is an argument to the executable. This can be accessed in your program. For example,
#include<iostream>
using namespace std;
int main(int argc, char** argv) {
   cout << "This program has " << argc << " arguments:" << endl;
   for (int i = 0; i < argc; ++i) {
      cout << argv[i] << endl;
   }
   return 0;
}

When you compile and run this program like −
$ ./a.out hello people
This will give the output −
This program has 3 arguments
C:\Users\user\Desktop\hello.exe
hello
people
Note that the first argument is always the location of the executable executing.
Get current date/time in seconds - JavaScript?

At first, get the current date −
var currentDateTime = new Date();
To get the current date/time in seconds, use getTime()/1000.
Following is the code −
var currentDateTime = new Date();
console.log("The current date time is as follows:");
console.log(currentDateTime);
var resultInSeconds=currentDateTime.getTime() / 1000;
console.log("The current date time in seconds is as follows:")
console.log(resultInSeconds);
To run the above program, you need to use the following command −
node fileName.js.

Here, my file name is demo285.js.
This will produce the following output on console −
The current date time is as follows:
2020-08-28T16:13:35.987Z
The current date time in seconds is as follows:
1598631215.987
crypt() function in PHP

The crypt() function is used to hash the string using using algorithms like DES, Blowfish, or MD5.
Note − This function behaves different on different operating systems.
The following are some constants used together with the crypt() function.
[CRYPT_STD_DES] - Standard DES-based hash with two character salt from the alphabet "./0-9A-Za-z".
[CRYPT_STD_DES] - Standard DES-based hash with two character salt from the alphabet "./0-9A-Za-z".
[CRYPT_EXT_DES] - Extended DES-based hash with a nine character salt consisting of an underscore followed by 4 bytes of iteration count and 4 bytes of salt.
[CRYPT_EXT_DES] - Extended DES-based hash with a nine character salt consisting of an underscore followed by 4 bytes of iteration count and 4 bytes of salt.
[CRYPT_MD5] - MD5 hashing with a 12 character salt starting with 1
[CRYPT_MD5] - MD5 hashing with a 12 character salt starting with 1
[CRYPT_BLOWFISH] - Blowfish hashing with a salt starting with 2a, 2x, or 2y, a two digit cost parameters "$", and 22 characters from the alphabet "./0-9A-Za-z".
[CRYPT_BLOWFISH] - Blowfish hashing with a salt starting with 2a, 2x, or 2y, a two digit cost parameters "$", and 22 characters from the alphabet "./0-9A-Za-z".
[CRYPT_SHA_256] - SHA-256 hash with a 16 character salt starting with 5.
[CRYPT_SHA_256] - SHA-256 hash with a 16 character salt starting with 5.
[CRYPT_SHA_512] - SHA-512 hash with a 16 character salt starting with 6.
[CRYPT_SHA_512] - SHA-512 hash with a 16 character salt starting with 6.
crypt(str, salt)
str − The string to be hashed. Required.
str − The string to be hashed. Required.
salt − Salt string to base the hashing on. Optional.
salt − Salt string to base the hashing on. Optional.
The crypt() function returns the encoded string or a string shorter than 13 characters and is guaranteed to differ from the salt on failure
The following is an example −
 Live Demo
<?php
if (CRYPT_STD_DES == 1) {
   echo "DES supported = ".crypt('demo','st')."\n";
} else {
   echo "DES not supported!";
}
?>
The following is the output −
DES supported = st7zBedJadRn2
MFC - Date & Time Picker

The date and time picker control (CDateTimeCtrl) implements an intuitive and recognizable method of entering or selecting a specific date. The main interface of the control is similar in functionality to a combo box. However, if the user expands the control, a month calendar control appears (by default), allowing the user to specify a particular date. When a date is chosen, the month calendar control automatically disappears.
CloseMonthCal
Closes the current date and time picker control.
Create
Creates the date and time picker control and attaches it to the CDateTimeCtrl object.
GetDateTimePickerInfo
Retrieves information about the current date and time picker control.
GetIdealSize
Returns the ideal size of the date and time picker control that is required to display the current date or time.
GetMonthCalColor
Retrieves the color for a given portion of the month calendar within the date and time picker control.
GetMonthCalCtrl
Retrieves the CMonthCalCtrl object associated with the date and time picker control.
GetMonthCalFont
Retrieves the font currently used by the date and time picker control's child month calendar control.
GetMonthCalStyle
Gets the style of the current date and time picker control.
GetRange
Retrieves the current minimum and maximum allowed system times for a date and time picker control.
GetTime
Retrieves the currently selected time from a date and time picker control and puts it in a specified SYSTEMTIME structure.
SetFormat
Sets the display of a date and time picker control in accordance with a given format string.
SetMonthCalColor
Sets the color for a given portion of the month calendar within a date and time picker control.
SetMonthCalFont
Sets the font that the date and time picker control's child month calendar control will use.
SetMonthCalStyle
Sets the style of the current date and time picker control.
SetRange
Sets the style of the current date and time picker control.
SetTime
Sets the time in a date and time picker control.
Let us look into a simple example by creating a new MFC application.
Step 1 − Remove the Caption and set its ID to IDC_STATIC_TXT.
Step 2 − Add the value variable for text control.
Step 3 − Drag the Date Time Picker control.
Step 4 − Add a control variable for Date Time Picker.
Step 5 − Add the Event handler for Date Time Picker.
Step 6 − Here is the implementation of  event handler.
void CMFCDateAndTimePickerDlg::OnDtnDatetimechangeDatetimepicker1(NMHDR *pNMHDR, LRESULT *pResult){ 
   LPNMDATETIMECHANGE pDTChange = reinterpret_cast  <LPNMDATETIMECHANGE>(pNMHDR); 
   // TODO: Add your control notification handler code here 
  
   GetDlgItemText(IDC_DATETIMEPICKER1, m_strValue); 
   UpdateData(FALSE); 
   *pResult = 0; 
} 
Step 7 − When you run the above application, you see the following output. Select any date, it will display on the Static Text Control.
 Print
 Add Notes
 Bookmark this page
What are Base and Derived Classes in C#?

A class can be derived from more than one class or interface, which means that it can inherit data and functions from multiple base classes or interfaces.
For example, Vehicle Base class with the following Derived Classes.
Truck
Bus
Motobike
The derived class inherits the base class member variables and member methods.
In the same way, the derived class for Shape class can be Rectangle as in the following example.
 Live Demo
using System;
namespace Program {
   class Shape {
      public void setWidth(int w) {
         width = w;
      }
      public void setHeight(int h) {
         height = h;
      }
      protected int width;
      protected int height;
   }
   // Derived class
   class Rectangle: Shape {
      public int getArea() {
         return (width * height);
      }
   }
   class Demo {
      static void Main(string[] args) {
         Rectangle Rect = new Rectangle();
         Rect.setWidth(5);
         Rect.setHeight(7);
         // Print the area of the object.
         Console.WriteLine("Total area: {0}", Rect.getArea());
         Console.ReadKey();
      }
   }
}
Total area: 35
Program to print all the numbers divisible by 3 and 5 in C++

In this tutorial, we will be discussing a program to print all the numbers divisible by 3
and 5 less than the given number.
For this we will be given with a number say N. Our task is to print all the numbers less than N which are divisible by both 3 and 5.
 Live Demo
#include <iostream>
using namespace std;
//printing the numbers divisible by 3 and 5
void print_div(int N){
   for (int num = 0; num < N; num++){
      if (num % 3 == 0 && num % 5 == 0)
      cout << num << " ";
   }
}
int main(){
   int N = 70;
   print_div(N);
   return 0;
}
0 15 30 45 60