code-rag-bench/online-tutorials huggingface dataset:
Python 3 - Assignment Operators Example

Assume variable a holds the value 10 and variable b holds the value 20, then −
Assume variable a holds the value 10 and variable b holds the value 20, then −
#!/usr/bin/python3

a = 21
b = 10
c = 0

c = a + b
print ("Line 1 - Value of c is ", c)

c += a
print ("Line 2 - Value of c is ", c )

c *= a
print ("Line 3 - Value of c is ", c )

c /= a 
print ("Line 4 - Value of c is ", c )

c  = 2
c %= a
print ("Line 5 - Value of c is ", c)

c **= a
print ("Line 6 - Value of c is ", c)

c //= a
print ("Line 7 - Value of c is ", c)

When you execute the above program, it produces the following result −
Line 1 - Value of c is  31
Line 2 - Value of c is  52
Line 3 - Value of c is  1092
Line 4 - Value of c is  52.0
Line 5 - Value of c is  2
Line 6 - Value of c is  2097152
Line 7 - Value of c is  99864


    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
2's complement notation

This is one of the methods of representing signed integers in the computer. In this method, the most significant digit (MSD) takes on extra meaning.
If the MSD is a 0, we can evaluate the number just as we would any normal unsigned integer.
If the MSD is a 1, this indicates that the number is negative.
The other bits indicate the magnitude (absolute value) of the number.
If the number is negative, the other bits signify the 2'scomplement of the magnitude of the number.
Thus a positive number has the same representation in SM, 1's complement, and 2's complement notations. Only negative numbers are represented differently in these notations. Somesigneddecimal numbers and their equivalent in 2's complement notation is shown below, assuming a word size of 4 bits.
Notice that there is a single notation for 0, immaterial of whether it is +0 or –0. One may feel that 0 000 is +0 only, as the MSB, in this case, is a 0. But then, the notation for –0 should be the 2's complement of 0 000, which is1111 + 1 = 0 000 ignoring the carry.
Thus, in 2's complement, notation an extra negative number can be represented compared with SignedMagnitudeor 1's complement notation. This is because, in 2's complement notation, there is only a single notation for zero, whereas in SM and 1's complement notations there are two notations for 0.
If the word size is n bits, the range of numbers that can be represented is from -(2n-1) to  +(2n-1 -1). A table of word size and the range of 2's complement numbers that can be represented is shown next.
 
Example 1 − Add the numbers (+5) and (-3) using a computer. The numbers assumed to be represented using 4-bit 2's complement notation.
             1101 <- carry generated during addition             0101 <- (+5)           + 1101 <-(-3)             0010 <- (+2) Sum
             1101 <- carry generated during addition
             0101 <- (+5)
           + 1101 <-(-3)
             0010 <- (+2) Sum
So in this method, that the computer straightaway gives the correct answer of +2 = 0010.
2's complement notation is not very simple to understand because it is very much different from the conventional way of representing signed numbers.
2's complement notation is not very simple to understand because it is very much different from the conventional way of representing signed numbers.
There is a single notation for zero, which is very convenient when the computer wants to test for a 0 result.
There is a single notation for zero, which is very convenient when the computer wants to test for a 0 result.
 It is very convenient for the computer to perform arithmetic. The addition operation straightaway gives the correct result.
 It is very convenient for the computer to perform arithmetic. The addition operation straightaway gives the correct result.
Hence, 2's complement notation is generally used to represent signed numbers inside a computer.
Draw Black Spiral Pattern Using Turtle in Python - GeeksforGeeks

01 Oct, 2020
Prerequisite: Turtle Programming in Python
“Turtle” is a Python feature like a drawing board, which lets us command a turtle to draw all over it. This module comes packed with the standard Python package and need not be installed externally.
forward(value): It moves the turtle in forward direction.
speed(value): It changes the speed of the turtle.
left(value): It moves the turtle towards the left.
In this article, we will discuss how to draw a Black Spiral Pattern Using Turtle Graphics.
Approach:
Import turtle
Initialize the variable.
Initialize the turtle.
Start making the pattern according to your logic.
Below is the implementation of the above approach.
Python3
# import turtleimport turtle  # initialising variablesdist = 1flag = 500  # initialising turtlespiral = turtle.Turtle()  # changing speed of turtlespiral.speed(10)  # making pattenwhile flag:        # makes the turtle to move forward    spiral.forward(dist)          # makes the turtle to move left    spiral.left(120)    spiral.left(1)    dist += 1    flag -= 1  turtle.done()
Output:
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Python - Convert Dictionary values to Absolute Magnitude - GeeksforGeeks

13 Dec, 2021
Given a dictionary, convert its values to absolute.
Input : test_dict = {“Gfg” : -5, “is” : -7, “Best” : -2} Output : {“Gfg” : 5, “is” : 7, “Best” : 2} Explanation : All negative elements changed to positive with same magnitude
Input : test_dict = {“Gfg” : -8, “is” : 7, “Best” : -2} Output : {“Gfg” : 8, “is” : 7, “Best” : 2} Explanation : All negative elements changed to positive with same magnitude  
Method #1 : Using loop + abs()
This is one of the ways in which this task can be performed. In this, we iterate for each value of dictionary using loop and perform the absolute magnitude conversion using abs().
Python3
# Python3 code to demonstrate working of# Convert Dictionary values to Absolute Magnitude# Using loop + abs() # initializing dictionarytest_dict = {"Gfg" : 5, "is" : -7, "Best" : 2, "for" : -9, "geeks" : -8} # printing original dictionaryprint("The original dictionary is : " + str(test_dict)) # using abs() to perform conversion# from negative to positive valuesfor ele in test_dict:    test_dict[ele] = abs(test_dict[ele]) # printing resultprint("Dictionary after absolute conversion : " + str(test_dict))
The original dictionary is : {'Gfg': 5, 'is': -7, 'Best': 2, 'for': -9, 'geeks': -8}
Dictionary after absolute conversion : {'Gfg': 5, 'is': 7, 'Best': 2, 'for': 9, 'geeks': 8}
Method #2 : Using dictionary comprehension + abs()
This task is similar to above method. The difference being dictionary comprehension is used instead of loop to perform the task of iteration through keys.
Python3
# Python3 code to demonstrate working of# Convert Dictionary values to Absolute Magnitude# Using dictionary comprehension + abs() # initializing dictionarytest_dict = {"Gfg" : 5, "is" : -7, "Best" : 2, "for" : -9, "geeks" : -8} # printing original dictionaryprint("The original dictionary is : " + str(test_dict)) # dictionary comprehension using to compile result# items() used to extract dictionary keys and values.res = {key : abs(val) for key, val in test_dict.items()} # printing resultprint("Dictionary after absolute conversion : " + str(res))
The original dictionary is : {'Gfg': 5, 'is': -7, 'Best': 2, 'for': -9, 'geeks': -8}
Dictionary after absolute conversion : {'Gfg': 5, 'is': 7, 'Best': 2, 'for': 9, 'geeks': 8}
surindertarika1234
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Arrays copyOf() in Java with examples - GeeksforGeeks

07 Dec, 2018
java.util.Arrays.copyOf() method is in java.util.Arrays class. It copies the specified array, truncating or padding with false (if necessary) so the copy has the specified length.
Syntax:
 copyOf(int[] original, int newLength) 
original – original array
newLength – copy of original array
// Java program to illustrate copyof methodimport java.util.Arrays;  public class Main{    public static void main(String args[])    {        // initializing an array original        int[] org = new int[] {1, 2 ,3};          System.out.println("Original Array");        for (int i = 0; i < org.length; i++)            System.out.print(org[i] + " ");          // copying array org to copy        int[] copy = Arrays.copyOf(org, 5);          // Changing some elements of copy        copy[3] = 11;        copy[4] = 55;          System.out.println("\nNew array copy after modifications:");        for (int i = 0; i < copy.length; i++)            System.out.print(copy[i] + " ");    }}
Output:
Original Array
1 2 3 
New array copy after modifications:
1 2 3 11 55 

What happens if length of copied array is greater than original array?The two arrays will have same values for all the indices that are valid in original array and new array.However, the indices missing in original will have zero in copy in case the copied array length is more than the original array.
// Java program to illustrate copyOf when new array// is of higher length.import java.util.Arrays;  public class Main {  public static void main(String args[])   {      // initializing an array original      int[] org = new int[] {1, 2 ,3};           System.out.println("Original Array : \n");      for (int i = 0; i < org.length; i++)           System.out.print(org[i] + " ");                 // copying array org to copy        // Here, new array has 5 elements - two       // elements more than the original array       int[] copy = Arrays.copyOf(org, 5);           System.out.print("\nNew array copy (of higher length):\n");       for (int i = 0; i < copy.length; i++)            System.out.print(copy[i] + " ");    }}
Output:
Original Array : 
1 2 3 
New array copy (of higher length):
1 2 3 0 0 

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Java - util package
Java-Arrays
Java-Collections
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Stream In Java
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Speech To Text using IBM Watson Studio

19 Feb, 2020
IBM Watson Studio is an integrated environment designed to develop, train, manage models, and deploy AI-powered applications and is a Software as a Service (SaaS) solution delivered on the IBM Cloud. The IBM Cloud provides lots of services like Speech To Text, Text To Speech, Visual Recognition, Natural Language Classifier, Language Translator, etc.
The Speech to Text service transcribes audio to text to enable speech transcription capabilities for applications.
Go to the Speech to Text page in the IBM Cloud Catalog.Sign up for a free IBM Cloud account or log in.Click Create.
Go to the Speech to Text page in the IBM Cloud Catalog.
Sign up for a free IBM Cloud account or log in.
Click Create.
From the IBM Cloud Resource list, click on your Speech to Text service instance to go to the Speech to Text service dashboard page.On the Manage page, click Show Credentials to view your credentials.Copy the API Key and URL values.
From the IBM Cloud Resource list, click on your Speech to Text service instance to go to the Speech to Text service dashboard page.
On the Manage page, click Show Credentials to view your credentials.
Copy the API Key and URL values.
Module Needed:
Jsonibm_watson: This module does not comes pre-defined with Python. To install it type the below command in the terminal.pip install ibm_watson

Json
ibm_watson: This module does not comes pre-defined with Python. To install it type the below command in the terminal.pip install ibm_watson

pip install ibm_watson

Now you’re ready to use the IBM Cloud Services.
Below code illustrates the use of IBM Watson studio’s Speech To Text Service using Python and web socket interface
#Python Program To Use IBM Watson# Studio's Speech To Text Below Code# Accepts only .mp3 Format of Audio# File      import jsonfrom os.path import join, dirnamefrom ibm_watson import SpeechToTextV1from ibm_watson.websocket import RecognizeCallback, AudioSourcefrom ibm_cloud_sdk_core.authenticators import IAMAuthenticator     # Insert API Key in place of # 'YOUR UNIQUE API KEY'authenticator = IAMAuthenticator('YOUR UNIQUE API KEY') service = SpeechToTextV1(authenticator = authenticator)   #Insert URL in place of 'API_URL' service.set_service_url('API_URL')   # Insert local mp3 file path in# place of 'LOCAL FILE PATH' with open(join(dirname('__file__'), r'LOCAL FILE PATH'),           'rb') as audio_file:              dic = json.loads(                json.dumps(                    service.recognize(                        audio=audio_file,                        content_type='audio/flac',                           model='en-US_NarrowbandModel',                    continuous=True).get_result(), indent=2))  # Stores the transcribed textstr = ""  while bool(dic.get('results')):    str = dic.get('results').pop().get('alternatives').pop().get('transcript')+str[:]       print(str)
Output
The Output will be Transcript (Text) of audio file.

python-utility
Technical Scripter 2019
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Program for Coin Change

In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given N coins and we want to make a change of those coins such that, there is an infinite supply of each value in S. we need to display that in how many ways we can make the change irrespective of order.
We will use the concept of dynamic programming to solve the problem statement to reduce the time complexity.
Now let’s observe the solution in the implementation below −
# dynamic approach
def count(S, m, n):
   # base case
   table = [[0 for x in range(m)] for x in range(n+1)]
   # for n=0
   for i in range(m):
      table[0][i] = 1
   # rest values are filled in bottom up manner
   for i in range(1, n+1):
      for j in range(m):
         # solutions including S[j]
         x = table[i - S[j]][j] if i-S[j] >= 0 else 0
         # solutions excluding S[j]
         y = table[i][j-1] if j >= 1 else 0
         # total
         table[i][j] = x + y
   return table[n][m-1]
# main
arr = [1, 3, 2, 4]
m = len(arr)
n = 5
print(“Number of coins:”,end=””)
print(count(arr, m, n))
Number of coins:6
All the variables are declared in the local scope and their references are seen in the figure above.
In this article, we have learned about how we can make a Python Program for Coin Change
How to convert JSON object to Hashtable format using PowerShell?

PowerShell 7 supports the -AsHashtable parameter in the ConvertFrom−JSON command to convert the JSON to hashtable directly and that is a great feature. Consider we have the below JSON file,
We can use the pipeline command ConvertFrom−JSON to convert the JSON file to the custom table format and with the −AsHashtable parameter to convert the custom object to the hashtable.
PS C:\Temp> Get-Content .\testsevent.json | ConvertFrom-Json -AsHashtable
Name Value
---- -----
Events {602d9444−d2cd−49c7−8624−8643e7171297}
DocumentIncarnation 0
To retrieve the data,
PS C:\Temp> $out = Get−Content .\testsevent.json | ConvertFrom−Json −AsHashtable
PS C:\Temp> $out.Events
PS C:\Temp> $out.Events
Name Value
---- -----
Description Host server is undergoing maintenance.
EventStatus Scheduled
EventId 602d9444−d2cd−49c7−8624−8643e7171297
For the PowerShell framework version, −AsHashTable parameter is not supported and in that case, you need to convert it to the hashtable manually as shown below.
$out = Get−Content .\testsevent.json | ConvertFrom−Json
Code to convert JSON to Hashtable,
$hash = @{}
$out.psobject.properties | foreach{$hash[$_.Name]= $_.Value}
$hash
Swap two variables in one line using C#

To swap two variables in a single line using the Bitwise XOR Operator.
val1 = val1 ^ val2 ^ (val2 = val1);
Above, we have set the values −
int val1 = 30;
int val2 = 60;
The following is the example to swap both the variable in one line using C# −
using System;

class Demo {

   public static void Main(String[] args) {
      int val1 = 30;
      int val2 = 60;

      Console.WriteLine("Values before swap");
      Console.WriteLine(val1);
      Console.WriteLine(val2);

      val1 = val1 ^ val2 ^ (val2 = val1);

      Console.WriteLine("Values after swap");
      Console.WriteLine(val1);
      Console.WriteLine(val2);
   }
}
GATE | GATE CS 2011 | Question 46 - GeeksforGeeks

15 Oct, 2019
Database table by name Loan_Records is given below.
Borrower    Bank_Manager   Loan_Amount
 Ramesh      Sunderajan     10000.00
 Suresh      Ramgopal       5000.00
 Mahesh      Sunderajan     7000.00
What is the output of the following SQL query?
SELECT Count(*) 
FROM  ( ( SELECT Borrower, Bank_Manager 
          FROM Loan_Records) AS S 
          NATURAL JOIN ( SELECT Bank_Manager, Loan_Amount 
                         FROM Loan_Records) AS T );
(A) 3(B) 9(C) 5(D) 6Answer: (C)Explanation:
See Question 3 of https://www.geeksforgeeks.org/database-management-systems-set-4/
Quiz of this Question
GATE-CS-2011
GATE-GATE CS 2011
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2014-(Set-1) | Question 65
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE CS 2012 | Question 40
C++ Program to count Vowels in a string using Pointer
Why is the Main() method use in C# static?

The Main method states what the class does when executed and instantiates other objects and variables.
A main method is static since it is available to run when the C# program starts. It is the entry point of the program and runs without even creating an instance of the class.
The following shows how to add a Main() method with static −
 Live Demo
using System;

namespace Demo {
   class HelloWorld {
      static void Main(string[] args) {

         Console.WriteLine("Bingo!");
         Console.ReadKey();
      }
   }
}
Bingo!
As you can see in the above example −
static void Main(string[] args) {
Here,
static − the object is not needed to access static members
static − the object is not needed to access static members
void − return type of the method
void − return type of the method
Main − entry point for any C# program. Program execution begins here.
Main − entry point for any C# program. Program execution begins here.
string[] args −  for command line arguments in C#.
string[] args −  for command line arguments in C#.
How to create and use Global Variable in swift

As per the Apple document – “Global variables are variables that are defined outside of any function, method, closure, or type context
Before we learn how to create global variables, first let us understand completely what are they.
Consider “W” which is inside the inner circle, can access everything which will be inside the inner circle. On the other hand, A can access everything
which is inside the outer circle as well as everything inside the inner circle, so the scope of “A” is global as he can access both the circles.
So a global variable can access everything inside the bigger and inner circle.
Now we will see how one can declare or create Global Variable. When we define a class or a struct we can define global variables.
Now we will be seeing how to declare a global variable. We will be using the Playground.
So let’s get started, Xcode → File → Playground
class Student {
   var section: String = "A"
   func getStudentData() {
      // some function
   }
}
Here you can see section is a global variable we have defined, inside a class but outside a function. We can use an access modifier prefixed with the global variable as per the need.
You can also define a global variables as static by prefixing static keyword.
private var name: String = "Aman"
There’s another and efficient way to create and store global variable is using a struct, you should always create a struct and encapsulate all the global variable inside it and can use in any class wherever we want., Let’s see how we can do it.
struct Student {
   static let name: String="Aman"
   static let age: Int = 22
}
class Employee {
   func getData() {
      print(Student.age)
      print(Student.name)
   }
}
This is how we can create global variables in swift.
SQL Query to Rename Stored Procedure - GeeksforGeeks

28 Oct, 2021
Stored Procedure is a saved SQL code. It is created to save time as we can use it again and again without writing the whole query. In this article, we will see how to Rename a Stored Procedure. 
Syntax:
CREATE PROCEDURE procedure_name AS 
SELECT * FROM table_name;
SQL query whose procedure needs to be created is always written after the AS statement.
Syntax:
EXEC procedure_name;
We can perform the above action by two methods. Those methods are:
By using sp_rename statement in SQL Server.
From Object Explorer in SQL Server Management Studio(SSMS).
For demonstration follow the below steps:
Step 1: Create a database
The database can be created using CREATE command.
Query:
CREATE DATABASE geeks;
Step 2: Using a database
Use the below SQL statement to switch the database context to geeks:
Query:
USE geeks;
Step 3:  Table definition
We have the following demo_table in our geek’s database.
Query:
CREATE TABLE demo_table(
NAME VARCHAR(20),
AGE INT,
CITY VARCHAR(20) );
Step 4: Insert data into a table
Query:
INSERT INTO demo_table VALUES
('ROMY KUMARI', 22, 'NEW DELHI'),
('RINKLE ARORA',23, 'PUNJAB'),
('AKANKSHA GUPTA',22, 'PUNJAB'),
('SUJATA JHA', 30,'PATNA'),
('PREETI GIRI', 26,'BANGLORE'),
('PREM GUPTA',31,'PUNE');
Output:
Step 5: Create procedure
We will create a procedure called ‘Display‘ to view all the content of the table.
Query:
CREATE PROCEDURE Display AS  
SELECT * FROM demo_table;
Output:
Step 6: Rename Procedure
Method 1: using sp_rename
Syntax:
EXEC sp_rename 'Current procedure_name', 'New procedure_name';
For demonstration let’s rename the procedure name from ‘Display’ to ‘Show’.
Query:
EXEC sp_rename 'Display', 'Show';
Execute:
EXEC Show;
Output:
Method 2: From Object Explorer
Step 1: Open object Explorer from View option in the menu bar. It appears on the left side of the screen.
We can see the ‘geeks’ database inside the database folder.
Step 2: Expand the Programmability folder inside the geek’s database. Then expand the Stored procedure folder
Step 3: Right-click on the procedure created and select the ‘Rename’ option.
Step 4: Type the name with which you want to rename the procedure
In these two ways, we can rename the stored procedure.
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
SQL | DROP, TRUNCATE
How to Select Data Between Two Dates and Times in SQL Server?
SQL vs NoSQL: Which one is better to use?
Advanced SQL Interview Questions
SQL | OFFSET-FETCH Clause
Insert multiple values into multiple tables using a single statement in SQL Server
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Comments
SQL | CREATE
Adding multiple constraints in a single table
domainname Command in Linux With Examples - GeeksforGeeks

24 Jun, 2019
domainname command in Linux is used to return the Network Information System (NIS) domain name of the host. You can use hostname -d command as well to get the host domainname. If the domain name is not set up in your host then the response will be “none”.In the networking terminology, the domain name is the mapping of IP with the name. Domain names are registered in the DNS server in case of a local network. If the DNS server is not present you can put the entry in /etc/hosts file to map IP address with the domain name.
Syntax:
domainname [options]
Options:
domainname -h : It is used to display all the options and syntax of the command.domainname -h
domainname -h
domainname -a or –alias : It is used to display the alias name. Returns blank line if alias name is not set up.domainname -a
domainname -a
domainname -A or –all-fqdns : It is used to display all the fully qualified domain names (FQDN).domainname -A
domainname -A
domainname -b or –boot : Used to set default domainname if none available.domainname -b allinoneIn the below example, you can see initially ‘none’ domainname was returned but after setting up command returns the new name.
domainname -b allinone
In the below example, you can see initially ‘none’ domainname was returned but after setting up command returns the new name.
domainname -s or –short : Displays the short hostname.domainname -s
domainname -s
domainname -I or –all-ip-addresses : Used to displays all IP addresses assigned to the host, use ip -a command to check IP addresses.domainname -I
domainname -I
domainname -i or –ip-address : Displays the localhost address.domainname -i
domainname -i
domainname -y or –yp or –nis : Displays the Network Information System (NIS) domain name.domainname -yIn this example you can see, the displayed domain name is the same as we set up using -b option.
domainname -y
In this example you can see, the displayed domain name is the same as we set up using -b option.
Other Useful Options:
-d, –domain Displays the domain name of DNS.
-f, –fqdn, –long Long hostname fully qualified domain name(FQDN).
-F, –file Read hostname or NIS domain name from given file.
linux-command
Linux-networking-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
ZIP command in Linux with examples
SORT command in Linux/Unix with examples
tar command in Linux with examples
UDP Server-Client implementation in C
curl command in Linux with Examples
Conditional Statements | Shell Script
diff command in Linux with examples
echo command in Linux with Examples
Mutex lock for Linux Thread Synchronization
Data Structures | Queue | Question 1 - GeeksforGeeks

08 Jan, 2013
Following is C like pseudo code of a function that takes a Queue as an argument, and uses a stack S to do processing.
void fun(Queue *Q){    Stack S;  // Say it creates an empty stack S      // Run while Q is not empty    while (!isEmpty(Q))    {        // deQueue an item from Q and push the dequeued item to S        push(&S, deQueue(Q));    }      // Run while Stack S is not empty    while (!isEmpty(&S))    {      // Pop an item from S and enqueue the poppped item to Q      enQueue(Q, pop(&S));    }}
What does the above function do in general?(A) Removes the last from Q(B) Keeps the Q same as it was before the call(C) Makes Q empty(D) Reverses the QAnswer: (D)Explanation: The function takes a queue Q as an argument. It dequeues all items of Q and pushes them to a stack S. Then pops all items of S and enqueues the items back to Q. Since stack is LIFO order, all items of queue are reversed.
Data Structures
Data Structures-Queue
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Introduction to Data Structures | 10 most commonly used Data Structures
Data Structures | Array | Question 2
Multilevel Linked List
Difference between data type and data structure
Bit manipulation | Swap Endianness of a number
Program to create Custom Vector Class in C++
Count of triplets in an Array (i, j, k) such that i < j < k and a[k] < a[i] < a[j]
Johnson’s algorithm for All-pairs shortest paths | Implementation
Binary Search Tree | Set 3 (Iterative Delete)
Data Structures | Stack | Question 3
Lodash _.extend() Method - GeeksforGeeks

18 Sep, 2020
The _.extend() method is like the _.assign() method except that it iterates over its own and inherited source properties. 
Syntax:
_.extend(object, sources)

Parameters: This method accepts two parameters as mentioned above and described below:
object: This parameter holds the destination object.
sources: This parameter holds the source objects.
Return Value: This method returns an object.
Example 1:
Javascript
// Defining Lodash variable const _ = require('lodash');   function Gfg() { this.a = 5; }   function GFG() { this.c = 10; }   Gfg.prototype.b = 15; GFG.prototype.d = 20;   // Calling _.extend() methjod console.log(_.extend( { a: 4 },     new Gfg, new GFG));
Output:
{ a: 5, b: 15, c: 10, d: 20 }

Example 2:
Javascript
// Defining Lodash variable const _ = require('lodash');   function Gfg() { this.a = 5; }   function GFG() { this.c = 10; }   // Calling _.extend() method console.log(_.extend( { a: 4 },     new Gfg, new GFG));
Output:
{ a: 5, c: 10 }

Note: This will not work in normal JavaScript because it requires the lodash library to be installed.
JavaScript-Lodash
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
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 calculate the number of days between two dates in javascript?
File uploading in React.js
How to append HTML code to a div using JavaScript ?
Hide or show elements in HTML using display property
How to Open URL in New Tab using JavaScript ?
Difference Between PUT and PATCH Request
Laravel | Installation and Configuration - GeeksforGeeks

05 Oct, 2021
Laravel is a PHP framework that makes building complex web applications a cakewalk. In this guide you are going to learn how to Install and Configure Laravel and get your first Laravel project running in your computer. 
Prerequisites: 
Basic knowledge of PHP
PHP Installation
Basic knowledge of Terminal/Command Prompt
Steps to install Laravel:  
Laravel actually uses a dependency manager tool called Composer to install all required libraries to run Laravel. So before we move forward make sure that composer is installed in your system. You can easily install Composer from here. It is well documented and after installation run the below given command in your terminal/command prompt: 
composer
If it gives an output like given below then it means the installation was successful and we can go to the next step. 
Next step is to create a folder where we are going to create our new Laravel Project. After moving to that folder just run this composer command to create a new Laravel Project. 
composer create-project --prefer-dist laravel/laravel my-first-laravel-project
Here, create-project is a composer command which is just downloading the package and installing all the dependencies further needed by this package and then we have this –prefer-dist which means just prefer the stable version releases if possible, next we mention name of package which is laravel/laravel and my-first-laravel-project is actually the name of project folder and you can replace it with any name that you want. This will start the installation of all dependencies as given in the image below. 
If everything went well then end of this script will look like this: 
Now you have a new folder called my-first-laravel-project and move to that folder. You will notice that inside this folder a lot of files and folders are already present, this is actually the Laravel framework itself. In this folder, run the command given below to start the in-build PHP server. 
php artisan serve
This will give an output like given below: 
Note: The link really depends on your system, it can be http://localhost:8000 also.
Copy this link and open it in your browser to see your Laravel app (In my case it is http://127.0.0.1:8000). It will look like this: 
 
anikakapoor
how-to-install
Laravel
How To
Installation Guide
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Align Text in HTML?
How to Install FFmpeg on Windows?
Java Tutorial
How to Install Jupyter Notebook on MacOS?
How to Install Python Pandas on MacOS?
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Install OpenCV for Python on Windows?
How to Install Jupyter Notebook on MacOS?
How to Install Python Pandas on MacOS?
How to use ComboBox in ReactJS?

18 Jan, 2021
A Combo Box is a graphical user interface widget that is commonly used. The application requires a Combo box from which the user can select the options. Material UI for React has this component available for us and it is very easy to integrate.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command:
npm install @material-ui/core
npm install @material-ui/lab
Project Structure: It will look like the following.
Project Structure
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from 'react'import TextField from '@material-ui/core/TextField';import Autocomplete from '@material-ui/lab/Autocomplete';  const App = () => {    // Our sample dropdown options  const options = ['Monday', 'Tuesday', 'Thursday',   'Friday', 'Saturday', 'Sunday']    return (    <div style={{marginLeft:'40%', marginTop: '60px'}}>      <h3>Greetings from GeeksforGeeks!</h3>      <Autocomplete        options={options}        style={{ width: 300 }}        renderInput={(params) =>          <TextField {...params} label="Combo box" variant="outlined" />}      />    </div>  );}  export default App
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
JavaScript
ReactJS
Technical Scripter
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PHP | random_bytes () Function

14 Apr, 2022
The random_bytes()is an inbuilt function in PHP. The main function is to generate cryptographically secure pseudo-random bytes. It generates cryptographic random bytes of arbitrary string length. The different sources of randomness used in this function, they are as follows:-
Window : CryptGenRandom() function.
Linux : getrandom(2) system call function.
Syntax :
String random_bytes ( int $length )
Parameter : It is the length of random string, returned in bytes. Return Value: The function returns the cryptographically secure random bytes in string. Examples:
Input : length = 7
Output :string(14) "cbd392c01352b0"
Below programs illustrate the random_bytes () function in PHP. Program 1: 
php
<?php//random_bytes () function in PHP$length = random_bytes('4'); //Print the result and convert by binaryhexavar_dump(bin2hex($length));?>
string(8) "e62a94a2"
php
<?php//random_bytes () function in PHP$length = random_bytes('6'); //Print the result and convert by binaryhexavar_dump(bin2hex($length));?>
string(12) "808fc44d325b"
Exception Error :
Invalid parameter will give TypeError .
Invalid length of bytes gives Error.
If source of randomness is not found then Exception will be thrown.
References: http://php.net/manual/en/function.random-bytes.php
sumitgumber28
PHP
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | sympy.Float() method

14 Jul, 2019
With the help of sympy.Float() method, we can convert the integer values to floating point values and by using this method we can also set the values of precision. By default value of precision is 15.
Syntax : sympy.Float()Return : Return the floating point number.
Example #1 :In this example we can see that by using sympy.Float() method, we can convert the integer value to floating point values with precision.
# import sympyfrom sympy import *  # Use sympy.Float() methodgfg = Float(56)    print(gfg)
Output :
56.0000000000000
Example #2 :
# import sympyfrom sympy import *  # Use sympy.Float() methodgfg = Float(456, 6)    print(gfg)
Output :
456.000
SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install Selenium in Python?

28 Jan, 2022
Selenium Scripts are built to do some tedious tasks which can be automated using headless web browsers.For example, Searching for some Questions on Different Search engines and storing results in a file by visiting each link. This task can take a long for a normal human being but with the help of selenium scripts one can easily do itNow, Some of You may be wondering what is headless web browsers. It’s nothing but a browser that can be controlled using these selenium scripts for automation(web tasks). Selenium Scripts can be programmed using various languages such as JavaScript, Java, Python, etc.How to Use selenium with Python and Linux Environment.Python should already be installed. It can be 2.* or 3.* version. Steps:  
Installing Selenium  Installing Webdrivers (headless)  Creating Simple Code  
Installing Selenium  
Installing Webdrivers (headless)  
Creating Simple Code  
 
Whatever Operating System You are Using Python command is Same for Installing Selenium Library.First MethodOpen Terminal/Cmd and Write Command as written Below 
python -m pip install selenium
Second MethodAlternatively, you can download the source distribution here, unarchive it, and run the command below:  
python setup.py install
 
One Can Install Firefox, Chromium, PhantomJs(Deprecated Now), etc.  
for using Firefox you may need to install GeckoDriver  
for using Chrome you may need to install Chromium  
In this article, Firefox is used so One can Follow the Below Steps to Install:-Steps for Linux:-1. Go to the geckodriver releases page. Find the latest version of the driver for your platform and download it. For example:  
wget https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
2. Extract the file with:  
tar -xvzf geckodriver*
3. Make it executable:  
chmod +x geckodriver
4. Move Files to usr/local/bin  
sudo mv geckodriver /usr/local/bin/
Steps for Windows:-1. Same as Step 1 in Linux Download the GeckoDriver2. Extract it using WinRar or any application you may have.3. Add it to Path using Command Prompt 
setx path "%path%;GeckoDriver Path"
For Example:-  
setx path "%path%;c:/user/eliote/Desktop/geckodriver-v0.26.0-win64/geckodriver.exe"
 
 
Python3
# Python program to demonstrate# selenium  from selenium import webdriver  driver = webdriver.Firefox()driver.get("https://google.co.in")
Output: 
 
adnanirshad158
how-to-install
python-modules
How To
Installation Guide
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scala - Function with Variable Arguments

Scala allows you to indicate that the last parameter to a function may be repeated. This allows clients to pass variable length argument lists to the function. Here, the type of args inside the print Strings function, which is declared as type "String*" is actually Array[String].
Try the following program, it is a simple example to show the function with arguments.
object Demo {
   def main(args: Array[String]) {
      printStrings("Hello", "Scala", "Python");
   }
   
   def printStrings( args:String* ) = {
      var i : Int = 0;
      
      for( arg <- args ){
         println("Arg value[" + i + "] = " + arg );
         i = i + 1;
      }
   }
}
Save the above program in Demo.scala. The following commands are used to compile and execute this program.
\>scalac Demo.scala
\>scala Demo

Arg value[0] = Hello
Arg value[1] = Scala
Arg value[2] = Python


    82 Lectures 
     7 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    76 Lectures 
     5.5 hours 

 Bigdata Engineer

    69 Lectures 
     7.5 hours 

 Bigdata Engineer

    46 Lectures 
     4.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
Get class from an object in Java

The runtime class of an object can be obtained using the java.lang.Object.getClass(). Also, the getName() method is used to get the name of the class.
A program that demonstrates getting the class of an object using the getClass() method is given as follows −
 Live Demo
public class Demo {
   public static void main (String [] args) {
      Integer integer = new Integer(10);
      Class c = integer.getClass();
      System.out.println ("The class is: " + c.getName());
      c = new Demo().getClass();
      System.out.println ("The class is: " + c.getName());
   }
}
The class is: java.lang.Integer
The class is: Demo
Now let us understand the above program.
First a new Integer is created. Then the getClass() method is used to obtain the runtime class. Finally the getName() method is used to get the name of the class i.e. java.lang.Integer and print it. A code snippet which demonstrates this is as follows −
Integer integer = new Integer(10);
Class c = integer.getClass();
System.out.println ("The class is: " + c.getName());
After this, the getClass() method is used to obtain the runtime class of an object of Demo. Then the getName() method is used to get the name of the class i.e. Demo and print it. A code snippet which demonstrates this is as follows −
c = new Demo().getClass();
System.out.println ("The class is: " + c.getName());
How to change current directory using Python?

You can change directory or cd in Python using the os module. It takes as input the relative/absolute path of the directory you want to switch to.
>>> import os
>>> os.chdir('my_folder')
Python program to find number of local variables in a function - GeeksforGeeks

10 Jan, 2019
Given a Python program, task is to find the number of local variables present in a function.
Examples:
Input : a = 1
        b = 2.1
        str = 'GeeksForGeeks'
    
Output : 3

We can use the co_nlocals() function which returns the number of local variables used by the function to get the desired result.
Code #1:
# Implementation of above approach  # A function containing 3 variables def fun():    a = 1    str = 'GeeksForGeeks'    # Driver programprint(fun.__code__.co_nlocals)
2

 Code #2:
# Python program to find number of# local variables in a function  # A function containing no variables def geek():    pass  # A function containing 3 variables def fun():    a, b, c = 1, 2.25, 333    str = 'GeeksForGeeks'  # Driver programprint(geek.__code__.co_nlocals)print(fun.__code__.co_nlocals)
0
4

Python function-programs
Python
Python Programs
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
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Binary Search (Recursive and Iterative)
Python | Split string into list of characters
How to get the id after INSERT into MySQL database using Python?

The data is inserted into the table in Mysql using the INSERT statement. While inserting the data into the table, either the data must be provided in the same order as the column definition in the database or the column names must be provided along with the data while using INSERT statement.
To get and print the ID of the last inserted row, lastrowid is used. This is a special keyword which is used to get the ID of the last inserted row. There are certain prerequisites to be taken care of before using this method.
The ID column must be the primary key in the table.
The ID column must be the primary key in the table.
The ID column must be auto-incremented.
The ID column must be auto-incremented.
cs.lastrowid
Here, cs is the cursor object.
import MySQL connector
import MySQL connector
establish connection with the connector using connect()
establish connection with the connector using connect()
create the cursor object using cursor() method
create the cursor object using cursor() method
create a query to INSERT a row into the table
create a query to INSERT a row into the table
execute the SQL query using execute() method
execute the SQL query using execute() method
get the ID of the row inserted using the lastrowid.
get the ID of the row inserted using the lastrowid.
close the connection
close the connection
Suppose we have the following table named “Students”.
+--------+---------+-----------+------------+
|    id  |   Name  |    City   |    Marks   |
+--------+---------+-----------+------------+
|    1   |   Karan |  Amritsar |    95      |
|    2   |   Sahil |  Amritsar |    93      |
|    3   |   Kriti |    Batala |    88      |
|    4   |    Amit |     Delhi |    90      |
+--------+---------+-----------+------------+
The ID column in the above column is the primary key and auto-incrementing. We will insert a new row into the table and get the id of the last inserted row.
import mysql.connector
db=mysql.connector.connect(host="your host", user="your username",password="your
password",database="database_name")

cursor=db.cursor()

#insert a new row into the table
query="INSERT INTO Students VALUES(5,“Priya”, “Amritsar”, 90)"
cursor.execute(query)
db.commit()

#print the id of the inserted row
print(cursor.lastrowid)

db.close()
5