code-rag-bench/online-tutorials huggingface dataset:
Docker – WORKDIR Instruction

28 Oct, 2020
WORKDIR instruction is used to set the working directory for all the subsequent Dockerfile instructions.  Some frequently used instructions in a Dockerfile are RUN, ADD, CMD, ENTRYPOINT, and COPY. If the WORKDIR is not manually created, it gets created automatically during the processing of the instructions. Some points to be noted when using the WORKDIR instruction are as follows: 
WORKDIR does not create new intermediate Image layers.
It adds metadata to the Image Config.
You can have multiple WORKDIR instructions in your Dockerfile.
If you use relative paths as Working Directory, it will be relative to the previous Working Directory.
The default path is /
In this article, we will be discussing how to use WORKDIR instruction in your Dockerfile. We will also discuss 2 other ways to issue Working Directory inside your Dockerfile. Follow the below steps to work with the WORKDIR instruction:
You can use the following template to create the Dockerfile.
FROM ubuntu:latest
WORKDIR /my-work-dir


To build the Docker Image, you can use the Docker Build command.
sudo docker build -t workdir-demo


To run the Docker Container, you can use the Docker Run command.
sudo docker run -it workdir-demo


The above command opens the bash for the container.
You can use the print working directory (pwd) command, to print the working directory.
Now. Let’s discuss ways to issue a working directory in a Dockerfile. There is 2 possible way to do so, and both of them are explained below:
Let’s look at how you can specify a relative path with WORKDIR instruction.
The first step is to create a Dockerfile as mentioned below:
FROM ubuntu:latest
WORKDIR /my-work-dir
RUN echo "work directory 1" > file1.txt
WORKDIR /my-work-dir-2
RUN echo "work directory 2" > file2.txt

Now, build and run the Docker Container.
sudo docker build -t workdir-demo .
sudo docker run -it workdir-demo bash

Finally, print the working directory.
pwd

The first echo statement runs with the working directory set to the “my-work-dir” folder. That’s why if you use ls command to see the contents of the folder, you will find “file1.txt” inside the “my-work-dir” folder. The second WORKDIR instruction changes the Working Directory to “my-work-dir-2” and hence, the file “file2.txt” is inside that folder.
The second way to issue a working directory is by making use of the environment variables. Follow the below steps to take so:
The first step is to use the following Dockerfile template as shown below:
FROM ubuntu:latest
ENV DIRPATH /app
WORKDIR $DIRPATH

Here, we have set the environment variable DIRPATH to the /app directory and set the WORKDIR.
Now, after running the Docker Container, you will find the directory set as /app. 
sudo docker build -t workdir-demo .
sudo docker run -it workdir-demo
pwd

To conclude, in this article, we discussed how to use the WORKDIR instruction in the Dockerfile to set the working directory. We also saw how to set a working directory using relative paths and environment variables.
Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Program to get duration between two time instants

Create two time instants:
Instant time1 = Instant.now();
Instant time2 = Instant.now().plusSeconds(50);
Use between() to get the duration between two time instants:
long resMilli = Duration.between(time1, time2).toMillis();
import java.time.Duration;
import java.time.Instant;
public class Demo {
   public static void main(String[] args) {
      Instant time1 = Instant.now();
      Instant time2 = Instant.now().plusSeconds(50);
      long resMilli = Duration.between(time1, time2).toMillis();
      System.out.println("Duration between two time intervals = "+resMilli);
   }
}
Duration between two time intervals = 50000
How do I get the current AUTO_INCREMENT value for a table in MySQL?

To know the current auto_increment value, we can use the last_insert_id() function. Firstly, we will create a table with the help of INSERT command.
Creating a table −
mysql> CREATE table AutoIncrement
-> (
-> IdAuto int auto_increment,
-> primary key(IdAuto)
-> );
Query OK, 0 rows affected (0.59 sec)
After creating a table, we will insert the records with the help of INSERT command. Inserting
records −
mysql> INSERT into AutoIncrement values();
Query OK, 1 row affected (0.48 sec)

mysql> INSERT into AutoIncrement values();
Query OK, 1 row affected (0.17 sec)

mysql> INSERT into AutoIncrement values();
Query OK, 1 row affected (0.13 sec)

mysql> INSERT into AutoIncrement values();
Query OK, 1 row affected (0.09 sec)
Now, we will see how many records have I inserted into my table with the help of SELECT
command.
Displaying all records −
mysql> SELECT * from AutoIncrement;
+--------+
| IdAuto |
+--------+
| 1      |
| 2      |
| 3      |
| 4      |
+--------+
4 rows in set (0.00 sec)
Therefore, the last auto increment is 4. Here is the query to know the current value have
inserted, which is 4.
mysql> SELECT last_insert_id();

The following is the output −
+------------------+
| last_insert_id() |
+------------------+
| 4                |
+------------------+
1 row in set (0.00 sec)
Here is the query that tells the next auto increment value. The syntax is as follows −
SELECT `AUTO_INCREMENT`
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = 'yourDatabaseName'
AND TABLE_NAME = 'yourTableName';
Now, I am applying the above query −
mysql> SELECT `AUTO_INCREMENT`
-> FROM INFORMATION_SCHEMA.TABLES
-> WHERE TABLE_SCHEMA = 'business'
-> AND TABLE_NAME = 'AutoIncrement';
The following is the output −
+----------------------------+
| AUTO_INCREMENT             |
+----------------------------+
| 5                          |
+----------------------------+
1 row in set (0.13 sec)
From the above query, we are getting the next increment value.
How to write a switch statement in a JSP page?

Following is the example of using a switch statement within a JSP page.
 Live Demo
<%! int day = 3; %>
<html>
   <head>
      <title>SWITCH...CASE Example</title>
   </head>
   <body>
      <%
         switch(day) {
            case 0:
               out.println("It\'s Sunday.");
               break;
            case 1:
               out.println("It\'s Monday.");
               break;
            case 2:
               out.println("It\'s Tuesday.");
               break;
            case 3:
               out.println("It\'s Wednesday.");
               break;
            case 4:
               out.println("It\'s Thursday.");
               break;
            case 5:
               out.println("It\'s Friday.");
               break;
            default:
               out.println("It's Saturday.");
         }
      %>
   </body>
</html>
The above code will generate the following result −
It's Wednesday.
Add a row at top in pandas DataFrame - GeeksforGeeks

29 Jul, 2021
Pandas DataFrame is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Let’s see how can we can add a row at top in pandas DataFrame.Observe this dataset first. 
Python3
# importing pandas moduleimport pandas as pd   # making data framedf = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv") df.head(10)
Code #1: Adding row at the top of given dataframe by concatenating the old dataframe with new one.  
Python3
new_row = pd.DataFrame({'Name':'Geeks', 'Team':'Boston', 'Number':3,                        'Position':'PG', 'Age':33, 'Height':'6-2',                        'Weight':189, 'College':'MIT', 'Salary':99999},                                                            index =[0])# simply concatenate both dataframesdf = pd.concat([new_row, df]).reset_index(drop = True)df.head(5)
Output:  
  Code #2: Adding row at the top of given dataframe by concatenating the old dataframe with new one.  
Python3
new_row = pd.DataFrame({'Name':'Geeks', 'Team':'Boston', 'Number':3,                        'Position':'PG', 'Age':33, 'Height':'6-2',                        'Weight':189, 'College':'MIT', 'Salary':99999}, index =[0]) # Concatenate new_row with dfdf = pd.concat([new_row, df[:]]).reset_index(drop = True)df.head(5)
Output:  
  Code #3: Adding row at the top of given dataframe by concatenating the old dataframe with new one using df.ix[] method. 
Python3
new_row = pd.DataFrame({'Name':'Geeks', 'Team':'Boston', 'Number':3,                        'Position':'PG', 'Age':33, 'Height':'6-2',                        'Weight':189, 'College':'MIT', 'Salary':99999}, index =[0]) df = pd.concat([new_row, df.ix[:]]).reset_index(drop = True)df.head(5)
Output:  
 
surindertarika1234
pandas-dataframe-program
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python OOPs Concepts
How to Install PIP on Windows ?
Bar Plot in Matplotlib
Defaultdict in Python
Python Classes and Objects
Deque in Python
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python - Ways to remove duplicates from list
Class method vs Static method in Python
C Quiz - 108 - GeeksforGeeks

31 May, 2021
#include <stdio.h>
void wrt_it (void);
int main (void)
{
    printf("Enter Text"); 
    printf ("n");
    wrt_ it();
    printf ("n");
    return 0;
}
void wrt_it (void)
{
    int c;
    if (?1)
        wrt_it();
    ?2
}

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Must Do Coding Questions for Product Based Companies
C Program For Finding Length Of A Linked List
How to calculate MOVING AVERAGE in a Pandas DataFrame?
How to Convert Categorical Variable to Numeric in Pandas?
How to Replace Values in Column Based on Condition in Pandas?
How to Fix: SyntaxError: positional argument follows keyword argument in Python
How to Fix: KeyError in Pandas
C Program to read contents of Whole File
How to Append Pandas DataFrame to Existing CSV File?
How to Replace Values in a List in Python?
Introduction to Linear Bounded Automata (LBA) - GeeksforGeeks

02 Mar, 2021
History :In 1960, associate degree automaton model was introduced by Myhill and these days this automation model is understood as deterministic linear bounded automaton. After this, another scientist named Landweber worked on this and proposed that the languages accepted by a deterministic LBA are continually context-sensitive languages.
In 1964, Kuroda introduced a replacement and a lot of general models specially for non-deterministic linear bounded automata, and established that the languages accepted by the non-deterministic linear bounded automata are exactly the context-sensitive languages.
Introduction to Linear Bounded Automata :A Linear Bounded Automaton (LBA) is similar to Turing Machine with some properties stated below:
Turing Machine with Non-deterministic logic,
Turing Machine with Multi-track, and
Turing Machine with a bounded finite length of the tape.
                                                                 
      
Tuples Used in LBA : LBA can be defined with eight tuples (elements that help to design automata) as: 
M = (Q , T , E , q0 , ML , MR , S , F), 

where,  
Q -> A finite set of transition states
T -> Tape alphabet
E -> Input alphabet
q0 -> Initial state
ML -> Left bound of tape
MR -> Right bound of tape
S -> Transition Function
F -> A finite set of final states 
Diagrammatic Representation of LBA :
Examples:
Languages that form LBA with tape as shown above,
L = {an! | n >= 0}
L = {wn | w from {a, b}+, n >= 1}
L = {wwwR | w from {a, b}+}
Facts :
Suppose that a given LBA M has
    --> q states,
    --> m characters within the tape alphabet, and
    --> the input length is n
Then M can be in at most f(n) = q * n * mn configurations i.e. a tape of n cells and m symbols, we are able to have solely mn totally different tapes.The tape head is typically on any of the n cells which we have a tendency to are typically death penalty in any of the q states.
Then M can be in at most f(n) = q * n * mn configurations i.e. a tape of n cells and m symbols, we are able to have solely mn totally different tapes.
The tape head is typically on any of the n cells which we have a tendency to are typically death penalty in any of the q states.
Theory of Computation & Automata
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
NPDA for accepting the language L = {an bn | n>=1}
Construct Pushdown Automata for all length palindrome
NPDA for the language L ={w∈ {a,b}*| w contains equal no. of a's and b's}
NPDA for accepting the language L = {wwR | w ∈ (a,b)*}
Construct a Turing Machine for language L = {ww | w ∈ {0,1}}
Pushdown Automata Acceptance by Final State
Ambiguity in Context free Grammar and Context free Languages
Halting Problem in Theory of Computation
Decidability and Undecidability in TOC
Decidable and Undecidable problems in Theory of Computation
PyQt5 - How to set the maximum value of progress bar ? - GeeksforGeeks

22 Apr, 2020
In this article we will see how to set the maximum value of progress bar. By default the maximum value of progress bar is 100, but we can change it to our need. In order to do this we will use setMaximum method, this will change the maximum value of progress bar.
Note : When we will set the value to progress bar using setValue method, the percentage may or may not be equal to the value passed in it, it depends on the range of progress bar.
percentage = ((value_passed - minimum_value)/(maximum_value - minimum_value))*100
Here, minimum_value = 0, value_passed and maximum_value is set by user.
Syntax : bar.setMaximum(maximum_value)
Argument : It takes argument.
Action performed : It will change the maximum value of progress bar.
Below is the implementation.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):        def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating progress bar        bar = QProgressBar(self)          # setting geometry to progress bar        bar.setGeometry(200, 150, 200, 30)          # setting maximum value of progress bar to 1000        bar.setMaximum(1000)          # setting value to progress bar        bar.setValue(200)          # setting alignment to centre        bar.setAlignment(Qt.AlignCenter)    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
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()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
How to parse a CSV File in PHP ? - GeeksforGeeks

21 May, 2021
In this article, we learn to parse a CSV file using PHP code.
Approach:
Step 1. Add data to an excel file. The following example is given for a sample data having Name and Coding Score as their column headers.
Step 2. Convert to CSV file by following the path. Go to File>Export>Change File Type> CSV Type. Save the file in your working folder with name “Book1.csv”.
Parsing CSV file using PHP:
Step 1. Create a folder and add that CSV file and create a new PHP file in it.
file path
Step 2. Open the PHP file and write the following code in it which is explained in the following steps.
Open dataset of CSV using fopen function.$open = fopen("filename.csv", "r");Read a line using fgetcsv() function.$data = fgetcsv($Open, 1000, ",");Use a loop to iterate in every row of data.while (($data = fgetcsv($Open, 1000, ",")) !== FALSE) 
{
  // Read the data    
}Close that file using PHP fclose() method.fclose($open);
Open dataset of CSV using fopen function.$open = fopen("filename.csv", "r");
Open dataset of CSV using fopen function.
$open = fopen("filename.csv", "r");
Read a line using fgetcsv() function.$data = fgetcsv($Open, 1000, ",");
Read a line using fgetcsv() function.
$data = fgetcsv($Open, 1000, ",");
Use a loop to iterate in every row of data.while (($data = fgetcsv($Open, 1000, ",")) !== FALSE) 
{
  // Read the data    
}
Use a loop to iterate in every row of data.
while (($data = fgetcsv($Open, 1000, ",")) !== FALSE) 
{
  // Read the data    
}
Close that file using PHP fclose() method.fclose($open);
Close that file using PHP fclose() method.
fclose($open);
Example:
PHP
<?php    if (($open = fopen("Book1.csv", "r")) !== FALSE)   {      while (($data = fgetcsv($open, 1000, ",")) !== FALSE)     {              $array[] = $data;     }      fclose($open);  }  echo "<pre>";  //To display array data  var_dump($array);  echo "</pre>";
Output:
array(6) {
  [0]=>
  array(2) {
    [0]=>
    string(5) "Name "
    [1]=>
    string(12) "Coding Score"
  }
  [1]=>
  array(2) {
    [0]=>
    string(4) "Atul"
    [1]=>
    string(3) "200"
  }
  [2]=>
  array(2) {
    [0]=>
    string(5) "Danny"
    [1]=>
    string(3) "250"
  }
  [3]=>
  array(2) {
    [0]=>
    string(6) "Aditya"
    [1]=>
    string(3) "150"
  }
  [4]=>
  array(2) {
    [0]=>
    string(7) "Avinash"
    [1]=>
    string(3) "300"
  }
  [5]=>
  array(2) {
    [0]=>
    string(6) "Ashish"
    [1]=>
    string(3) "240"
  }
}
PHP-function
PHP-Questions
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to execute PHP code using command line ?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
PHP in_array() Function
How to pop an alert message box using PHP ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to get data of any size from the EEPROM with Arduino?

Arduino Uno has 1 kB of EEPROM storage. EEPROM is a type of non-volatile memory, i.e., its contents are preserved even after power-down. Therefore, it can be used to store data that you want to be unchanged across power cycles. Configurations or settings are examples of such data.
In this article, we will see how to get data of any size (not just a byte) from the EEPROM. We will be walking through an inbuilt example in Arduino. The EEPROM examples can be accessed from − File → Examples → EEPROM.
We will look at the eeprom_get example. This example assumes that you've pre-set the data in Arduino's EEPROM by running the code in the eeprom_put example. In other words, the eeprom_put example is a precursor to this example.
The main function of interest is EEPROM.get(). It takes two arguments, the starting address from which to start reading data, and the variable in which the read data is to be stored (which can be of a primitive type, like float, or a custom struct). Examples of other primitive data types are short, int, long, char, double, etc. This function determines the number of bytes to read based on the size of the variable in which the read data is to be stored.
We begin with the inclusion of the library.
#include <EEPROM.h>
There is a global struct defined later in the code.
struct MyObject {
   float field1;
   byte field2;
   char name[10];
};
Within the Setup, we first initialize Serial, and read a float from the beginning of the EEPROM (address = 0). We then read a struct in the secondTest() function (where we first move the EEPROM read address by the size of a float, then create an object of the type struct, and read into it. We then print the fields within the struct one by one.
void setup() {
   float f = 0.00f; //Variable to store data read from EEPROM.
   int eeAddress = 0; //EEPROM address to start reading from

   Serial.begin(9600);
   while (!Serial) {
      ; // wait for serial port to connect. Needed for native USB port only
   }
   Serial.print("Read float from EEPROM: ");

   //Get the float data from the EEPROM at position 'eeAddress' EEPROM.get(eeAddress, f);
   Serial.println(f, 3); //This may print 'ovf, nan' if the data inside the EEPROM is not a valid float.

   /***
      As get also returns a reference to 'f', you can use it inline.
      E.g: Serial.print( EEPROM.get( eeAddress, f ) );
   ***/
   /***
      Get can be used with custom structures too.
      I have separated this into an extra function.
   ***/

   secondTest(); //Run the next test.
}

void secondTest() {
   int eeAddress = sizeof(float); //Move address to the next byte after float 'f'.
   MyObject customVar; //Variable to store custom object read from EEPROM.
   EEPROM.get(eeAddress, customVar);

   Serial.println("Read custom object from EEPROM: ");
   Serial.println(customVar.field1);
   Serial.println(customVar.field2);
   Serial.println(customVar.name);
}
Nothing happens in the loop.
void loop() {
   /* Empty loop */
}
Euphoria - Data Types

The data stored in memory can be of many types. For example, a person's age is stored as a numeric value and his or her address is stored as alphanumeric characters.
Euphoria has some standard types that are used to define the operations possible on them and the storage method for each of them.
Euphoria has following four standard data types −
integer
atom
sequence
object
The understanding of atoms and sequences is the key to understanding Euphoria.
Euphoria integer data types store numeric values. They are declared and defined as follows −
integer var1, var2

var1 = 1
var2 = 100
The variables declared with type integer must be atoms with integer values from -1073741824 to +1073741823 inclusive. You can perform exact calculations on larger integer values, up to about 15 decimal digits, but declare them as atom, rather than integer.
All data objects in Euphoria are either atoms or sequences. An atom is a single numeric value. Atoms can have any integer or double-precision floating point value. Euphoria atoms are declared and defined as follows−
atom var1, var2, var3

var1 = 1000
var2 = 198.6121324234
var3 = 'E'       
The atoms can range from approximately -1e300 to +1e300 with 15 decimal digits of accuracy. An individual character is an atom which must may be entered using single quotes. For example, all the following statements are legal −
-- Following is equivalent to the atom 66 - the ASCII code for B
char = 'B'

-- Following is equivalent to the sequence {66}
sentence = "B"

A sequence is a collection of numeric values which can be accessed through their index. All data objects in Euphoria are either atoms or sequences.
Sequence index starts from 1 unlike other programming languages where array index starts from 0. Euphoria sequences are declared and defined as follows −
sequence var1, var2, var3, var4

var1 = {2, 3, 5, 7, 11, 13, 17, 19}
var2 = {1, 2, {3, 3, 3}, 4, {5, {6}}}
var3 = {{"zara", "ali"}, 52389, 97.25}     
var4 = {} -- the 0 element sequence
A character string is just a sequence of characters which may be entered using double quotes. For example, all the following statements are legal −
word = 'word'
sentence = "ABCDEFG"
Character strings may be manipulated and operated upon just like any other sequences. For example, the above string is entirely equivalent to the sequence −
sentence = {65, 66, 67, 68, 69, 70, 71}
You will learn more about sequence in Euphoria − Sequences.
This is a super data type in Euphoria which may take on any value including atoms, sequences, or integers. Euphoria objects are declared and defined as follows −
object var1, var2, var3

var1 = {2, 3, 5, 7, 11, 13, 17, 19}
var2 = 100
var3 = 'E'     
An object may have one of the following values −
a sequence
a sequence
an atom
an atom
an integer
an integer
an integer used as a file number
an integer used as a file number
a string sequence, or single-character atom
a string sequence, or single-character atom
 Print
 Add Notes
 Bookmark this page
Python - Move() function in wxPython - GeeksforGeeks

10 May, 2020
In this particular article we will learn, how can we move our window to a particular point. This can be achieved using Move() function in wx.Window class of wxPython.Move() takes x and y points to move window to a particularx, y point.
Syntax :
wx.Move(self, x, y, flags=SIZE_USE_EXISTING)

Parameters :
Code Example #1:
# import wxPythonimport wx  # frame classclass MoveWindow(wx.Frame):      def __init__(self, parent, title):        super(MoveWindow, self).__init__(parent, title = title,            size =(300, 200))        # move window using Move() function        self.Move((500, 250))    def  main():    app = wx.App()    move = MoveWindow(None, title ='Move()')    move.Show()    app.MainLoop()    if __name__ == '__main__':    main()
Output:
Code Example #2:
# import wxPythonimport wx  # frame classclass MoveWindow(wx.Frame):      def __init__(self, parent, title):        super(MoveWindow, self).__init__(parent, title = title,            size =(300, 200))        # move window to (900, 600) using Move() function        self.Move((900, 600))    def  main():    app = wx.App()    move = MoveWindow(None, title ='Move()')    move.Show()    app.MainLoop()    if __name__ == '__main__':    main()
Output:
Python-gui
Python-wxPython
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
Python | Get unique values from a list
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python Classes and Objects
Python - Extract Dictionary values list to List - GeeksforGeeks

22 Apr, 2020
Sometimes, while working with dictionary records, we can have problems in which we need to extract all the dictionary values into a single separate list. This can have possible application in data domains and web-development. Lets discuss certain ways in which this task can be performed.
Method #1 : Using map() + generator expressionThe combination of above functionalities can be used to solve this problem. In this, we perform the task of extraction of values using generator expression and map() is used to reconstruct the value lists.
# Python3 code to demonstrate working of # Extracting Dictionary values list to List# Using map() + generator expression  # initializing dictionarytest_dict = {'gfg' : [4, 6, 7, 8],             'is' : [3, 8, 4, 2, 1],             'best' : [9, 5, 2, 1, 0]}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # Extracting Dictionary values to List# Using map() + generator expressionres = list(map(list, (ele for ele in test_dict.values())))      # printing result print("The list of dictionary values : " + str(res)) 
The original dictionary is : {‘is’: [3, 8, 4, 2, 1], ‘gfg’: [4, 6, 7, 8], ‘best’: [9, 5, 2, 1, 0]}The list of dictionary values : [[3, 8, 4, 2, 1], [4, 6, 7, 8], [9, 5, 2, 1, 0]]
 
Method #2 : Using map()The combination of above functions can be used to solve this problem. In this we perform the task of extraction and remaking using map().
# Python3 code to demonstrate working of # Extracting Dictionary values list to List# Using map()  # initializing dictionarytest_dict = {'gfg' : [4, 6, 7, 8],             'is' : [3, 8, 4, 2, 1],             'best' : [9, 5, 2, 1, 0]}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # Extracting Dictionary values to List# Using map()res = list(map(list, (test_dict.values())))      # printing result print("The list of dictionary values : " + str(res)) 
The original dictionary is : {‘is’: [3, 8, 4, 2, 1], ‘gfg’: [4, 6, 7, 8], ‘best’: [9, 5, 2, 1, 0]}The list of dictionary values : [[3, 8, 4, 2, 1], [4, 6, 7, 8], [9, 5, 2, 1, 0]]
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
Defaultdict in Python
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Python | Convert string dictionary to dictionary
Python - All possible pairs in List - GeeksforGeeks

03 Jul, 2020
Sometimes, while working with Python list, we can have a problem in which we need to extract all the possible pairs that can be performed from integers from list. This kind of problem can occur in many domains such as day-day programming and web development. Let’s discuss certain ways in which this task can be performed.
Input : test_list = [1, 7, 4]Output : [(1, 7), (1, 4), (7, 4)]
Input : test_list = [7, 4]Output : [(7, 4)]
Method #1 : Using list comprehension + enumerate()This is one of the ways in which this task can be performed. In this, we perform the task of pairing using nested loops in list comprehension recipe, and enumerate() is used to check with the next indices while iteration.
# Python3 code to demonstrate working of # All possible pairs in List# Using list comprehension + enumerate()  # initializing listtest_list = [1, 7, 4, 3]  # printing original list print("The original list : " + str(test_list))  # All possible pairs in List# Using list comprehension + enumerate()res = [(a, b) for idx, a in enumerate(test_list) for b in test_list[idx + 1:]]  # printing result print("All possible pairs : " + str(res))
The original list : [1, 7, 4, 3]
All possible pairs : [(1, 7), (1, 4), (1, 3), (7, 4), (7, 3), (4, 3)]

 
Method #2 : Using combinations()This is one of the ways in which this task can be performed. In this, we just using inbuild function for pairing and sending 2 as value for making pairs of size 2.
# Python3 code to demonstrate working of # All possible pairs in List# Using combinations()from itertools import combinations  # initializing listtest_list = [1, 7, 4, 3]  # printing original list print("The original list : " + str(test_list))  # All possible pairs in List# Using combinations()res = list(combinations(test_list, 2))  # printing result print("All possible pairs : " + str(res))
The original list : [1, 7, 4, 3]
All possible pairs : [(1, 7), (1, 4), (1, 3), (7, 4), (7, 3), (4, 3)]

Python list-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 ?
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
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?
LEX program to print the longest string and to find average of given numbers - GeeksforGeeks

03 Aug, 2021
Lex :The Lex program has purpose of generating lexical analyzer. Lex analyzers are a program that transform input streams into sequence of tokens. A C program implements the lexical analyzer to read input stream and produce output as the source code.
 Commands to be used –
lex file_name.l   // To produce a c program
cc lex.yy.c -lfl  // To compile the c program and produces object program a.out.
./a.out           // To transforms an input stream into a sequence of tokens.    
1. Longest string :In this we are finding the length of longest string by using the function called ( It returns the length of a given string). And we are storing this returned value in the variable . To print what string or word is longest we are using  and  function. We are storing the string or word in a variable of type char that is .
Program –
C
%{   //to find longest string and its length    #include<stdio.h>    #include<string.h>    int longest = 0;    char longestString[30];%}%%[a-zA-Z]+ {if(yyleng>longest){    longest = yyleng;    strcpy(longestString,yytext);}}  %%  int main(void){    yylex();    printf("The longest string is %s \n", longestString);    printf("Length of a longest string is %d \n",longest);}
Output –
2. Average of given numbers :So, first we have to calculate sum of all numbers that are given by user. Store sum in a variable sum. Then count number of integers(numbers that are given by the user). Store this count in a variable n.After this, just divide the sum and count of numbers. You will get your result.Here, we are using inbuild function atoi(). A string of characters can be passed into atoi() function, which will convert them into an integer. The input string is a text string that can be converted into a numeric value. When first character in input string is not part of a number, atoi() function stops reading it. This could be null character at the end of string. It does not support exponents and decimals.The atoi() function removes all the Whitespace in string at beginning.
Program –
C
%{    //Average of given numbers.    #include<stdio.h>    #include<math.h>%}digit[0-9]+%%{digit} return atoi(yytext);%%  int main(){    float sum=0, num, n=0;    while((num=yylex())>0){    sum = sum+num;    n = n+1;}printf("The sum of given numbers is %f\n",sum);printf("Average of given numbers is %f\n",sum/n);yylex();return 0;}
Output –
Theory of Computation & Automata
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
NPDA for accepting the language L = {an bn | n>=1}
Construct Pushdown Automata for all length palindrome
NPDA for the language L ={w∈ {a,b}*| w contains equal no. of a's and b's}
NPDA for accepting the language L = {wwR | w ∈ (a,b)*}
Construct a Turing Machine for language L = {ww | w ∈ {0,1}}
Pushdown Automata Acceptance by Final State
Ambiguity in Context free Grammar and Context free Languages
Halting Problem in Theory of Computation
Decidability and Undecidability in TOC
Decidable and Undecidable problems in Theory of Computation
How to get a variable name as a string in PHP? - GeeksforGeeks

15 May, 2019
Use variable name as a string to get the variable name. There are many ways to solve this problem some of them are discussed below:
Method 1: Using $GLOBALS: It is used to reference all variables available in global scope. It is an associative array which contains the reference of all variables which are currently defined in the global scope.
Example: This example uses $GLOBAL reference to get the variable name as a string.
<?php  // Declare and initialize a variable$test = "This is a string";  // Function that returns the variable namefunction getVariavleName($var) {    foreach($GLOBALS as $varName => $value) {        if ($value === $var) {            return $varName;        }    }    return;}  // Function call and display the// variable nameprint getVariavleName($test);  ?>
test

Method 2: Using $$ Operator: The $$var_name is known as reference variable where $var_name is a normal variable. The $$var_name used to refer to the variable with the name as value of the variable $var_name.Example: This example uses $$ operator to get the variable name as a string.
<?php  // Declare and initialize a variable$name = "test";  // Reference variable to store string$$name = "This is a string";  // Display resultprint($name);  ?>
test

PHP-string
Picked
PHP
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
PHP | Converting string to Date and DateTime
Comparing two dates in PHP
How to receive JSON POST with PHP ?
How to pass JavaScript variables to PHP ?
Split a comma delimited string into an array in PHP
Download file from URL using PHP
C# | How to change the CursorSize of the Console - GeeksforGeeks

28 Jan, 2019
Given the normal Console in C#, the task is to change the CursorSize of the Console.
Approach: This can be done using the CursorSize property in the Console class of the System package in C#. It gets or sets the height of the cursor within a character cell in percentage.
Program 1: Getting the value of CursorSize
// C# program to illustrate the// Console.CursorSize Propertyusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  namespace GFG {  class Program {      static void Main(string[] args)    {          // Get the CursorSize        Console.WriteLine("Current CursorSize: {0}",                                Console.CursorSize);    }}}
Output:
Program 2: Setting the value of CursorSize
// C# program to illustrate the// Console.CursorSize Propertyusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  namespace GFG {  class Program {      // Main Method    static void Main(string[] args)    {          // Get the CursorSize        Console.WriteLine("Current CursorSize: {0}",                                Console.CursorSize);          // Set the CursorSize        Console.CursorSize = 100;          // Get the CursorSize        Console.Write("Current CursorSize: {0}",                            Console.CursorSize);    }}}
Output:
Note: See the width of the Cursor in both the images.
CSharp-Console-Class
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
C# | Method Overriding
C# | Abstract Classes
Difference between Ref and Out keywords in C#
Extension Method in C#
C# | Class and Object
C# | Constructors
C# | String.IndexOf( ) Method | Set - 1
C# | Replace() Method
JavaTuples getValue() method - GeeksforGeeks

27 Aug, 2018
The getValue() method in org.javatuples is used to fetch the value of the TupleClassObject from the index passed as the parameter. This method can be used to any tuple class object of javatuples library. It returns a Object value which is the element present at the index, passed as parameter, of the TupleClassObject. Since the returned Value is of Object type, hence using getValue() loses the type-safety.
Method Declaration:
public final Object getValue(int pos)
Syntax:
Object val = TupleClassObject.getValue(int pos)
Here TupleClassObject represents the JavaTuple Class object used like Unit, Quintet, Decade, etc.
Parameters: This method takes pos as parameter where:
pos– is the index at which the value of the TupleClassObject is to be known.
TupleClassObject– represents the JavaTuple Class object used like Unit, Quintet, Decade, etc.
Return Value: This method returns a Object value which is the element present at the index, passed as parameter, of the TupleClassObject.
Below programs illustrate the various ways to use getValue() method:
Program 1: Using getValue() with Unit class:
// Below is a Java program to use getValue() method  import java.util.*;import org.javatuples.Unit;  class GfG {    public static void main(String[] args)    {        // Creating an Unit with one value        Unit<String> unit = Unit.with("GeeksforGeeks");          // Using getValue() method        Object val = unit.getValue(0);          System.out.println("Value at 0 = " + val);    }}
Output:
Value at 0 = GeeksforGeeks
Program 2: Using getValue() with Quartet class:
// Below is a Java program to use getValue() method  import java.util.*;import org.javatuples.Quartet;  class GfG {    public static void main(String[] args)    {        Quartet<String, String, String, String> quartet            = Quartet.with("GeeksforGeeks",                           "A computer portal",                           "for geeks",                           "by Sandeep Jain");          // Using getValue() method        Object val = quartet.getValue(2);          System.out.println("Value at 2 = " + val);    }}
Output:
Value at 2 = for geeks
Note: Similarly, it can be used with any other JavaTuple Class.
Java-Functions
JavaTuples
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
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
Multithreading in Java
How to write multi-line strings in template literals ? - GeeksforGeeks

03 Dec, 2021
Template literals are introduced in ES6 and by this, we use strings in a modern way. Normally for defining string, we use double/single quotes ( ” ” or ‘ ‘ ) in JavaScript. But in template literals, we use backtick ( ` ` ).
Let us see how to write multiline strings in template literals.
Example 1: We write multiline string by template literals.
HTML
<script>    const multilineString = `How     are you    doing    I am fine`;          console.log(multilineString);</script>
Output:
How      
are you  
doing    
I am fine
Example 2: If you use double/single quote to write multiline string then we use the newline character (\n).  Use an extra backslash ( \ ) after every newline character (\n), this backslash tells the JavaScript engine that the string is not over yet.
HTML
<script>    var multilineString =     "How \n\    are you \n\    doing \n\    I am fine";          console.log(multilineString);</script>
Output:
How 
are you
doing
I am fine
JavaScript-Questions
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
JavaScript | Promises
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
Python - tensorflow.math.sqrt() - GeeksforGeeks

16 Jun, 2020
TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks.
sqrt() is used to compute element wise square root.
Syntax: tensorflow.math.sqrt(x, name)
Parameters:
x: It’s a tensor. Allowed dtypes are bfloat16, half, float32, float64, complex64, complex128.
name(optional): It defines the name for the operation.
Returns: It returns a tensor.
Example 1:
Python3
# importing the libraryimport tensorflow as tf  # Initializing the input tensora = tf.constant([ 5, 7, 9, 15], dtype = tf.float64)  # Printing the input tensorprint('a: ', a)  # Calculating resultres = tf.math.sqrt(a)  # Printing the resultprint('Result: ', res)
Output:
a:  tf.Tensor([ 5.  7.  9. 15.], shape=(4, ), dtype=float64)
Result:  tf.Tensor([2.23606798 2.64575131 3.         3.87298335], shape=(4, ), dtype=float64)




Example 2: Visualization
Python3
# import tensorflow as tfimport matplotlib.pyplot as plt  # Initializing the input tensora = tf.constant([ 5, 7, 9, 15], dtype = tf.float64)  # Calculating tangentres = tf.math.sqrt(a)  # Plotting the graphplt.plot(a, res, color ='green')plt.title('tensorflow.math.sqrt')plt.xlabel('Input')plt.ylabel('Result')plt.show()
Output:
Python Tensorflow-math-functions
Python-Tensorflow
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?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
numpy.angle() in Python

28 Nov, 2018
numpy.angle() function is used when we want to compute the angle of the complex argument. A complex number is represented by “ x + yi ” where x and y are real number and i= (-1)^1/2. The angle is calculated by the formula tan-1(x/y).
Syntax : numpy.angle(z, deg=0)
Parameters :z : [array_like] A complex number or sequence of complex numbers.deg : [bool, optional] Return angle in degrees if True, radians if False (default).
Return :angle : The counterclockwise angle from the positive real axis on the complex plane, with dtype as numpy.float64.
Code #1 : Working
# Python program explaining# numpy.angle() function# when we want answer in radian  import numpy as geekin_list =[2.0, 1.0j, 1 + 1j]  print ("Input  list : ", in_list)    out_angle = geek.angle(in_list) print ("output angle in radians : ", out_angle) 
Output :
Input  list :  [2.0, 1j, (1+1j)]
output angle in radians :  [ 0.          1.57079633  0.78539816]

 Code #2 : Working
# Python program explaining# numpy.angle() function# when we want answer in degrees  import numpy as geekin_list =[2.0, 1.0j, 1 + 1j]  print ("Input  list : ", in_list)    out_angle = geek.angle(in_list, deg = True) print ("output angle in degrees : ", out_angle) 
Output :
Input  list :  [2.0, 1j, (1+1j)]
output angle in degrees :  [  0.  90.  45.]

Python numpy-Mathematical Function
Python-numpy
Python
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()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts