code-rag-bench/online-tutorials huggingface dataset:
Assembly - Constants

There are several directives provided by NASM that define constants. We have already used the EQU directive in previous chapters. We will particularly discuss three directives −
EQU
%assign
%define
The EQU directive is used for defining constants. The syntax of the EQU directive is as follows −
CONSTANT_NAME EQU expression

For example,
TOTAL_STUDENTS equ 50

You can then use this constant value in your code, like −
mov  ecx,  TOTAL_STUDENTS 
cmp  eax,  TOTAL_STUDENTS
The operand of an EQU statement can be an expression −
LENGTH equ 20
WIDTH  equ 10
AREA   equ length * width
Above code segment would define AREA as 200.
The following example illustrates the use of the EQU directive −
SYS_EXIT  equ 1
SYS_WRITE equ 4
STDIN     equ 0
STDOUT    equ 1
section	 .text
   global _start    ;must be declared for using gcc
	
_start:             ;tell linker entry point
   mov eax, SYS_WRITE         
   mov ebx, STDOUT         
   mov ecx, msg1         
   mov edx, len1 
   int 0x80                
	
   mov eax, SYS_WRITE         
   mov ebx, STDOUT         
   mov ecx, msg2         
   mov edx, len2 
   int 0x80 
	
   mov eax, SYS_WRITE         
   mov ebx, STDOUT         
   mov ecx, msg3         
   mov edx, len3 
   int 0x80
   
   mov eax,SYS_EXIT    ;system call number (sys_exit)
   int 0x80            ;call kernel

section	 .data
msg1 db	'Hello, programmers!',0xA,0xD 	
len1 equ $ - msg1			

msg2 db 'Welcome to the world of,', 0xA,0xD 
len2 equ $ - msg2 

msg3 db 'Linux assembly programming! '
len3 equ $- msg3
When the above code is compiled and executed, it produces the following result −
Hello, programmers!
Welcome to the world of,
Linux assembly programming!

The %assign directive can be used to define numeric constants like the EQU directive. This directive allows redefinition. For example, you may define the constant TOTAL as −
%assign TOTAL 10

Later in the code, you can redefine it as −
%assign  TOTAL  20

This directive is case-sensitive.
The %define directive allows defining both numeric and string constants. This directive is similar to the #define in C. For example, you may define the constant PTR as −
%define PTR [EBP+4]

The above code replaces PTR by [EBP+4].
This directive also allows redefinition and it is case-sensitive.

    46 Lectures 
     2 hours 

 Frahaan Hussain

    23 Lectures 
     12 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Write a Golang program to find the sum of digits for a given number

num = 125 => 1 + 2 + 5 = 8
num = 101 => 1 + 0 + 1 = 2
num = 151 => 1 + 5 + 1 = 7
Step 1: Define a function that accepts numbers(num); type is int.
Step 2: Start a true loop until num becomes 0 and define res:=0.
Step 3: Find modulo and add to res.
Step 4: Divide num by 10.
Step 5: Return res.
Live Demo
package main
import "fmt"
func findDigitSum(num int) int {
   res := 0
   for num>0 {
      res += num % 10
      num /= 10
   }
   return res
}

func main(){
   fmt.Println(findDigitSum(168))
   fmt.Println(findDigitSum(576))
   fmt.Println(findDigitSum(12345))
}
15
18
15
How to change the font and size of buttons and frame in tkinter?

Tkinter Button Widgets are a general way to provide Event Handling in a variety of applications. Sometimes, we may need to style the buttons which are defined in an application. In order to add styling in the button widgets, first create an instance of Button widget using a variable. Then, add some property like fontfamily, font-size, padding, etc. into it. The most general way to resize the button is by resizing the text in it.
In this example, we have created a button that can be resized by changing the value in the 'font' property.
#Import tkinter library
from tkinter import *
#Create an instance of tkinter frame
win= Tk()
#Set the Geometry
win.geometry("750x250")
def click_to_close():
win.destroy()
#Create a Button
button= Button(win, text= "Click to Close", font= ('Helvetica 20
bold italic'), command=click_to_close)
button.pack(pady=20)
win.mainloop()
Running the given code will generate a button with some text in it which can be resized by changing the value of the font-size.
PostgreSQL – Connecting to the database using Python

30 Aug, 2020
PostgreSQL API for Python allows user to interact with the PostgreSQL database using the psycopg2 module. In this article we will look into the process of connecting to a PostgreSQL database using Python.
First we will need to install the psycopg2 module with the below command in the command prompt:
pip install psycopg2

For the purpose of example we will be needing a sample database. To create so, follow the below steps:
First open a PostgreSQL client tool like pgadmin4 or psql.
Second login to the database using your credentials.
Finally use the below command to create a database (say, School)
CREATE DATABASE school;

To connect to the above created database (ie, school), we use the connect () function. The connect() function is used to create a new database session and it returns a new connection class instance.
To do so use the below syntax:
Syntax: conn = psycopg2.connect("dbname=suppliers user=postgres password=postgres")

To make it convenient to use you can use the below method:
1. First create a database.ini file with the credentials as shown below:
[postgresql]
host=localhost
database=school
user=postgres
password=5555

Now, the following config() function reads the database.ini file and returns connection parameters. The same config() function is added in the config.py file:
Python3
#!/usr/bin/pythonfrom configparser import ConfigParser    def config(filename='database.ini', section='postgresql'):    # create a parser    parser = ConfigParser()    # read config file    parser.read(filename)      # get section, default to postgresql    db = {}    if parser.has_section(section):        params = parser.items(section)        for param in params:            db[param[0]] = param[1]    else:        raise Exception('Section {0} not found in the {1} file'.format(section, filename))      return db
Example:
The following connect() function connects to the school database that we created earlier and returns  the PostgreSQL database version.
Python3
#!/usr/bin/pythonimport psycopg2from config import config  def connect():    """ Connect to the PostgreSQL database server """    conn = None    try:        # read connection parameters        params = config()          # connect to the PostgreSQL server        print('Connecting to the PostgreSQL database...')        conn = psycopg2.connect(**params)                  # create a cursor        cur = conn.cursor()              # execute a statement        print('PostgreSQL database version:')        cur.execute('SELECT version()')          # display the PostgreSQL database server version        db_version = cur.fetchone()        print(db_version)             # close the communication with the PostgreSQL        cur.close()    except (Exception, psycopg2.DatabaseError) as error:        print(error)    finally:        if conn is not None:            conn.close()            print('Database connection closed.')    if __name__ == '__main__':    connect()
Output:
postgreSQL-administration
postgreSQL-managing-database
PostgreSQL
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Getting union of sets in Julia – union() and union!() Methods

26 Mar, 2020
The union() is an inbuilt function in julia which is used to construct the union of the specified sets.
Syntax: union(s, itrs...)
Parameters:
s: Specified first set.
itrs: Specified second set.
Returns: It returns the constructed union of the specified sets.
Example:
# Julia program to illustrate # the use of union() method   # Getting the constructed union of the specified sets.println(union([5, 10], [15, 20]))println(union([2, 4], [2, 4, 6]))println(union([1, 3], 5:7))println(union(Set([2, 4, 6]), 1:5))
Output:
[5, 10, 15, 20]
[2, 4, 6]
[1, 3, 5, 6, 7]
[4, 2, 6, 1, 3, 5]
The union!() is an inbuilt function in julia which is used to construct the union of passed in sets and overwrite s with the result.
Syntax:union!(s::Union{AbstractSet, AbstractVector}, itrs...)
Parameters:
s: Specified set.
itrs: Specified iterator.
Returns: It returns the constructed union of passed in sets and overwrite s with the result.
Example:
# Julia program to illustrate # the use of union !() method   # Getting constructed union of passed # in sets and overwrite s with the result.s1 = Set([1, 2, 3, 4]);union !(s1, 5:7:9);println(s1)  s2 = Set([1, 2, 3, 4]);union !(s2, 1:2:3);println(s2)
Output:
Set([4, 2, 3, 5, 1])
Set([4, 2, 3, 1])
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Binary list to integer

21 Feb, 2019
The problem being discussed in this article is quite common that every programmer would have come across it. Conversion of binary number list to its integer value can be done using shorthands and knowledge of them can prove to be quite useful. Let’s discuss certain ways in which this can be done.
Method #1 : Using join() + list comprehensionThe combination of these two function can help to achieve this particular task. In this method, the entire list is first converted to string and then type conversion into int and then binary number is obtained.
# Python3 code to demonstrate # converting binary list to integer # using join() + list comprehension  # initializing list test_list = [1, 0, 0, 1, 1, 0]  # printing original listprint ("The original list is : " + str(test_list))  # using join() + list comprehension# converting binary list to integer res = int("".join(str(x) for x in test_list), 2)  # printing result print ("The converted integer value is : " +  str(res))
Output :
The original list is : [1, 0, 0, 1, 1, 0]
The converted integer value is : 38

 
Method #2 : Using bit shift + | operatorThis particular task can be performed by shifting the bits and taking the | with each of the bits being processed. This is yet another elegant way in which this can be performed.
# Python3 code to demonstrate # converting binary list to integer # using bit shift + | operator  # initializing list test_list = [1, 0, 0, 1, 1, 0]  # printing original listprint ("The original list is : " + str(test_list))  # using bit shift + | operator# converting binary list to integer res = 0for ele in test_list:    res = (res << 1) | ele  # printing result print ("The converted integer value is : " +  str(res))
Output :
The original list is : [1, 0, 0, 1, 1, 0]
The converted integer value is : 38

Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Convert Decimal to String in Python - GeeksforGeeks

28 Jul, 2020
Python defines type conversion functions to directly convert one data type to another. This article is aimed at providing the information about converting decimal to string.
str() method can be used to convert decimal to string in Python.
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.
Example 1:
Python3
from decimal import Decimal  dec = Decimal(10)print(dec, type(dec))  # Converting to stringdec = str(dec)print(dec, type(dec))
Output:
10 <class 'decimal.Decimal'>
10 <class 'str'>
Example 2:
Python3
from decimal import Decimal    dec = Decimal("0.01")print(dec, type(dec))  # Converting decimal to strings = str(dec)print(s, type(dec))
Output:
0.01 <class 'decimal.Decimal'>
0.01 <class 'decimal.Decimal'>
python-basics
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Defaultdict in Python
Python OOPs Concepts
Python | os.path.join() method
Python | Pandas dataframe.groupby()
Angular10 isPlatformServer() Function - GeeksforGeeks

02 Jun, 2021
In this article, we are going to see what is isPlatformServer in Angular 10 and how to use it.
The isPlatformServer is used to get a platform id that represents a server platform
Syntax:
isPlatformServer(platformId);
NgModule: Module used by isPlatformServer is:
CommonModule
Return Value: returns a Boolean Value stating whether a platform id represents a server platform.
Approach: 
Create the angular app to be used
Import isPlatformServer from @angular/core to the project.
In app.component.ts define the object which holds the Boolean value.
serve the angular app using ng serve to see the output
Example 1:
app.component.ts
import { Component, Inject } from '@angular/core';import { PLATFORM_ID } from '@angular/core';import { isPlatformServer }from '@angular/common';  @Component({  selector: 'app-root',  templateUrl: './app.component.html',  styleUrls: [ './app.component.css' ]})export class AppComponent  {    isServer: boolean;        constructor( @Inject(PLATFORM_ID) platformId: Object) {      this.isServer = isPlatformServer(platformId);      console.log(this.isServer);    }    }
Output:
Example 2:
app.component.ts
import { Component, Inject } from '@angular/core';import { PLATFORM_ID } from '@angular/core';import { isPlatformServer } from '@angular/common';  @Component({  selector: 'app-root',  templateUrl: './app.component.html',  styleUrls: [ './app.component.css' ]})export class AppComponent  {    isServer: boolean;        constructor( @Inject(PLATFORM_ID) platformId: Object) {      this.isServer = isPlatformServer(platformId);    }    }
”>app.component.html”
<div *ngIf = 'isServer==false'>  platform id does not represents a server platform.</div>
Output:
Reference: https://angular.io/api/common/isPlatformServer
Angular10
AngularJS-Function
AngularJS
Misc
Web Technologies
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Angular PrimeNG Calendar Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Angular PrimeNG Messages Component
vector::push_back() and vector::pop_back() in C++ STL
Top 10 algorithms in Interview Questions
Overview of Data Structures | Set 1 (Linear Data Structures)
How to write Regular Expressions?
Minimax Algorithm in Game Theory | Set 3 (Tic-Tac-Toe AI - Finding optimal move)
How to get a list of parameter names inside Python function?

To extract the number and names of the arguments from a function or function[something] to return ("arg1", "arg2"), we use the inspect module.
The given code is written as follows using inspect module to find the parameters inside the functions aMethod and foo.
import inspect
def aMethod(arg1, arg2): pass
print(inspect.getargspec(aMethod))
def foo(a,b,c=4, *arglist, **keywords): pass
print(inspect.getargspec(foo))
ArgSpec(args=['arg1', 'arg2'], varargs=None, keywords=None, defaults=None)
ArgSpec(args=['a', 'b', 'c'], varargs='arglist', keywords='keywords', defaults=(4,))
Finding the End Index of the Specified Range in C# - GeeksforGeeks

28 Jun, 2021
The Range Structure is introduced in C# 8.0. It represents a range that has a start and end indexes. You are allowed to find the end index of the given ranges with the help of End Property provided by the Range struct.Syntax:  
public property Index End { Index get(); };
Here, Index represents the end index.Example 1: 
CSharp
// C# program to illustrate the use// of End property of Range structusing System; namespace range_example { class Program {     static void Main(string[] args)    {         // Creating range        // using Range Constructor        var r1 = new Range(0, 5);         // Creating range        // using range operator        Range r2 = 3..7;         // Finding the last index        // of r1 and r2 ranges        // Using End property        var res1 = r1.End;        Console.WriteLine("End index of r1 range: " + res1);         var res2 = r2.End;        Console.WriteLine("End index of r2 range: " + res2);    }}}
Output: 
End index of r1 range: 5
End index of r2 range: 7
Example 2: 
CSharp
// C# program to illustrate how to use// End property of Range structureusing System; namespace range_example { class GFG {     // Main Method    static void Main(string[] args)    {        // Creating and initializing an array        string[] arr = new string[8] {"Archery", "Badminton", "Cricket",             "Bowling", "Boxing", "Curling", "Tennis", "Skateboarding"};         // Creating ranges        // Using Range(Index, Index)        // Constructor        var r1 = new Range(0, 3);        var r2 = new Range(4, 7);         // Finding the last index        // of the specified range        // Using End property        var res1 = r1.End;        var res2 = r2.End;        Console.WriteLine("End Index of Range {0} is {1}"+             " and the item is {2}", r1, res1, arr[res1]);         Console.WriteLine("End Index of Range {0} is {1} and"+                     " the item is {2}", r2, res2, arr[res2]);    }}}
Output: 
End Index of Range 0..3 is 3 and the item is Bowling
End Index of Range 4..7 is 7 and the item is Skateboarding
 
saurabh1990aror
CSharp-8.0
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C# Dictionary with examples
C# | Method Overriding
C# | Class and Object
C# | Constructors
C# | String.IndexOf( ) Method | Set - 1
Extension Method in C#
C# | Delegates
Introduction to .NET Framework
C# | Data Types
Difference between Ref and Out keywords in C#
Divide Two Integers in C++

Suppose we have two integers dividend and divisor. We have to divide two integers without using multiplication, division, and mod operator. Return the quotient after dividing the dividend by divisor. The integer division should truncate toward zero. Both of the inputs are integers
So if the given inputs are dividend = 7, divisor = -3, then output will be -2.
To solve this, we will follow these steps −
Taking two arguments x and y it indicates x divides y
if x < -Infinity and y = 1, then return infinity
a := |x|, b := |y| and ans := 0
while a – b >= 0p := 0while a – (left shifted b (left shifted 1 p times)) >= 0p := p + 1a := a – (left shift b, p times)ans := ans + left shift 1 p times
p := 0
while a – (left shifted b (left shifted 1 p times)) >= 0p := p + 1
p := p + 1
a := a – (left shift b, p times)
ans := ans + left shift 1 p times
if x > 0 is true and y > 0 is also true, then return ans, otherwise return (– ans)
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
class Solution {
public:
   int divide(int l, int y) {
      if(l <= INT_MIN && y == -1)return INT_MAX;
      lli a = labs(l);
      lli b = labs(y);
      lli ans = 0;
      while(a-b >= 0){
         int x = 0;
         while(a-(b << 1 << x) >= 0){
            x++;
         }
         a -= b<<x;
         ans += 1<<x;
      }
      return (l>0)== (y>0)?ans:-ans;
   }
};
main(){
   Solution ob;
   cout << ob.divide(40, 3);
}
40
3
13
Difference between collection and collections in java

Java collection framework is used to manipulate the collection of the object. Collection framework contains multiple wrapper classes , convenience class , classes for legacy implementation like vector and Hashtable, collection interfaces and etc.    
Collection is an interface in the java collection framework. It is divided into two parts −
Java util collection - It contains classes such as Set , queue , List and etc.
Java util map - It contains classes such as Map , sortedMap and etc.
On the other hand , Collections is the one the utility class. Main purpose of this class is to provide convenience method to the developers. This class has only static methods that operate on and return collection. The methods of this class all throw a NullPointerException if the collections or class objects provided to them are null.
1
Basic 
 It is an interface in Java collection framework 
It is a utility class in Collection framework 
2
Static Methods 
It doesn't has all static methods 
It has all static method 
3
Operation 
It is used to store list of object in a single object  
It is used to operate on collection.
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class Main {
   public static void main(String[] args) {
      // List
      List list = new ArrayList();
      list.add("HCL");
      list.add("DELL");
      // Sorting List in ascending order according to the natural ordering
      Collections.sort(list);
      list.forEach(System.out::println);
   }
}
Trapezoidal Rule for definite integral

Definite integrals can be solved using this trapezoidal rule. To integrate a function f(x) between the range a to b is basically finding the area below the curve from point x = a to x = b. 
To find that area, we can divide the area into n trapezoids, and the width of each trapezoid is h, so we can say that (b - a) = nh. When the number of trapezoids increases, the result of area calculation will be more accurate. To solve integrals, we will follow this formula.
Here h is the width of the interval, and n is the number of intervals. We can find the h by using 
Input:
The function f(x): 1-exp(-x/2.0) and limits of the integration: 0, 1. The number of intervals: 20
Output:
The answer is: 0.21302
integrateTrapezoidal(a, b, n)
Input: Lower and upper limit, and the number of integrals n.
Output: The result of integration.
Begin
   h := (b - a)/n
   sum := f(a) + f(b)
   for i := 1 to n, do
      sum := sum + f(a + ih)
   done
   return sum
End
#include<iostream>
#include<cmath>
using namespace std;

float mathFunc(float x) {
   return (1-exp(-x/2.0));    //the function 1 - e^(-x/2)
}

float integrate(float a, float b, int n) {
   float h, sum;
   int i;
   h = (b-a)/n;    //calculate the distance between two interval
   sum = (mathFunc(a)+mathFunc(b))/2;    //initial sum using f(a) and f(b)

   for(i = 1; i<n; i++) {
      sum += mathFunc(a+i*h);
   }
   return (h*sum);    //The result of integration
}

main() {
   float result, lowLim, upLim;
   int interval;
   cout << "Enter Lower Limit, Upper Limit and interval: "; cin >>lowLim >>upLim >>interval;
   result = integrate(lowLim, upLim, interval);
   cout << "The answer is: " << result;
}
Enter Lower Limit, Upper Limit and interval: 0 1 20
The answer is: 0.21302
QlikView - Data Transformation

Data Transformation is the process of modifying the existing data to a new data format. It can also involve filtering out or adding some specific values to the existing data set. QlikView can carry out data transformation after reading it to its memory and using many in-built functions.  
Let us consider the following input data, which represents the sales figures of each month. This is stored as a csv file with name quarterly_sales.csv
Month,SalesVolume
March,2145
April,2458
May,1245
Sales Values in Q2
June,5124
July,7421
August,2584
Sales Values in Q3
September,5314
October,7846
November,6532
December,4625
January,8547
February,3265

The above data is loaded to QlikView memory by using the script editor. Open the Script editor from the File menu or press Control+E. Choose the "Table Files" option form the "Data from Files" tab and browse for the file quarterlt_sales.csv. Click next.
The next screen prompts us to choose some data transformation. Click on the button Enable Transformation Step.
In this step, we will select the transformation to eliminate the rows, which describe the quarter. We select Garbage → delete marked and select the two rows, which are not required. Click Next.
After selecting the type of Transformation and the rows to be removed, the next screen prompts us for any further transformation like selecting a where clause or adding any Prefixes. We will ignore this step and click Finish.
The Load script for the above data after all the transformation steps are complete is given
below.
The transformed data can be displayed by using a Table Box sheet object. The steps to create it are given below.
Next, we choose the fields for the Table Box.
The Table Box now displays the data in the sheet.

    70 Lectures 
     5 hours 

 Arthur Fong
 Print
 Add Notes
 Bookmark this page
Difference between Natural join and Cross join in SQL

03 May, 2020
1. Natural Join :Natural Join joins two tables based on same attribute name and datatypes. The resulting table will contain all the attributes of both the tables but only one copy of each common column.
Example:Consider the two tables given below:
Consider the given query
SELECT * 
FROM Student S NATURAL JOIN Marks M;
Output :
2. Cross Join :Cross Join will produce cross or Cartesian product of two tables if there is no condition specifies. The resulting table will contain all the attributes of both the tables including duplicate or common columns also.
Example:Consider the above two tables and the query is given below:
SELECT * 
FROM Student S CROSS JOIN Marks M; 
Output:
Difference between Natural JOIN and CROSS JOIN in SQL
DBMS-Join
DBMS
Difference Between
GATE CS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Timestamp.today

27 Jan, 2019
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 Timestamp.today() function return the current time in the local timezone. This differs from datetime.today() in that it can be localized to a passed timezone.
Syntax :Timestamp.today(cls, tz=None)
Parameters :tz : Timezone to localize to
Return : today’s time
Example #1: Use Timestamp.today() function to return the current time in the local timezone.
# importing pandas as pdimport pandas as pd  # Create the Timestamp objectts = pd.Timestamp(year = 2011,  month = 11, day = 21,                   hour = 10, second = 49, tz = 'US/Central')   # Print the Timestamp objectprint(ts)
Output :
Now we will use the Timestamp.today() function to return the current time in the local timezone.
# return current timets.today()
Output :
As we can see in the output, the Timestamp.today() function has returned the current time in the local timezone.
Example #2: Use Timestamp.today() function to return the current time in the local timezone.
# importing pandas as pdimport pandas as pd  # Create the Timestamp objectts = pd.Timestamp(year = 2009, month = 5, day = 31,                   hour = 4, second = 49, tz = 'Europe/Berlin')  # Print the Timestamp objectprint(ts)
Output :
Now we will use the Timestamp.today() function to return the current time in the local timezone.
# return current timets.today()
Output :
As we can see in the output, the Timestamp.today() function has returned the current time in the local timezone.
Python Pandas-Timestamp
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
Create a Table in a PDF Using Java

04 Nov, 2020
The creation of a table in a PDF using Java is done by installing the document class. While instantiating this class, pass a PdfDocument object as a parameter to its constructor. Then, to feature a table to the document, instantiate the Table class, and add this object to the document using the add() method.
Note: External jar files are required to perform operations on PDF.
Below is an example PDF adding a table in a pdf using java with all the steps:
Java
// Adding table in a pdf using javaimport com.itextpdf.kernel.pdf.PdfDocument;import com.itextpdf.kernel.pdf.PdfWriter;  import com.itextpdf.layout.Document;import com.itextpdf.layout.element.Cell;import com.itextpdf.layout.element.Table;  public class AddingTableToPDF {    public static void main(String args[]) throws Exception    {        String file            = "C:/EXAMPLES/itextExamples/addingTableToPDF.pdf";          // Step-1 Creating a PdfDocument object        PdfDocument pdfDoc            = new PdfDocument(new PdfWriter(file));          // Step-2 Creating a Document object        Document doc = new Document(pdfDoc);          // Step-3 Creating a table        Table table = new Table(2);          // Step-4 Adding cells to the table        table.addCell(new Cell().add("Name"));        table.addCell(new Cell().add("Raju"));        table.addCell(new Cell().add("Id"));        table.addCell(new Cell().add("1001"));        table.addCell(new Cell().add("Designation"));        table.addCell(new Cell().add("Programmer"));          // Step-6 Adding Table to document        doc.add(table);          // Step-7 Closing the document        doc.close();        System.out.println("Table created successfully..");    }}
Output:
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala Map filter() method with example

13 Aug, 2019
The filter() method is utilized to select all elements of the map which satisfies a stated predicate.
Method Definition: def filter(p: ((A, B))=> Boolean): Map[A, B]
Return Type: It returns a new map consisting all the elements of the map which satisfies the given predicate.
Example #1:
// Scala program of filter()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Creating map        val m1 = Map("geeks" -> 5, "for" -> 3)                  // Applying filter method        val result = m1.filter(x => x._1 == "geeks" && x._2 == 5)                  // Displays output        println(result)          }}
Map(geeks -> 5)

Example #2:
// Scala program of filter()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Creating map        val m1 = Map("geeks" -> 5, "for" -> 3)                  // Applying filter method        val result = m1.filter(x => x._1 == "for" && x._2 == 5)                  // Displays output        println(result)          }}
Map()

Here, an empty map is returned as none of the elements satisfy the stated predicate.
Scala
Scala-Map
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Class and Object in Scala
Scala Lists
Scala Constructors
Operators in Scala
Scala | Arrays
How to Install Scala with VSCode?
Inheritance in Scala
Enumeration in Scala
Scala | Option
Break statement in Scala
ios eof() function in C++ with Examples

02 Sep, 2019
The eof() method of ios class in C++ is used to check if the stream is has raised any EOF (End Of File) error. It means that this function will check if this stream has its eofbit set.
Syntax:
bool eof() const;

Parameters: This method does not accept any parameter.
Return Value: This method returns true if the stream has eofbit set, else false.
Example 1:
// C++ code to demonstrate// the working of eof() function  #include <bits/stdc++.h>using namespace std;  int main(){      // Stream    stringstream ss;      // Using eof() function    bool isEOF = ss.eof();      // print result    cout << "is stream eof: "         << isEOF << endl;      return 0;}
is stream eof: 0

Example 2:
// C++ code to demonstrate// the working of eof() function  #include <bits/stdc++.h>using namespace std;  int main(){      // Stream    stringstream ss;    ss.clear(ss.eofbit);      // Using eof() function    bool isEOF = ss.eof();      // print result    cout << "is stream eof: "         << isEOF << endl;      return 0;}
is stream eof: 1

Reference: hhttp://www.cplusplus.com/reference/ios/ios/eof/
CPP-Functions
cpp-ios
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Add an object to the end of Collection<T>

01 Feb, 2019
Collection<T>.Add(T) method is used to add an object to the end of the Collection<T>.
Syntax :
public void Add (T item);

Here, item is the object to be added to the end of the Collection<T>. The value can be null for reference types.
Below given are some examples to understand the implementation in a better way:
Example 1:
// C# code to add an object to// the end of the Collectionusing System;using System.Collections.Generic;using System.Collections.ObjectModel;  class GFG {      // Driver code    public static void Main()    {        // Creating a collection of strings        Collection<string> myColl = new Collection<string>();          myColl.Add("A");        myColl.Add("B");        myColl.Add("C");        myColl.Add("D");        myColl.Add("E");          // Displaying the number of elements in Collection        Console.WriteLine("The number of elements in myColl are : "                                                    + myColl.Count);          // Displaying the elements in Collection        Console.WriteLine("The elements in myColl are : ");          foreach(string str in myColl)        {            Console.WriteLine(str);        }    }}
Output:
The number of elements in myColl are : 5
The elements in myColl are : 
A
B
C
D
E

Example 2:
// C# code to add an object to// the end of the Collectionusing System;using System.Collections.Generic;using System.Collections.ObjectModel;  class GFG {      // Driver code    public static void Main()    {        // Creating a collection of ints        Collection<int> myColl = new Collection<int>();          myColl.Add(2);        myColl.Add(3);        myColl.Add(4);        myColl.Add(5);          // Displaying the number of elements in Collection        Console.WriteLine("The number of elements in myColl are : "                                                   + myColl.Count);          // Displaying the elements in Collection        Console.WriteLine("The elements in myColl are : ");          foreach(int i in myColl)        {            Console.WriteLine(i);        }    }}
Output:
The number of elements in myColl are : 4
The elements in myColl are : 
2
3
4
5

Note:
Collection<T> accepts null as a valid value for reference types and allows duplicate elements.
This method is an O(1) operation.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.collection-1.add?view=netframework-4.7.2
CSharp-Collection-Class
CSharp-Collections.ObjectModel-Namespace
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
Extension Method in C#
C# | List Class
C# | .NET Framework (Basic Architecture and Component Stack)
HashSet in C# with Examples
Lambda Expressions in C#
Switch Statement in C#
Partial Classes in C#
Hello World in C#
Software Testing | Functional Testing

08 May, 2019
Functional Testing is a type of Software Testing in which the system is tested against the functional requirements and specifications. Functional testing ensures that the requirements or specifications are properly satisfied by the application. This type of testing is particularly concerned with the result of processing. It focuses on simulation of actual system usage but does not develop any system structure assumptions.
It is basically defined as a type of testing which verifies that each function of the software application works in conformance with the requirement and specification. This testing is not concerned about the source code of the application. Each functionality of the software application is tested by providing appropriate test input, expecting the output and comparing the actual output with the expected output. This testing focuses on checking of user interface, APIs, database, security, client or server application and functionality of the Application Under Test.
Functional testing can be manual or automated.
Functional Testing Process:Functional testing involves the following steps:
Identify function that is to be performed.Create input data based on the specifications of function.Determine the output based on the specifications of function.Execute the test case.Compare the actual and expected output.
Identify function that is to be performed.
Create input data based on the specifications of function.
Determine the output based on the specifications of function.
Execute the test case.
Compare the actual and expected output.
Major Functional Testing Techniques:
Unit Testing
Integration Testing
Smoke Testing
User Acceptance Testing
Interface Testing
Usability Testing
System Testing
Regression Testing
Functional Testing Tools:
1. Selenium
2. QTP
3. JUnit
4. SoapUI
5. Watir 
Advantages of Functional Testing:
It ensures to deliver a bug-free product.
It ensures to deliver a high-quality product.
No assumptions about the structure of the system.
This testing is focused on the specifications as per the customer usage.
Disadvantages of Functional Testing:
There are high chances of performing redundant testing.
Logical errors can be missed out in the product.
If the requirement is not complete then performing this testing becomes difficult.
Software Testing
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Groovy - toString()

The method is used to get a String object representing the value of the Number Object.
If the method takes a primitive data type as an argument, then the String object representing the primitive data type value is returned.
If the method takes two arguments, then a String representation of the first argument in the radix specified by the second argument will be returned.
String toString() 
static String toString(int i)

i − An int for which string representation would be returned.
toString() − This returns a String object representing the value of this Integer.
toString() − This returns a String object representing the value of this Integer.
toString(int i) − This returns a String object representing the specified integer.
toString(int i) − This returns a String object representing the specified integer.
Following is an example of the usage of this method −
class Example { 
   static void main(String[] args) { 
      Integer x = 5;
		
      System.out.println(x.toString()); 
      System.out.println(Integer.toString(12)); 
   } 
}
When we run the above program, we will get the following result −
5 
12 


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
Solid Gauge Chart in Pygal - GeeksforGeeks

10 Jul, 2020
Pygal is a Python module that is mainly used to build SVG (Scalar Vector Graphics) graphs and charts. SVG is a vector-based graphics in the XML format that can be edited in any editor. Pygal can create graphs with minimal lines of code that can be easy to understand and write.
Gauges are the popular charts which help for dashboards, they anticipate a number in a range at a glance. It can use colored bands, hands, and combinations to display multiple values and their relation to a numeric scale.
Syntax:
gauge = pygal.SolidGauge()

Example 1:
Python3
# importing pygalimport pygal  # creating the chart objectSolid_Gauge = pygal.SolidGauge(inner_radius = 0.75)  # naming the titleSolid_Gauge.title = 'Solid Gauge Chart'       # Random dataSolid_Gauge.add('A', [{'value': 1000, 'max_value': 5000}])Solid_Gauge.add('B', [{'value': 12, 'max_value': 20}])Solid_Gauge.add('C', [{'value': 99, 'max_value': 100}])  Solid_Gauge
Output:
Example 2:
Python3
# importing pygalimport pygal  # creating the chart objectSolid_Gauge = pygal.SolidGauge(inner_radius = 0.75,                                half_pie = True)  # naming the titleSolid_Gauge.title = 'Solid Gauge Chart'       # Random dataSolid_Gauge.add('A', [{'value': 1000, 'max_value': 5000}])Solid_Gauge.add('B', [{'value': 12, 'max_value': 20}])Solid_Gauge.add('C', [{'value': 99, 'max_value': 100}])  Solid_Gauge
Output:
Data Visualization
Python pygal-chart
Python-pygal
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Difference between Abstract Class and Interface in C# - GeeksforGeeks

28 Jan, 2022
An abstract class is a way to achieve the abstraction in C#. An Abstract class is never intended to be instantiated directly. This class must contain at least one abstract method, which is marked by the keyword or modifier abstract in the class definition. The Abstract classes are typically used to define a base class in the class hierarchy.
Example:
// C# program to illustrate the// concept of abstract classusing System;  // abstract class 'G'public abstract class G {      // abstract method 'gfg1()'    public abstract void gfg1();}  // class 'G' inherit// in child class 'G1'public class G1 : G {      // abstract method 'gfg1()'    // declare here with    // 'override' keyword    public override void gfg1()    {        Console.WriteLine("Class name is G1");    }}  // class 'G' inherit in// another child class 'G2'public class G2 : G {      // same as the previous class    public override void gfg1()    {        Console.WriteLine("Class name is  G2");    }}  // Driver Classpublic class main_method {      // Main Method    public static void Main()    {          // 'obj' is object of class        // 'G' class '        // G' cannot        // be instantiate        G obj;          // instantiate class 'G1'        obj = new G1();          // call 'gfg1()' of class 'G1'        obj.gfg1();          // instantiate class 'G2'        obj = new G2();          // call 'gfg1()' of class 'G2'        obj.gfg1();    }}
Output :
Class name is G1
Class name is  G2

Like a class, Interface can have methods, properties, events, and indexers as its members. But interfaces will contain only the declaration of the members. The implementation of interface’s members will be given by the class who implements the interface implicitly or explicitly.
Example:
// C# program to illustrate the// concept of interfaceusing System;  // A simple interfaceinterface interface1 {      // method having only declaration    // not definition    void show();}  // A class that implements the interface.class MyClass : interface1 {      // providing the body part of function    public void show()    {        Console.WriteLine("Welcome to GeeksforGeeks!!!");    }      // Main Method    public static void Main(String[] args)    {          // Creating object        MyClass obj1 = new MyClass();          // calling method        obj1.show();    }}
Output:
Welcome to GeeksforGeeks!!!
beki914
CSharp-Interfaces
CSharp-OOP
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
C# Dictionary with examples
C# | String.IndexOf( ) Method | Set - 1
Extension Method in C#
C# | Delegates
Introduction to .NET Framework
C# | Data Types
HashSet in C# with Examples
C# | Replace() Method
Different ways to sort an array in descending order in C#
Basic CRUD (Create, Read, Update, Delete) in ASP.NET MVC Using C# and Entity Framework
C++ Program to Delete the First Node in a given Singly Linked List

A linked list is a linear data structure that has multiple nodes that are connected with each other. Each node consists of two fields – Data Field and the address of the next node.
Let us assume we have a singly linked list and we need to delete the first node from this linked list. For example,
Input 1 − 4 → 3 → 2 → 1
Output − 3 → 2 → 1 →
Explanation − ‘4’ is the first node in the given singly linked list. After deleting the first node, the linked list will be 3→2→1.
Input 2 − 1 → 2 → 3 →
Output − 2 → 3 →
Explanation − After deleting the first node ‘1’, the linked list will be 2 → 3.
Initially, we have a linked list that consists of nodes. Each node contains the data and address to the next node. After inserting the data in the linked list, we will create a function to delete the first node.
Thus, we will create a temporary pointer that initially points to the head and move the head to the next node. Now delete the temporary node and return the linked list.
A function deleteAthead(node*&head) takes the pointer to the head and deletes the first node of the linked list.
A function deleteAthead(node*&head) takes the pointer to the head and deletes the first node of the linked list.
Create a temporary pointer that initially points to the head.
Create a temporary pointer that initially points to the head.
Head moves to the next node.
Head moves to the next node.
Delete the temporary pointer.
Delete the temporary pointer.
Return the linked list.
Return the linked list.
#include<iostream>
using namespace std;
int main(){
class node{
   public:
      int data;
      node*next;
      node(int d){
         data=d;
         node*next=NULL;
      }
};
void insertAtFirstNode(node*&head, int data){
   node*n= new node(data);
   n->next= head;
   head=n;
}
void print(node*head){
   while(head!=NULL){
      cout<<head->data<<"->";
      head=head->next;
   }
   cout<<endl;
}
void deleteAtFirst(node*&head){
   if(head==NULL){
      return;
   }
   node*temp=head;
   head= head->next;
   delete temp;
   return;
}
int main(){
   node*head= NULL;
   insertAtFirstNode(head,1);
   insertAtFirstNode(head,2);
   insertAtFirstNode(head,3);
   insertAtFirstNode(head,4);
   deleteAtFirst(head);
   print(head);
}
Running the above code will generate the output as,
3 → 2 → 1 →
Since the given singly linked list is 4 → 3 → 2 → 1 →, after deleting the first node which is 4, the linked list will become, 3 → 2 → 1 →