code-rag-bench/online-tutorials huggingface dataset:
What is Escrow Smart Contract?

11 May, 2022
Escrow is the third party which holds the asset(asset can be money, bond, stocks) on the presence of two parties. Escrow will release the fund when certain conditions are met.For Example, “A” is a seller and wants to sell his car, “B” is a buyer who wants to buy “A”‘s car so they will contact Escrow “C”(an arbiter) which hold the asset until “B” receives the car. When this condition will be met, Escrow will release the fund to “A”. This solves the issue of trust and prevents any discrepancy.Lets the write a smart contract for the Escrow using solidity language. Here Smart contract will hold the asset, which will be released on when conditions are fulfilled. 
Solidity
pragma solidity 0.6.0;        // Defining a Contractcontract escrow{      // Declaring the state variables    address payable public buyer;    address payable public seller;    address payable public arbiter;    mapping(address => uint) TotalAmount;      // Defining a enumerator 'State'    enum State{                 // Following are the data members        awate_payment, awate_delivery, complete     }      // Declaring the object of the enumerator    State public state;          // Defining function modifier 'instate'    modifier instate(State expected_state){                  require(state == expected_state);        _;    }     // Defining function modifier 'onlyBuyer'    modifier onlyBuyer(){        require(msg.sender == buyer ||                 msg.sender == arbiter);        _;    }      // Defining function modifier 'onlySeller'    modifier onlySeller(){        require(msg.sender == seller);        _;    }          // Defining a constructor    constructor(address payable _buyer,                 address payable _sender) public{                // Assigning the values of the         // state variables        arbiter = msg.sender;        buyer = _buyer;        seller = _sender;        state = State.awate_payment;    }          // Defining function to confirm payment    function confirm_payment() onlyBuyer instate(      State.awate_payment) public payable{              state = State.awate_delivery;              }          // Defining function to confirm delivery    function confirm_Delivery() onlyBuyer instate(      State.awate_delivery) public{                  seller.transfer(address(this).balance);        state = State.complete;    }      // Defining function to return payment    function ReturnPayment() onlySeller instate(      State.awate_delivery)public{                        buyer.transfer(address(this).balance);    }      }
Solidity-Basics
Blockchain
Solidity
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to connect ReactJS with MetaMask ?
Solidity - Libraries
Solidity - While, Do-While, and For Loop
Solidity - Functions
Blockchain - Hyperledger vs Ethereum
Solidity - Libraries
Solidity - While, Do-While, and For Loop
Solidity - Functions
Solidity - Variables
What are Events in Solidity?
Python | Pandas Index.delete()

16 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Index.delete() function returns a new object with the passed locations deleted. We can pass more than one locations to be deleted in the form of list.
Syntax: Index.delete(loc)
Parameters :loc : Scalar/List of Indices
Returns : new_index : Index
Example #1: Use Index.delete() function to delete the first value in the Index.
# importing pandas as pdimport pandas as pd  # Creating the Indexidx = pd.Index(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',                'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'])  # Print the Indexidx
Output :
Let’s delete the month of ‘Jan’. It is present at the 0th index so we will pass 0 as an argument to the function.
# delete the first label in the given Indexidx.delete(0)
Output :As we can see in the output, the function has returned an object with its first label deleted. Example #2: Use Index.delete() function to delete more than one labels in the Index.
# importing pandas as pdimport pandas as pd  # Creating the Indexidx = pd.Index(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',                'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'])  # Print the Indexidx
Output :
Let’s delete the second, third, fourth and fifth indices from the Index. We pass a list of values to be deleted to the function.
# to delete values present at 2nd, 3rd, 4th and 5th place in the Index.idx.delete([2, 3, 4, 5])
Output :As we can see the labels corresponding to the passed values in the Index has been deleted.
Python pandas-indexing
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install Kotlin on Linux? - GeeksforGeeks

26 Nov, 2021
Kotlin is a programming language introduced by JetBrains in 2011, the official designer of the most intelligent Java IDE, named Intellij IDEA. This is a strongly statically typed general-purpose programming language that runs on JVM. In 2017, Kotlin is sponsored by Google, announced as one of the official languages for Android Development.
In this article, we will learn How can we install the Kotlin programming language in Linux. 
Follow the below steps to install Koptlin on your Linux system.
Step 1: Upgrade Packages 
Open your Linux terminal and update your package information from all configured sources.
# sudo apt update
Step 2: Install JDK
Install the Java Software Development Kit (JDK). Kotlin is based on JDK. JDK is used to compile Kotlin programs. When you run the following command you will be asked to enter Y or N enter Y and click enter.
# sudo apt install default-jdk
Step 3: Install Kotlin using SDKMAN
SDKMAN is an easier way to install Kotlin on UNIX-based systems. After Installing SDKMAN restart your computer.
# curl -s https://get.sdkman.io | bash
Now we will install Kotlin using the following command.
# sdk install kotlin
After executing the above command Kotlin will be installed in your system. Now we will create a Kotlin file and check it by doing compile and run.
Step 4: Create a Kotlin file
Open any editor and write the following code there and save that file with the .kt extension. Here I’m creating a file with Kotlin.kt name.
For creating a file write nano fileName.kt in your terminal. Then write your Kotlin code inside that file and save it using ctrl + x and then press y.  
Kotlin
// Function in Kotlinfun main(args: Array<String>) {        // Print statement    println("GeeksforGeeks")}
Step 5: Compile Kotlin file
Navigate to that folder in which you have created your Kotlin file and then compile that file using the following command. Replace Kotlin.kt with your file name and The value of the -d option specifies the name of the output file.
# kotlinc Kotlin.kt -include-runtime -d outPutFile.jar
Step 6: Run the Kotlin Program
Now we will check the output by running the following command.
# java -jar outPutFile.jar
Output:
GeeksforGeeks
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to create a nested RecyclerView in Android
How to Create and Setup Spring Boot Project in Eclipse IDE?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
How to return custom result type from an action method in C# ASP.NET WebAPI?

We can create our own custom class as a result type by implementing IHttpActionResult interface. IHttpActionResult contains a single method,
ExecuteAsync, which asynchronously creates an HttpResponseMessage instance.
public interface IHttpActionResult
{
   Task<HttpResponseMessage> ExecuteAsync(CancellationToken
   cancellationToken);
}
If a controller action returns an IHttpActionResult, Web API calls the ExecuteAsync
method to create an HttpResponseMessage. Then it converts the HttpResponseMessage into an HTTP response message.
To have our own custom result we must create a class that implements
IHttpActionResult interface.
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;
namespace DemoWebApplication.Controllers{
   public class CustomResult : IHttpActionResult{
      string _value;
      HttpRequestMessage _request;
      public CustomResult(string value, HttpRequestMessage request){
         _value = value;
         _request = request;
      }
      public Task<HttpResponseMessage> ExecuteAsync(CancellationToken
      cancellationToken){
         var response = new HttpResponseMessage(){
            Content = new StringContent($"Customized Result: {_value}"),
            RequestMessage = _request
         };
         return Task.FromResult(response);
      }
   }
}
Contoller Action −
using DemoWebApplication.Models;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
namespace DemoWebApplication.Controllers{
   public class DemoController : ApiController{
      public IHttpActionResult Get(int id){
         List<Student> students = new List<Student>{
            new Student{
               Id = 1,
               Name = "Mark"
            },
            new Student{
               Id = 2,
               Name = "John"
            }
         };
         var studentForId = students.FirstOrDefault(x => x.Id == id);
         return new CustomResult(studentForId.Name, Request);
      }
   }
}
Here is the postman output of the endpoint which returns custom result.
Bootstrap Tables

A basic Bootstrap table has a light padding and only horizontal dividers.
The .table class adds basic styling to a table:
The .table-striped class adds zebra-stripes to a table:
The .table-bordered class adds borders on all sides of the table and cells:
The .table-hover class adds a hover effect (grey background color) on table rows:
The .table-condensed class makes a table more compact by cutting cell padding in half:
Contextual classes can be used to color table rows (<tr>) or table cells (<td>):
The contextual classes that can be used are:
The .table-responsive class creates a responsive table. The table will then 
scroll horizontally on small devices (under 768px). When viewing on anything 
larger than 768px wide, there is no difference:
Add a class attribute to style the table as a basic Bootstrap table.
<table >
  <tr>
    <td>John</td>
    <td>Doe</td>
    <td>john@example.com</td>
  <tr>
  <tr>
    <td>Mary</td>
    <td>Moe</td>
    <td>mary@example.com</td>
  </tr>
  <tr>
    <td>July</td>
    <td>Dooley</td>
    <td>july@example.com</td>
  </tr>
<table>

Start the Exercise
For a complete reference of all table classes, go to our complete
Bootstrap Tables Reference.
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Install PostgreSQL on Mac - GeeksforGeeks

04 Oct, 2021
This is a step-by-step guide to install PostgreSQL on a Mac OS machine. We will be installing PostgreSQL version 11.3 on Mac using the installer provided by EnterpriseDB in this article. 
There are three crucial steps for the installation of PostgreSQL as follows: 
Download PostgreSQL EnterpriseDB installer for MacInstall PostgreSQLVerify the installation
Download PostgreSQL EnterpriseDB installer for Mac
Install PostgreSQL
Verify the installation
You can download the latest stable PostgreSQL Installer specific to your Mac OS by clicking here.  
After downloading the installer run the downloaded dmg package as administrator user and follow the below steps: 
Step 1: Click the Next button 
Step 2: Choose the installation folder, where you want PostgreSQL to be installed, and click on Next.  
Step 3: Select the components as per your requirement to install and click the Next button. 
Step 4: Select the database directory where you want to store the data an click on Next.  
Step 5: Set the password for the database superuser (Postgres) 
Step 6: Set the port for PostgreSQL. Make sure that no other applications are using this port. If unsure leave it to its default (5432) and click on Next. 
Step 7: Choose the default locale used by the database and click the Next button. 
Step 8: Click the Next button to start the installation. 
Wait for the installation to complete, it might take a few minutes.  
You can check the installation using the below command in the terminal:  
ps -ef | grep postgres
This will result in the below image:
 
anikaseth98
postgreSQL-basics
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - Psql commands
PostgreSQL - Change Column Type
PostgreSQL - For Loops
PostgreSQL - Function Returning A Table
PostgreSQL - Create Auto-increment Column using SERIAL
PostgreSQL - ARRAY_AGG() Function
PostgreSQL - CREATE PROCEDURE
PostgreSQL - DROP INDEX
PostgreSQL - Copy Table
PostgreSQL - Cursor
Arduino - Conditional Operator ? :

The conditional operator ? : is the only ternary operator in C.
expression1 ? expression2 : expression3

Expression1 is evaluated first. If its value is true, then expression2 is evaluated and expression3 is ignored. If expression1 is evaluated as false, then expression3 evaluates and expression2 is ignored. The result will be a value of either expression2 or expression3 depending upon which of them evaluates as True.
Conditional operator associates from right to left.
Example
/* Find max(a, b): */
max = ( a > b ) ? a : b;
/* Convert small letter to capital: */
/* (no parentheses are actually necessary) */
c = ( c >= 'a' && c <= 'z' ) ? ( c - 32 ) : c;
expression1 must be a scalar expression; expression2 and expression3 must obey one of the following rules.
Both expressions have to be of arithmetic type.
expression2 and expression3 are subjected to usual arithmetic conversions, which determines the resulting type.
>Both expressions have to be of void type. The resulting type is void.

    65 Lectures 
     6.5 hours 

 Amit Rana

    43 Lectures 
     3 hours 

 Amit Rana

    20 Lectures 
     2 hours 

 Ashraf Said

    19 Lectures 
     1.5 hours 

 Ashraf Said

    11 Lectures 
     47 mins

 Ashraf Said

    9 Lectures 
     41 mins

 Ashraf Said
 Print
 Add Notes
 Bookmark this page
How to Install php-curl in Ubuntu ? - GeeksforGeeks

05 Oct, 2021
CURL stands for Client URL. It is a Linux Terminal command which is used to transferring data from one server to another server. It is a free and open-source data transfer tool that uses the following protocols: IMAP, IMAPS, POP, POP3, POP3S, DICT, FILE HTTP, HTTPS, SMB, SMBS, SMTP, SMTPS, FTP, FTPS, TELNET, RTSP, RMTP, and TFTP.
It displays a meter-like progress bar while running and indicating various parameters like the amount of transferred data, speed of data transfer and estimated time left.
Following are the steps for the installation of PHP-CURL on your Ubuntu system:
Step 1: Install PHP libraries for the server by running the following command:$ sudo add-apt-repository ppa:ondrej/php
$ sudo add-apt-repository ppa:ondrej/php
Step 2: Then, update the server:$ sudo apt update
$ sudo apt update
Step 3: Now, install CURL.$ sudo apt install curl
$ sudo apt install curl
Step 4: You can check the version of curl installed by the command:$ dpkg -l curl
$ dpkg -l curl
Step 5: Once you have installed CURL on Ubuntu 18.04 PHP server, you need to restart your webserver on which PHP is running:If you are using Apache server then use either of the following commands to restart the server:$ sudo service apache2 restartor$ sudo /etc/init.d/apache2 restartSimilarly, if you are using Nginx server, then use either of the following commands:$ sudo systemctl restart nginxor$ sudo /etc/init.d/nginx restart
If you are using Apache server then use either of the following commands to restart the server:
$ sudo service apache2 restart
or
$ sudo /etc/init.d/apache2 restart
Similarly, if you are using Nginx server, then use either of the following commands:
$ sudo systemctl restart nginx
or
$ sudo /etc/init.d/nginx restart
PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
how-to-install
PHP-Misc
Picked
How To
Installation Guide
PHP
PHP Programs
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Align Text in HTML?
How to filter object array based on attributes?
Java Tutorial
How to Install FFmpeg on Windows?
How to integrate Git Bash with Visual Studio Code?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Anaconda on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
Ext.js - Data

Data package is used for loading and saving all the data in the application.
Data package has numerous number of classes but the most important classes are −
Model
Store
Proxy
The base class for model is Ext.data.Model. It represents an entity in an application. It binds the store data to view. It has mapping of backend data objects to the view dataIndex. The data is fetched with the help of store.
For creating a model, we need to extend Ext.data.Model class and we need to define the fields, their name, and mapping.
Ext.define('StudentDataModel', {
   extend: 'Ext.data.Model',
   fields: [
      {name: 'name', mapping : 'name'},
      {name: 'age', mapping : 'age'},
      {name: 'marks', mapping : 'marks'}
   ]
});
Here, the name should be the same as the dataIndex, which we declare in the view and the mapping should match the data, either static or dynamic from the database, which is to be fetched using store.
The base class for store is Ext.data.Store. It contains the data locally cached, which is to be rendered on view with the help of model objects. Store fetches the data using proxies, which has the path defined for services to fetch the backend data.
Store data can be fetched in two ways - static or dynamic.
For static store, we will have all the data present in the store as shown in the following code.
Ext.create('Ext.data.Store', {
   model: 'StudentDataModel',
   data: [
      { name : "Asha", age : "16", marks : "90" },
      { name : "Vinit", age : "18", marks : "95" },
      { name : "Anand", age : "20", marks : "68" },
      { name : "Niharika", age : "21", marks : "86" },
      { name : "Manali", age : "22", marks : "57" }
   ];
});
Dynamic data can be fetched using proxy. We can have proxy which can fetch data from Ajax, Rest, and Json.
The base class for proxy is Ext.data.proxy.Proxy. Proxy is used by Models and Stores to handle the loading and saving of Model data.
There are two types of proxies
Client Proxy
Server Proxy
Client proxies include Memory and Local Storage using HTML5 local storage.
Server proxies handle data from the remote server using Ajax, Json data, and Rest service.
Defining proxies in the server
Ext.create('Ext.data.Store', {
   model: 'StudentDataModel',
   proxy : {
      type : 'rest',
      actionMethods : {
         read : 'POST'  // Get or Post type based on requirement
      },
      url : 'restUrlPathOrJsonFilePath', // here we have to include the rest URL path 
      // which fetches data from database or Json file path where the data is stored
      reader: {
         type : 'json',  // the type of data which is fetched is of JSON type
         root : 'data'
      },
   }
});
 Print
 Add Notes
 Bookmark this page
Google Maps - Info Window

In addition to markers, polygons, polylines, and other geometrical shapes, we can also draw an Info Window on the map. This chapter explains how to use the Info Window.
Info Window is used to add any kind of information to the map. For instance, if you want to provide information about a location on the map, you can use an info window. Usually the info window is attached to a marker. You can attach an info window by instantiating the google.maps.InfoWindow class. It has the following properties −
Content − You can pass your content in String format using this option.
Content − You can pass your content in String format using this option.
position − You can choose the position of the info window using this option.
position − You can choose the position of the info window using this option.
maxWidth − By default, the info window's width will be stretched till the text is wrapped. By specifying maxWidth, we can restrict the size of the info window horizontally.
maxWidth − By default, the info window's width will be stretched till the text is wrapped. By specifying maxWidth, we can restrict the size of the info window horizontally.
The following example shows how to set the marker and specify an info window above it −
<!DOCTYPE html>
<html>
   
   <head>
      <script src = "https://maps.googleapis.com/maps/api/js"></script>
      
      <script>
         function loadMap() {
			
            var mapOptions = {
               center:new google.maps.LatLng(17.433053, 78.412172),
               zoom:5
            }
            
            var map = new google.maps.Map(document.getElementById("sample"),mapOptions);
            
            var marker = new google.maps.Marker({
               position: new google.maps.LatLng(17.433053, 78.412172),
               map: map,
               draggable:true,
               icon:'/scripts/img/logo-footer.png'
            });
            
            marker.setMap(map);
            
            var infowindow = new google.maps.InfoWindow({
               content:"388-A , Road no 22, Jubilee Hills, Hyderabad Telangana, INDIA-500033"
            });
				
            infowindow.open(map,marker);
         }
      </script>
      
   </head>
   
   <body onload = "loadMap()">
      <div id = "sample" style = "width:580px; height:400px;"></div>
   </body>
   
</html>
It will produce the following output −

    20 Lectures 
     2.5 hours 

 Asif Hussain

    7 Lectures 
     1 hours 

 Aditya Kulkarni

    33 Lectures 
     2.5 hours 

 Sasha Miller

    22 Lectures 
     1.5 hours 

 Zach Miller

    16 Lectures 
     1.5 hours 

 Sasha Miller

    23 Lectures 
     2.5 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
How to create blur activity background in android?

This example demonstrate about How to create blue activity background 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"?>
<LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android"
   xmlns:app = "http://schemas.android.com/apk/res-auto"
   xmlns:tools = "http://schemas.android.com/tools"
   android:layout_width = "match_parent"
   android:gravity = "center"
   android:layout_height = "match_parent"
   tools:context = ".MainActivity"
   android:background = "@drawable/ic_launcher_background"
   android:orientation = "vertical">
   <TextView
      android:id = "@+id/text"
      android:textSize = "30sp"
      android:layout_width = "wrap_content"
      android:layout_height = "wrap_content" />
</LinearLayout>
In the above code, we have taken text view to show sample text.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.telephony.TelephonyManager;
import android.view.WindowManager;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
   private static final int PERMISSION_REQUEST_CODE = 100;
   TextView textView;
   TelephonyManager telephonyManager;
   @RequiresApi(api = Build.VERSION_CODES.P)
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
      WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
      setContentView(R.layout.activity_main);
      textView = findViewById(R.id.text);
      textView.setText("Blur Behind Flag");
   }
}
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
Dunder or magic methods in python

magic methods that allow us to do some pretty neat tricks in object oriented programming. These methods are identified by a two underscores (__) used as prefix and suffix. As example, function as interceptors that are automatically called when certain conditions are met.
In python __repr__ is a built-in function used to compute the "official" string representation of an object, while __str__ is a built-in function that computes the "informal" string representations of an object.
 Live Demo
class String:
   # magic method to initiate object
   def __init__(self, string):
      self.string = string
# Driver Code
if __name__ == '__main__':
   # object creation
   my_string = String('Python')
   # print object location
   print(my_string)
<__main__.String object at 0x000000BF0D411908>

 Live Demo
class String:
   # magic method to initiate object
   def __init__(self, string):
      self.string = string
   # print our string object
   def __repr__(self):
      return 'Object: {}'.format(self.string)
# Driver Code
if __name__ == '__main__':
   # object creation
   my_string = String('Python')
   # print object location
   print(my_string)
Object: Python

 Live Demo
class String:
   # magic method to initiate object
   def __init__(self, string):
      self.string = string
   # print our string object
   def __repr__(self):
      return 'Object: {}'.format(self.string)
# Driver Code
if __name__ == '__main__':
   # object creation
   my_string = String('Python')
   # concatenate String object and a string
   print(my_string + ' Program')
TypeError: unsupported operand type(s) for +: 'String' and 'str'

Now add __add__ method to String class
class String:
   # magic method to initiate object
   def __init__(self, string):
      self.string = string
   # print our string object
   def __repr__(self):
      return 'Object: {}'.format(self.string)
   def __add__(self, other):
      return self.string + other
# Driver Code
if __name__ == '__main__':
   # object creation
   my_string = String('Hello')
   # concatenate String object and a string
   print(my_string +' Python')
Hello Python
list empty() function in C++ STL

In this article we will be discussing the working, syntax and examples of list::empty() function in C++.
List is a data structure that allows constant time insertion and deletion anywhere in sequence. Lists are implemented as doubly linked lists. Lists allow non-contiguous memory allocation. List perform better insertion extraction and moving of element in any position in container than array, vector and deque. In List the direct access to the element is slow and list is similar to forward_list, but forward list objects are single linked lists and they can only be iterated forwards.
list::empty() is an inbuilt function in C++ STL which is declared in header file. list::empty() checks whether the given list container is empty(size is 0) or not, and returns true value if the list is empty and false if the list is not empty.
bool list_name.empty();
This function accepts no value.
This function returns true if the container size is zero and false if the container size is not zero.
In the below code we will call a function empty() to check whether a list is empty or not and if the list is empty then we will insert elements to a list using push_back() function to check the result.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int main() {
   list<int> myList; //to create a list
   //call empty() function to check if list is empty or not
   if (myList.empty())
      cout << "my list is empty\n";
   else
      cout << "my list isn’t empty\n";
   //push_back() is used to insert element in a list
   myList.push_back(1);
   myList.push_back(2);
   myList.push_back(3);
   myList.push_back(4);
   if (myList.empty())
      cout << "my list is empty\n";
   else
      cout << "my list is not empty\n";
   return 0;
}
If we run the above code it will generate the following output
my list is empty
my list is not empty


In the below code we are trying to multiply the numbers from 1-10 and for that −
First insert elements into the list using push_back() function
First insert elements into the list using push_back() function
Traverse the list until it won’t get empty using the function empty().
Traverse the list until it won’t get empty using the function empty().
Print the result
Print the result
#include <bits/stdc++.h> 
using namespace std;
int main (){
   list<int> myList;
   int product = 0;
   for (int i=1;i<=10;++i)
   mylist.push_back(i);
   while (!mylist.empty()){
      product *= myList.front();
      myList.pop_front();
   }
   cout << "product of numbers from 1-10 is: " <<product << '\n';
   return 0;
}
If we run the above code it will generate the following output
product of numbers from 1-10 is: 3628800
C# Program to create Pascal’s Triangle

A Pascal’s triangle contains numbers in a triangular form where the edges of the triangle are the number 1 and a number inside the triangle is the sum of the 2 numbers directly above it.
A program that demonstrates the creation of the Pascal’s triangle is given as follows.
 Live Demo
using System;
namespace PascalTriangleDemo {
   class Example {
      public static void Main() {
         int rows = 5, val = 1, blank, i, j;
         Console.WriteLine("Pascal's triangle");
         for(i = 0; i<rows; i++) {
            for(blank = 1; blank <= rows-i; blank++)
            Console.Write(" ");
            for(j = 0; j <= i; j++) {
               if (j == 0||i == 0)
               val = 1;
               else
               val = val*(i-j+1)/j;
               Console.Write(val + " ");
            }
            Console.WriteLine();
         }
      }
   }
}
The output of the above program is as follows.
Pascal's triangle
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Now, let us understand the above program.
The Pascal’s triangle is created using a nested for loop. The outer for loop situates the blanks required for the creation of a row in the triangle and the inner for loop specifies the values that are to be printed to create a Pascal’s triangle. The code snippet for this is given as follows.
for(i = 0; i<rows; i++) {
   for(blank = 1; blank <= rows-i; blank++)
   Console.Write(" ");
   for(j = 0; j <= i; j++) {
      if (j == 0||i == 0)
      val = 1;
      else
      val = val*(i-j+1)/j;
      Console.Write(val + " ");
   }
   Console.WriteLine();
}
GUI application to search a country name from a given state or city name using Python - GeeksforGeeks

04 Dec, 2021
In these articles, we are going to write python scripts to search a country from a given state or city name and bind it with the GUI application. We will be using the GeoPy module. GeoPy modules make it easier to locate the coordinates of addresses, cities, countries, landmarks, and Zipcode.
Before starting we need to install the GeoPy module, so let’s run to this command on your terminal.
pip install geopy
Approach:
Import module
Use Nominatim API to access the corresponding to set of coordinates
geocode() to get the location of a given place
The GUI would look like below:
Note: Nominatim uses OpenStreetMap data to find locations on Earth by name and address (geocoding).
Below is the Implementation:
Python3
from geopy.geocoders import Nominatim  geolocator = Nominatim(user_agent = "geoapiExercises")location = geolocator.geocode("Delhi")print("Country Name: ", location)
Output: 
Country Name:  Delhi, Kotwali Tehsil, Central Delhi, Delhi, 110006, India  
Application for Searching Country from given city/state with Tkinter: This Script implements the above Implementation into a GUI.
Python3
# importing the modulesfrom geopy.geocoders import Nominatimfrom tkinter import *from tkinter import messagebox def getinfo():    geolocator = Nominatim(user_agent = "geoapiExercises")    place = e.get()    place_res.set(place)    location = geolocator.geocode(place)    res.set(location) # object of tkinter# and background set for light greymaster = Tk()master.configure(bg = 'light grey') # variable Classes in tkinterplace_res = StringVar();res = StringVar(); # creating label for each information# name using widget LabelLabel(master, text = "Enter place :" ,      bg = "light grey").grid(row = 0, sticky = W)Label(master, text = "Place :" ,      bg = "light grey").grid(row = 1, sticky = W)Label(master, text = "Country Address :" ,      bg = "light grey").grid(row = 2, sticky = W) # creating label for class variable# name using widget EntryLabel(master, text = "", textvariable = place_res,      bg = "light grey").grid(row = 1, column = 1, sticky = W)Label(master, text = "", textvariable = res,      bg = "light grey").grid(row = 2, column = 1, sticky = W) e = Entry(master)e.grid(row = 0, column = 1) # creating a button using the widget # Button that will call the submit functionb = Button(master, text = "Show", command = getinfo )b.grid(row = 0, column = 2, columnspan = 2,       rowspan = 2, padx = 5, pady = 5) mainloop()
 Output:
abhigoya
nnr223442
Python Tkinter-exercises
Python-tkinter
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Box Plot in Python using Matplotlib
Bar Plot in Matplotlib
Python | Get dictionary keys as a list
Python | Convert set into a list
Ways to filter Pandas DataFrame by column values
Python - Call function from another file
loops in python
Multithreading in Python | Set 2 (Synchronization)
Python Dictionary keys() method
Python Lambda Functions
Plot data from a .txt file using matplotlib

To plot data from .txt file using matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Initialize empty lists for bar_names and bar_heights.
Open a sample .txt file in read "r" mode and append to bar's name and height list.
Make a bar plot.
To display the figure, use show() method.
from matplotlib import pyplot as plt

plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True

bar_names = []
bar_heights = []

for line in open("test_data.txt", "r"):
bar_name, bar_height = line.split()
bar_names.append(bar_name)
bar_heights.append(bar_height)

plt.bar(bar_names, bar_heights)

plt.show()
"test_data.txt" contains the following data −
Javed  12
Raju   14
Rishi  15
Kiran  10
Satish 17
Arun   23
It will produce the following output
C# OverflowException

OverflowException is thrown when the parameter value is out of integer ranges.
Let us see an example.
When we set a value to int.Parse() method that is out of integer range, then OverflowException is thrown as shown below −
 Live Demo
using System;
class Demo {
   static void Main() {
      string str = "757657657657657";
      int res = int.Parse(str);
   }
}
The following error is thrown when the above program is compiled since we have passed a value that is out of integer (Int32) range.
Unhandled Exception:
System.OverflowException: Value was either too large or too small for an Int32.
Difference between ASP and ASP.NET - GeeksforGeeks

02 Feb, 2022
ASP: ASP stands for Active Server Pages. It is a development framework used for building web pages. ASP was introduced in 1998 by Microsoft as its first server-side scripting language. The file extension of ASP pages are .asp and are normally written in VBScript. It is an old but still powerful tool for making dynamic web pages. ASP is a technology (much like PHP) for executing scripts on a web server.Example:  
html
<!DOCTYPE html><html> <body>    <%response.write("Welcome to GeeksforGeeks!")%></body> </html>                   
Output:  
Welcome to GeeksforGeeks!
ASP.NET: ASP.NET was released in 2002 by Microsoft as a successor to ASP. It is also a server-side web framework, open-source, which is designed for the generation of dynamic web pages. The file extension of ASP.NET pages is .aspx and is normally written in C# (C sharp). The latest version of ASP.NET is ASP.NET 4.6.Example: 
csharp
@{    var rank = 50;}<html><body>@if (rank < 60){    <p>Welcome to GeeksforGeeks!</p>}</body></html>
Output:  
Welcome to GeeksforGeeks!
Difference between ASP and ASP.NET:  
 
itskawal2000
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Roadmap to Become a Web Developer in 2022
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to create footer to stay at the bottom of a Web page?
Node.js fs.readFileSync() Method
How to set the default value for an HTML <select> element ?
File uploading in React.js
How to set input type date in dd-mm-yyyy format using HTML ?
Matrix manipulation in Python

In Python we can solve the different matrix manipulations and operations. Numpy Module provides different methods for matrix operations.
add() − add elements of two matrices.
subtract() − subtract elements of two matrices.
divide() − divide elements of two matrices.
multiply() − multiply elements of two matrices.
dot() − It performs matrix multiplication, does not element wise multiplication.
sqrt() −  square root of each element of matrix.
sum(x,axis) − add to all the elements in matrix. Second argument is optional, it is used when we want to compute the column sum if axis is 0 and row sum if axis is 1.
“T” − It performs transpose of the specified matrix.
 Live Demo
import numpy
# Two matrices are initialized by value
x = numpy.array([[1, 2], [4, 5]])
y = numpy.array([[7, 8], [9, 10]])
#  add()is used to add matrices
print ("Addition of two matrices: ")
print (numpy.add(x,y))
# subtract()is used to subtract matrices
print ("Subtraction of two matrices : ")
print (numpy.subtract(x,y))
# divide()is used to divide matrices
print ("Matrix Division : ")
print (numpy.divide(x,y))
print ("Multiplication of two matrices: ")
print (numpy.multiply(x,y))
print ("The product of two matrices : ")
print (numpy.dot(x,y))
print ("square root is : ")
print (numpy.sqrt(x))
print ("The summation of elements : ")
print (numpy.sum(y))
print ("The column wise summation  : ")
print (numpy.sum(y,axis=0))
print ("The row wise summation: ")
print (numpy.sum(y,axis=1))
# using "T" to transpose the matrix
print ("Matrix transposition : ")
print (x.T)
Addition of two matrices: 
[[ 8 10]
 [13 15]]
Subtraction of two matrices :
[[-6 -6]
 [-5 -5]]
Matrix Division :
[[0.14285714 0.25      ]
 [0.44444444 0.5       ]]
Multiplication of two matrices: 
[[ 7 16]
 [36 50]]
The product of two matrices :
[[25 28]
 [73 82]]
square root is :
[[1.         1.41421356]
 [2.         2.23606798]]
The summation of elements :
34
The column wise summation  :
[16 18]
The row wise summation: 
[15 19]
Matrix transposition :
[[1 4]
[2 5]]
Python Tuple min() Method

Python tuple method min() returns the elements from the tuple with minimum value.
Following is the syntax for min() method −
min(tuple)

tuple − This is a tuple from which min valued element to be returned. 
tuple − This is a tuple from which min valued element to be returned. 
This method returns the elements from the tuple with minimum value.
The following example shows the usage of min() method.
#!/usr/bin/python

tuple1, tuple2 = (123, 'xyz', 'zara', 'abc'), (456, 700, 200)
print "min value element : ", min(tuple1)
print "min value element : ", min(tuple2)
When we run above program, it produces following result −
min value element :  123
min value element :  200


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Output of Python Programs | Set 20 (Tuples) - GeeksforGeeks

18 Sep, 2020
Prerequisite : TuplesNote: Output of all these programs is tested on Python3
1. What will be the output of the following program ?
tuple = (1, 2, 3, 4)tuple.append( (5, 6, 7) )print(len(my_tuple))
Options:
125Error
1
2
5
Error
Output:
4. Error
Explanation: In this case an exception will be thrown as tuples are immutable and don’t have an append method.
2. What will be the output of the following program ?
tuple = {}tuple[(1,2,4)] = 8tuple[(4,2,1)] = 10tuple[(1,2)] = 12_sum = 0for k in tuple:    _sum += tuple[k]print(len(tuple) + _sum)
Options:
34123133
34
12
31
33
Output:
4. 33
Explanation: Tuples can be used for keys into dictionary. The tuples can have mixed lengths and the order of the items in the tuple is considered when comparing the equality of the keys.
3. What will be the output of the following program ?
tuple1 = (1, 2, 4, 3)tuple2 = (1, 2, 3, 4)print(tuple1 < tuple2)
Options:
ErrorTrueFalseUnexpected
Error
True
False
Unexpected
Output:
3. False
Explanation: In this case elements will be compared one by one. So, when it compares 4 with 3 it will return False.
4. What will be the output of the following program ?
tuple = (1, 2, 3)print(2 * tuple)
Options:
(1, 2, 3, 1, 2, 3)(1, 2, 3, 4, 5, 6)(3, 6, 9)Error
(1, 2, 3, 1, 2, 3)
(1, 2, 3, 4, 5, 6)
(3, 6, 9)
Error
Output:
1. (1, 2, 3, 1, 2, 3)
Explanation: ‘*’ operator is used to concatenate tuples.
5. What will be the output of the following program ?
tuple=("Check")*3print(tuple)
Options:
Unexpected(3Check)CheckCheckCheckSyntax Error
Unexpected
(3Check)
CheckCheckCheck
Syntax Error
Output:
3. CheckCheckCheck
Explanation: Here “Check” will be treated as is a string not a tuple as there is no comma after the element.
Python-Output
python-tuple
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Output of Java programs | Set 13 (Collections)
Output of Java Program | Set 3
Different ways to copy a string in C/C++
Output of C++ programs | Set 34 (File Handling)
Output of Java program | Set 28
Output of Java Programs | Set 48 (Static keyword)
Runtime Errors
Output of Java Programs | Set 12
Output of Java program | Set 5
Output of Java Program | Set 20 (Inheritance)
TypeScript - Array shift()

shift()method removes the first element from an array and returns that element.
array.shift();

Returns the removed single value of the array.
var arr = [10, 1, 2, 3].shift(); 
console.log("Shifted value is : " + arr );

On compiling, it will generate the same code in JavaScript.
Its output is as follows −
Shifted value is : 10


    45 Lectures 
     4 hours 

 Antonio Papa

    41 Lectures 
     7 hours 

 Haider Malik

    60 Lectures 
     2.5 hours 

 Skillbakerystudios

    77 Lectures 
     8 hours 

 Sean Bradley

    77 Lectures 
     3.5 hours 

 TELCOMA Global

    19 Lectures 
     3 hours 

 Christopher Frewin
 Print
 Add Notes
 Bookmark this page
DateTime.DaysInMonth() Method in C#

The DateTime.DaysInMonth() method in C# is used to return the number of days in the specified month and year. For example, 31 for month value 1 i.e. January.
Following is the syntax −
public static int DaysInMonth (int year, int month);
Let us now see an example to implement the DateTime.DaysInMonth() method −
using System;
public class Demo {
   public static void Main() {
      DateTime date1 = new DateTime(2019, 08, 20, 6, 20, 40);
      DateTime date2 = new DateTime(2019, 06, 20, 6, 20, 40);
      Console.WriteLine("DateTime 1 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", date1);
      Console.WriteLine("Days in DateTime 1 month = "+DateTime.DaysInMonth(2019, 08));
      Console.WriteLine("\nDateTime 2 = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ", date2);
      Console.WriteLine("Days in DateTime 2 month = "+DateTime.DaysInMonth(2019, 06));
      int res = date1.CompareTo(date2);
      // returns >0 since date1 is later than date2
      Console.WriteLine("\nReturn Value (comparison) = "+res);
   }
}
This will produce the following output −
DateTime 1 = 20 August 2019, 06:20:40
Days in DateTime 1 month = 31
DateTime 2 = 20 June 2019, 06:20:40
Days in DateTime 2 month = 30
Return Value (comparison) = 1
Let us now see another example to implement the DateTime.DaysInMonth() method −
using System;
public class Demo {
   public static void Main(){
      int year1 = 2019, year2 = 2016;
      int FebMonth = 2;
      Console.WriteLine("Days in 2019, Feb month = "+DateTime.DaysInMonth(year1, FebMonth));
      Console.WriteLine("Days in 2016, Feb month = "+DateTime.DaysInMonth(year2, FebMonth));
   }
}
This will produce the following output −
Days in 2019, Feb month = 28
Days in 2016, Feb month = 29
BigInteger Class in C#

Use the BigInteger to handle big numbers in C#. The assembly to add for BigInteger is System. Numerics.
In c# Big integer is found in System.Numerics.BigInteger.
The syntax of BigInteger −
[SerializableAttribute]
public struct BigInteger : IFormattable, IComparable, IComparable<BigInteger>, IEquatable<BigInteger>
Let us see an example code snippet −
BigInteger num = BigInteger.Multiply(Int64.MaxValue, Int64.MaxValue);
You can create BigInteger like this −
BigInteger num = new BigInteger(double.MaxValue);
The following are some of its constructors −
How to find the median of all columns in an R data frame?

The median is the value in a vector that divide the data into two equal parts. To find the median of all columns, we can use apply function. For example, if we have a data frame df that contains numerical columns then the median for all the columns can be calculated as apply(df,2,median).
Consider the below data frame −
 Live Demo
set.seed(7)
x1<-rnorm(20,5,1)
x2<-rnorm(20,100,5)
x3<-rnorm(20,100,2)
x4<-rnorm(20,25,3)
x5<-rnorm(20,30,4)
df1<-data.frame(x1,x2,x3,x4,x5)
df1
      x1       x2       x3       x4       x5
1 7.287247 104.19875 102.43710 25.22911 31.37034
2 3.803228 103.52671 98.60137 25.47747 30.01699
3 4.305707 106.52982 99.42913 26.63102 30.11688
4 4.587707 93.06002  97.37689 27.11442 28.42631
5 4.029327 106.36458 99.21798 25.95691 26.82918
6 4.052720 100.92096 99.19695 28.32775 28.75319
7 5.748139 103.76140 102.70104 27.30746 28.61573
8 4.883045 102.95873 101.18238 28.46042 28.78157
9 5.152658 95.08474 100.20105 28.78205 22.85643
10 7.189978 98.61968 101.86214 27.10187 32.34910
11 5.356986 95.64574 99.47452 26.29788 36.54318
12 7.716752 103.59355 99.98466 22.23219 27.41831
13 7.281452 100.55326 100.73431 23.15325 32.47597
14 5.324021 99.60767 103.41433 22.40002 30.94557
15 6.896067 97.89755 101.44748 20.08145 33.38600
16 5.467681 97.18937 100.96207 21.02248 27.70542
17 4.106199 104.98757 96.86426 22.33289 34.47197
18 4.692672 94.47435 100.63650 23.32719 23.84000
19 4.995178 99.28856 100.33198 24.81279 28.24750
20 5.988164 101.57497 98.20018 32.26808 29.39731
Finding the median of all columns in data frame df1 −
apply(df1,2,median)
     x1       x2       x3          x4       x5
5.238339 100.737114 100.266517 25.717187 29.089439
Let’s have a look at another example −
 Live Demo
y1<-sample(1:5,20,replace=TRUE)
y2<-sample(1:2,20,replace=TRUE)
y3<-sample(1:6,20,replace=TRUE)
y4<-sample(1:10,20,replace=TRUE)
df2<-data.frame(y1,y2,y3,y4)
df2
  y1 y2 y3 y4
1  2 2  5  5
2  5 2  3  9
3  2 2  2  10
4  3 2  1  5
5  1 1  1  3
6  1 2  4  3
7  3 1  6  1
8  2 2  5  9
9  2 1  5  1
10 4 2  2  5
11 3 1  6  7
12 5 1  4  9
13 2 2  3  3
14 4 2  1  6
15 2 1  1  7
16 1 2  5  10
17 3 1  4  7
18 2 1  1  6
19 5 2  3  2
20 1 2  6  7
Finding the median of all columns in data frame df2 −
apply(df2,2,median)
 y1  y2  y3 y4
2.0 2.0 3.5 6.0