code-rag-bench/online-tutorials huggingface dataset:
State the difference between structure and union with suitable example in C language

The differences between structures and unions in C language are explained below −
struct tagname{
   datatype member1;
   datatype member2;
   ----
   ----
   ----
};
union tagname{
   datatype member1;
   datatype member2;
   ----
   ----
   ----
};
struct sample{
   int a;
   float b;
   char c;
};
union sample{
   int a;
   float b;
   char c;
};
Following is the C program for structures −
#include<stdio.h>
struct size{
   double a;
   int b;
   char c;
   float d;
};
int main(){
   printf("%ld",sizeof( stuct size));
}
When the above program is executed, it produces the following result −
24
Following is the C program on union −
#include<stdio.h>
union size{
   double a;
   int b;
   char c;
   float d;
}
Int main(){
   Printf("ld",sizeof(union size));
}
When the above program is executed, it produces the following result −
8
Longest Increasing Subsequence

Longest Increasing Subsequence is a subsequence where one item is greater than its previous item. Here we will try to find Longest Increasing Subsequence length, from a set of integers.
Input:
A set of integers. {0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}
Output:
The length of longest increasing subsequence. Here it is 6.
The subsequence is 0, 2, 6, 9, 13, 15.
longestSubSeq(subarray, n)
Input − The sub array and the size of sub array.
Output − Longest increasing sub sequence length.
Begin
   define array length of size n
   initially set 0 to all entries of length

   for i := 1 to n-1, do
      for j := 0 to i-1, do
         if subarray[j] < subarray[i] and length[j] > length[i], then length[i] := length[j]
      done

      increase length[i] by 1
   done

   lis := 0
   for i := 0 to n-1, do
      lis := maximum of lis and length[i]
   done

   return lis
End
#include <iostream>
using namespace std;

int longestSubSeq(int subArr[], int n) {
   int length[n] = { 0 };                    //set all length to 0
   length[0] = 1;                            //subsequence ending with subArr[0] is 1

   for (int i = 1; i < n; i++) {            //ignore first character, second to all
      for (int j = 0; j < i; j++) {         //subsequence ends with subArr[j]
         if (subArr[j] < subArr[i] && length[j] > length[i])
            length[i] = length[j];
      }
      length[i]++;              //add arr[i]
   }
   int lis = 0;
   for (int i = 0; i<n; i++)           // find longest increasing subsequence
      lis = max(lis, length[i]);
   return lis;
}
int main() {
   int arr[] = { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15};
   int n = 16
   cout << "Length of Longest Increasing Subsequence is: " << longestSubSeq(arr, n);
   return 0;
}
Length of Longest Increasing Subsequence is: 6
How to get the creation date of a MySQL table?

To get the creation date of a MySQL table, use create_time from information_schema.tables. The syntax is as follows −
SELECT create_time FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'yourDatabaseName' AND table_name = 'yourTableName';
My table name is 'skiplasttenrecords' and database is ‘test’.
Implement the above syntax for your database and table name. The query is as follows −
mysql> SELECT create_time FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'test'
   −> AND table_name = 'skiplasttenrecords';
The following is the output displaying the creation date −
+---------------------+
| CREATE_TIME         |
+---------------------+
| 2018-11-29 15:47:14 |
+---------------------+
1 row in set (0.00 sec)
Difference between Procedural and Declarative Knowledge

Procedural or imperative knowledge clarifies how to perform a certain task. It lays down the steps to perform. For example, - how to copy an array using javascript in a procedural way.
var a=[1, 2, 3, 4, 5];
var b=[];
for(var i=0;i < a.length;i++) {
   b.push(a[i]);
}
console.log(b);
[1, 2, 3, 4, 5]
Declarative or functional knowledge clarifies what to do to perform a certain task. It lays down the function to perform. For example, - how to copy an array using javascript in a declarative way.
var a=[1, 2, 3, 4, 5];
var b=a.map(function(number){
   return number*1
});
console.log(b);
[1, 2, 3, 4, 5]
The following are some of the important differences between Procedural Knowledge and Declarative Knowledge.
How to update the date format in MySQL?

Let us first create a table −
mysql> create table DemoTable630 (ArrivalDate varchar(100));
Query OK, 0 rows affected (0.55 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable630 values('2015-21-01');
Query OK, 1 row affected (0.09 sec)
mysql> insert into DemoTable630 values('2018-25-12');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable630 values('2019-15-07');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable630 values('2016-31-03');
Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable630;
This will produce the following output −
+-------------+
| ArrivalDate |
+-------------+
| 2015-21-01  |
| 2018-25-12  |
| 2019-15-07  |
| 2016-31-03  |
+-------------+
4 rows in set (0.00 sec)
Following is the query to convert date format −
mysql> select str_to_date(ArrivalDate,'%Y-%d-%m') from DemoTable630;
This will produce the following output −
+-------------------------------------+
| str_to_date(ArrivalDate,'%Y-%d-%m') |
+-------------------------------------+
| 2015-01-21                          |
| 2018-12-25                          |
| 2019-07-15                          |
| 2016-03-31                          |
+-------------------------------------+
4 rows in set (0.00 sec)
Calculate the average value in a MongoDB document grouping by null?

You can use $group operator with _id: null. Following is the syntax −
db.yourCollectionName.aggregate([{$group: {_id:null, "anyFieldName": {$avg:"$yourFieldName"} } }]);
Let us first create a collection with documents −
> db.caculateTheAverageValueDemo.insertOne({"Population":100});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd68a197924bb85b3f4895f")
}
> db.caculateTheAverageValueDemo.insertOne({"Population":500});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd68a1c7924bb85b3f48960")
}
> db.caculateTheAverageValueDemo.insertOne({"Population":200});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd68a237924bb85b3f48961")
}
> db.caculateTheAverageValueDemo.insertOne({"Population":100});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd68a297924bb85b3f48962")
}
> db.caculateTheAverageValueDemo.insertOne({"Population":100});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cd68a2e7924bb85b3f48963")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.caculateTheAverageValueDemo.find().pretty();
This will produce the following output −
{ "_id" : ObjectId("5cd68a197924bb85b3f4895f"), "Population" : 100 }
{ "_id" : ObjectId("5cd68a1c7924bb85b3f48960"), "Population" : 500 }
{ "_id" : ObjectId("5cd68a237924bb85b3f48961"), "Population" : 200 }
{ "_id" : ObjectId("5cd68a297924bb85b3f48962"), "Population" : 100 }
{ "_id" : ObjectId("5cd68a2e7924bb85b3f48963"), "Population" : 100 }
Following is the query to average the values of a MongoDB document −
> db.caculateTheAverageValueDemo.aggregate([{$group: {_id:null, "AveragePopulation": {$avg:"$Population"} } }]);
This will produce the following output −
{ "_id" : null, "AveragePopulation" : 200 }
What is a final method in Java?

The final modifier for finalizing the implementations of classes, methods, and variables.
We can declare a method as final, once you declare a method final it cannot be overridden. So, you cannot modify a final method from a sub class.
The main intention of making a method final would be that the content of the method should not be changed by any outsider.
public class FinalMethodExample {
   public final void display(){
      System.out.println("Hello welcome to Tutorialspoint");
   }
   public static void main(String args[]){
      new FinalMethodExample().display();
   }
   class Sample extends FinalMethodExample{
      public void display(){
         System.out.println("hi");
      }
   }
}
FinalMethodExample.java:12: error: display() in FinalMethodExample.Sample cannot override display() in FinalMethodExample
public void display(){
            ^
overridden method is final
1 error
Python - RemoveAccents Module - GeeksforGeeks

16 Jul, 2020
removeaccents module is that library of python which helps you to remove all the accents from a given string. The most common accents are the acute (é), grave (è), circumflex (â, î or ô), umlaut and dieresis (ü or ï ). Accent marks usually appear above a character.It can be widely used in Natural language Processing for filtering out the data by removing all the accents from a given text.
Installing Library :
This module does not come built-in with Python. You need to install it externally. To install this module type the below command in the terminal.
pip install removeaccents
remove_accents : It will return the string after removing all accents from the characters in the string.
Example :
# Importing removeaccents function  # From removeaccents Library  from removeaccents import removeaccents  str_input ="Ît löökèd cóol ând câsüâl, büt nôt prôvôcâtïvê ."str_output = removeaccents.remove_accents(str_input)print(str_output)  str_input ="För môrê àrticlés vîsit GééksförGèèks ."str_output = removeaccents.remove_accents(str_input)print(str_output)  str_input ="https://äüth.gèéksforgëëks.ôrg / usër / vâsü_gûptâ/àrtîclés ."str_output = removeaccents.remove_accents(str_input)print(str_output)
Output:
It looked cool and casual, but not provocative .

For more articles visit GeeksforGeeks .

https://auth.geeksforgeeks.org/user/vasu_gupta/articles .


Reference:pypy.org
Natural-language-processing
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 ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Erlang - write

This method is used to write the contents to a file.
write(FileHandler,text)

FileHandler − This is the handle to a file. This handle is the one that would be returned when the file:openoperation is used.
FileHandler − This is the handle to a file. This handle is the one that would be returned when the file:openoperation is used.
Text − The text which needs to be added to the file.
Text − The text which needs to be added to the file.
None
-module(helloworld). 
-export([start/0]). 

start() -> 
   {ok, Fd} = file:open("Newfile.txt", [write]), 
   file:write(Fd,"New Line").
Whenever the above code is run, the line “New Line” will be written to the file. Note that because the mode is set to write, if there were any previous contents to the file, they will be overwritten.
To append to the existing contents of the file, you need to change the mode to append as shown in the following program.
-module(helloworld). 
-export([start/0]). 

start() -> 
   {ok, Fd} = file:open("Newfile.txt", [append]), 
   file:write(Fd,"New Line").
 Print
 Add Notes
 Bookmark this page
How to set the font size of a Tkinter Canvas text item?

Canvas is one of the flexible widgets in tkinter which controls the widgets with its power of functions, methods, and attributes. However, tkinter canvas can be used to create text using the create_text(options) constructor. We can define the text along with other properties in the constructor. After defining the text, we can control over the text style such as font-family, font-size and font-style by using font(property).
Let us have a look at the following example where we will add a new text and then resize it using the font property.
#Import tkinter library
from tkinter import *
from tkinter import ttk
#Create an instance of tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
win.geometry("750x250")
#Creating a canvas
canvas= Canvas(win, width= 430, height= 450)
#Create a text inside canvas
text= canvas.create_text(200,40,text="Hey, Developers!", font=('Helvetica','30','bold'))
canvas.pack()
win.mainloop()
Running the above code will display a window that contains a text in the canvas. We can resize the text in the canvas by using the font(options) attribute.
Now, change the font size from the property and run the code to see the reflected changes.
Types of Three-address codes

10 Sep, 2021
Three-address code is a sequence of statements of the general form A := B op C, where A, B, C are either programmer defined names, constants or compiler-generated temporary names; op stands for an operation which is applied on A, B.In simple words, a code having at most three addresses in a line is called three address codes. 
Example:  
(a+b)*(a+b+c) 
The three address code for above expression is:  
t1=a+b
t2=t1+c
t3=t1*t2
In compiler design the most popular intermediate code representation is Three-address code. It is globally accepted and is most widely used. There are a lot of three-address statements. All the complex three-address statements are generally a combination of simpler three-address statements. 
These statements come under following seven categories and can be called as building block for three-address statements- 
 
Now, by using the above statements let us convert some popular high level constructs in Three-address code. 
1. While Statement –  
while E do S
Three-address Code:  
L:if(E==0) goto L1
  S
  goto L
L1:end
2. For Statement –  
for(E1;E2;E3) do S
Three-address Code:  
  E1
L:if(E2) goto L1
  goto L2
L1:S
  E3
  goto L
L2:end
3. Switch Statement –  
switch(E){
case 1: S1
        break;
case 2: S2
        break;
default: S3
}
Three-address Code:  
  t=E
  goto test
L1:S1
  goto Last
L2:S2
   goto Last
L3:S3
   goto Last
test: if(E==1) goto L1
      if(E==2) goto L2
      goto L3
Last:end
Thus, we can see by using the seven statements we can replicate statements from higher level language into address codes. 
pranavgajera1998
Compiler Design
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Directed Acyclic graph in Compiler Design (with examples)
Type Checking in Compiler Design
Data flow analysis in Compiler
S - attributed and L - attributed SDTs in Syntax directed translation
Runtime Environments in Compiler Design
Layers of OSI Model
ACID Properties in DBMS
TCP/IP Model
Types of Operating Systems
Normal Forms in DBMS
Python – Length of shortest string in string list

17 Dec, 2019
Sometimes, while working with a lot of data, we can have a problem in which we need to extract the minimum length string of all the strings in list. This kind of problem can have application in many domains. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using min() + generator expressionThe combination of above functionalities can be used to perform this task. In this, we extract all the list lengths using generator expression and return minimum of them using min().
# Python3 code to demonstrate working of# Minimum String length# using min() + generator expression  # initialize list test_list = ['gfg', 'is', 'best']  # printing original list print("The original list : " + str(test_list))  # Minimum String length# using min() + generator expressionres = min(len(ele) for ele in test_list)  # printing resultprint("Length of minimum string is : " + str(res))
The original list : ['gfg', 'is', 'best']
Length of minimum string is : 2

 
Method #2 : Using len() + key argument + min()The combination of above functions can be used to perform this task. In this, we extract the minimum length using len() and min(). It is faster than above method as it performs more task built in rather than overhead by generator expression.
# Python3 code to demonstrate working of# Minimum String length# using len() + key argument + min()  # initialize list test_list = ['gfg', 'is', 'best']  # printing original list print("The original list : " + str(test_list))  # Minimum String length# using len() + key argument + min()res = len(min(test_list, key = len))  # printing resultprint("Length of minimum string is : " + str(res))
The original list : ['gfg', 'is', 'best']
Length of minimum string is : 2

Python list-programs
Python
Python Programs
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
Python String | replace()
How to Install PIP on Windows ?
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Results of comparison operations in C and C++

28 May, 2017
In C, data type of result of comparison operations is int. For example, see the following program.
#include<stdio.h>int main(){    int x = 10, y = 10;    printf("%d \n", sizeof(x == y));    printf("%d \n", sizeof(x < y));    return 0;}
Output:
4
4
Whereas in C++, type of results of comparison operations is bool. For example, see the following program.
#include<iostream>using namespace std;  int main(){    int x = 10, y = 10;    cout << sizeof(x == y) << endl;    cout << sizeof(x < y);    return 0;}
Output:
1
1
This article is contributed by Rajat. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
C-Operators
cpp-operator
C Language
C++
cpp-operator
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Function Pointer in C
std::string class in C++
Unordered Sets in C++ Standard Template Library
Memory Layout of C Programs
What is the purpose of a function prototype?
Vector in C++ STL
Map in C++ Standard Template Library (STL)
Initialize a vector in C++ (7 different ways)
Set in C++ Standard Template Library (STL)
Inheritance in C++
Python Program to replace list elements within a range with a given number

24 Jan, 2021
Given a range, the task here  is to write a python program that can update the list elements falling under a given index range with a specified number.
Input : test_list = [4, 6, 8, 1, 2, 9, 0, 10, 12, 3, 9, 1], i, j = 4, 8, K = 9
Output : [4, 6, 8, 1, 9, 9, 9, 9, 12, 3, 9, 1]
Explanation : List is updated with 9 from 4th to 8th index.
Input : test_list = [4, 6, 8, 1, 2, 9, 0, 10, 12, 3, 9, 1], i, j = 4, 8, K = 8
Output : [4, 6, 8, 1, 8, 8, 8, 8, 12, 3, 9, 1]
Explanation : List is updated with 8 from 4th to 8th index.
Method 1 : Using slicing and * operator
In this, we perform task of getting elements of range using slicing and * operator is used to perform update and provide required elements to fill updates.
Program:
Python3
# initializing listtest_list = [4, 6, 8, 1, 2, 9, 0, 10, 12, 3, 9, 1]  # printing original listprint("The original list is : " + str(test_list))  # initializing i, ji, j = 4, 8  # initializing KK = 9  # getting range using slicing and# required elements using * operatortest_list[i:j] = [K] * (j - i)  # printing resultprint("Range Updated list : " + str(test_list))
Output:
The original list is : [4, 6, 8, 1, 2, 9, 0, 10, 12, 3, 9, 1]
Range Updated list : [4, 6, 8, 1, 2, 9, 0, 10, 12, 3, 9, 1, 9]
Method 2 : Using repeat() and list slicing
The similar task can also be performed using repeat(), which uses unbuilt constructs to get required elements.
Program:
Python3
from itertools import repeat  # initializing listtest_list = [4, 6, 8, 1, 2, 9, 0, 10, 12, 3, 9, 1]  # printing original listprint("The original list is : " + str(test_list))  # initializing i, ji, j = 4, 8  # initializing KK = 9  # getting range using slicing and# required elements using repeat()test_list[i:j] = repeat(K, (j - i))  # printing resultprint("Range Updated list : " + str(test_list))
Output:
The original list is : [4, 6, 8, 1, 2, 9, 0, 10, 12, 3, 9, 1]
Range Updated list : [4, 6, 8, 1, 2, 9, 0, 10, 12, 3, 9, 1, 9]
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 ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Split string into list of characters
Python end parameter in print()

24 Jun, 2022
By default python’s print() function ends with a newline. A programmer with C/C++ background may wonder how to print without newline. Python’s print() function comes with a parameter called ‘end’. By default, the value of this parameter is ‘\n’, i.e. the new line character. You can end a print statement with any character/string using this parameter. 
Python3
# This Python program must be run with# Python 3 as it won't work with 2.7. # ends the output with a <space>print("Welcome to" , end = ' ')print("GeeksforGeeks", end = ' ')
Output :
Welcome to GeeksforGeeks
One more program to demonstrate working of end parameter. 
Python3
# This Python program must be run with# Python 3 as it won't work with 2.7. # ends the output with '@'print("Python" , end = '@')print("GeeksforGeeks")
Output :
Python@GeeksforGeeks
The print() function uses sep parameter to separate the arguments and ends after the last argument. For example,
Example of end parameter along with sep in print() function.
Python3
print('G','F', sep='', end='')print('G')#\n provides new line after printing the yearprint('09','12','2016', sep='-', end='\n')  print('Red','Green','Blue', sep=',', end='@')print('geeksforgeeks')
Output:
print('G','F', sep='', end='')
print('G')
#\n provides new line after printing the year
print('09','12','2016', sep='-', end='\n')
 
print('Red','Green','Blue', sep=',', end='@')
print('geeksforgeeks')
This article is contributed by Ankit Bindal. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to review-team@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
sagar utekar
sheetal18june
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How can we write a multiline lambda expression in Java?

Lambda expression is an anonymous method that has used to provide an implementation of a method defined by a functional interface. In Java 8, it is also possible for the body of a lambda expression to be a complex expression or statement, which means a lambda expression consisting of more than one line. In that case, the semicolons are necessary. If the lambda expression returns a result then the return keyword is also required.
([comma seperated argument-list]) -> { multiline statements }
interface Employee {
   String displayName(String s);
}
public class MultilineLambdaTest {
   public static void main(String[] s) {
      Employee emp = (x) -> {     // Lambda Expression with multiple lines
         x = "Jai " + x;
         System.out.println(x);
         return x;
      };
      emp.displayName("Adithya");
   }
}
Jai Adithya
Python program to mask a list using values from another list

05 Apr, 2021
Given two lists, the task is to write a python program that marks 1 for elements present in the other list else mark 0.
Input : test_list = [5, 2, 1, 9, 8, 0, 4], search_list = [1, 10, 8, 3, 9]
Output : [0, 0, 1, 1, 1, 0, 0]
Explanation : 1, 9, 8 are present in test_list at position 2, 3, 4 and are masked by 1. Rest are masked by 0.
Input : test_list = [5, 2, 1, 19, 8, 0, 4], search_list = [1, 10, 8, 3, 9]
Output : [0, 0, 1, 0, 1, 0, 0]
Explanation : 1, 8 are present in test_list at position 2, 4 and are masked by 1. Rest are masked by 0.
Method #1: Using list comprehension
In this, we iterate through search list and in operator used to check composition using list comprehension and assign 1 for presence and 0 for absence.
Python3
# Python3 code to demonstrate working of# Boolean composition mask in list# Using list comprehension  # initializing listtest_list = [5, 2, 1, 9, 8, 0, 4]  # printing original listprint("The original list is : " + str(test_list))  # initializing search listsearch_list = [1, 10, 8, 3, 9]  # list comprehension iteration and in operator# checking compositionres = [1 if ele in search_list else 0 for ele in test_list]  # printing resultprint("The Boolean Masked list : " + str(res))
Output:
The original list is : [5, 2, 1, 9, 8, 0, 4]
The Boolean Masked list : [0, 0, 1, 1, 1, 0, 0]
Method #2: Using set() + list comprehension
In this, duplicate elements are removed from the search list to reduce search space using set(). Rest all the operations are similar to the above method.
Python3
# Python3 code to demonstrate working of# Boolean composition mask in list# Using set() + list comprehension  # initializing listtest_list = [5, 2, 1, 9, 8, 0, 4]  # printing original listprint("The original list is : " + str(test_list))  # initializing search listsearch_list = [1, 10, 8, 3, 9]  # list comprehension iteration and in operator# checking composition# set() removes duplicatesres = [1 if ele in set(search_list) else 0 for ele in test_list]  # printing resultprint("The Boolean Masked list : " + str(res))
Output:
The original list is : [5, 2, 1, 9, 8, 0, 4]
The Boolean Masked list : [0, 0, 1, 1, 1, 0, 0]
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 ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
JavaScript | Generator.prototype.next() Method

16 Apr, 2020
The Generator.prototype.next() method is an inbuilt method in JavaScript which is used to return an object with two properties done and value.
Syntax:
gen.next( value );
Parameters: This function accepts single parameter as mentioned above and described below:
value: This parameter holds the value to be sent to the generator.
Return value: This method returns an object containing two properties:
done: It has the valuetrue – for the iterator which past the end of the iterated sequence.false – for the iterator which are able to produce the next value in the sequence.value: It contains any JavaScript value which is returned by the iterator.
done: It has the valuetrue – for the iterator which past the end of the iterated sequence.false – for the iterator which are able to produce the next value in the sequence.
true – for the iterator which past the end of the iterated sequence.
false – for the iterator which are able to produce the next value in the sequence.
value: It contains any JavaScript value which is returned by the iterator.
Below examples illustrate the Generator.prototype.next() method in JavaScript:
Example 1:
function* GFG() {   yield "GeeksforGeeks";  yield "JavaScript";  yield "Generator.prototype.next()";}  const geek = GFG(); console.log(geek.next());      console.log(geek.next());      console.log(geek.next());     console.log(geek.next());  
Output:
Object { value: "GeeksforGeeks", done: false }
Object { value: "JavaScript", done: false }
Object { value: "Generator.prototype.next()", done: false }
Object { value: undefined, done: true }

Example 2:
function* GFG(len, list) {    let result = [];    let val = 0;        while (val < list.length) {        result = [];        let i = val        while(i < val + len)          {            if (list[i]) {                result.push(list[i]);            }           i+=1        }            yield result;        val += len;    }}list = [    'geeks1','geeks2','geeks3',    'geeks4','geeks5','geeks6',    'geeks7','geeks8','geeks9',    'geeks10','geeks11'];  var geek = GFG(4, list);                  document.writeln(geek.next().value+"<br>");      document.writeln(geek.next().value+"<br>");    document.writeln(geek.next().value+"<br>");    document.writeln(geek.next().value+"<br>");
Output:
geeks1,geeks2,geeks3,geeks4
geeks5,geeks6,geeks7,geeks8
geeks9,geeks10,geeks11
undefined
Supported Browsers: The browsers supported by Generator.prototype.next() method are listed below:
Google Chrome
Firefox
Opera
Safari
Edge
javascript-functions
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Converting HTML to Text with BeautifulSoup

16 Apr, 2021
Many times while working with web automation we need to convert HTML code into Text. This can be done using the BeautifulSoup. This module provides get_text() function that takes HTML as input and returns text as output.
Example 1:
Python3
# importing the libraryfrom bs4 import BeautifulSoup # Initializing variablegfg = BeautifulSoup("<b>Section </b><br/>BeautifulSoup<ul>\<li>Example <b>1</b></li>") # Calculating resultres = gfg.get_text() # Printing the resultprint(res)
 
 
Output:
 
Section BeautifulSoupExample 1
 
Example 2: This example extracts data from the live website then converts it into text. In this example, we used the request module from urllib library to read HTML data from URL.
 
Python3
# importing the libraryfrom bs4 import BeautifulSoupfrom urllib import request # Initializing variableurl = "https://www.geeksforgeeks.org/matrix-introduction/"gfg = BeautifulSoup(request.urlopen(url).read()) # Extracting data for article sectionbodyHtml = gfg.find('article', {'class' : 'content'}) # Calculating resultres = bodyHtml.get_text() # Printing the resultprint(res)
Output:
arorakashish0911
Picked
Python BeautifulSoup
Python bs4-Exercises
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
How to put the caption below the table using CSS ?

25 Mar, 2021
To put the caption below the table we can use the CSS caption-side property. This property is used to specify the position where the table caption is placed. It is used in HTML Tables. 
This property can be used with any element whose display property set to caption-side. There are several parameters for this property, but we have been asked to put the caption below the table, so we will use a single parameter value that is bottom.
Syntax:
caption-side: bottom;
Example:
HTML
<!DOCTYPE html> <html>     <head>         <title>caption-side property</title>         <style>             .geeks {                 caption-side: bottom;             }         </style>     </head>     <body>         <center>             <h1 style="color:green;">GeeksForGeeks</h1>             <h2>caption-side: bottom:</h2>             <table class="geeks" border="1">                 <caption>Table 4.1 Student Details</caption>                 <tr>                     <th>Student Name</th>                     <th>Enroll_no.</th>                     <th>Address</th>                 </tr>                 <tr>                     <td>Hritik Bhatnagar</td>                     <td>234</td>                     <td>Delhi</td>                 </tr>                 <tr>                     <td>Govind madan</td>                     <td>235</td>                     <td>kolkata</td>                 </tr>                 <tr>                     <td>Suraj Roy</td>                     <td>236</td>                     <td>Mumbai</td>                 </tr>                 <tr>                     <td> Dhruv Mishra</td>                     <td>237</td>                     <td>Dehadun</td>                 </tr>             </table>         </center>     </body> </html>                     
Output:
caption
CSS-Basics
CSS-Properties
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
Build a Survey Form using HTML and CSS
Design a web page using HTML and CSS
Form validation using jQuery
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to remove the axis tick marks on a Seaborn heatmap?

To remove the axis tick marks on a Seaborn heatmap, we can take the following steps
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Create random data points with 4×4 dimension.
Create random data points with 4×4 dimension.
Plot the rectangular data as a color-encoded matrix.
Plot the rectangular data as a color-encoded matrix.
Use tick_params() for changing the appearance of ticks and tick labels. Use left=false and bottom=false to remove the tick marks.
Use tick_params() for changing the appearance of ticks and tick labels. Use left=false and bottom=false to remove the tick marks.
To display the figure, use Show() method.
To display the figure, use Show() method.
import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt

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

data = np.random.rand(4, 4)

ax = sns.heatmap(data, vmax=1)
ax.tick_params(left=False, bottom=False)

plt.show()
It will display the following Output −
C Program to print environment variables

20 May, 2017
The C standard says following about main function in C.
The function called at program startup is named main. The 
implementation declares no prototype for this function. It shall 
be defined with a return type of int and with no parameters:
       int main(void) { /* ... */ }
or with two parameters (referred to here as argc and argv, though 
any names may be used, as they are local to the function in which
they are declared):
       int main(int argc, char *argv[]) { /* ... */ }
or equivalent;10) or in some other implementation-defined manner.
But most of the compilers also support a third declaration of main that accepts third argument. The third argument stores all environment variables.
#include <stdio.h>  // Most of the C compilers support a third parameter to main which// store all envorinment variablesint main(int argc, char *argv[], char * envp[]){    int i;    for (i = 0; envp[i] != NULL; i++)        printf("\n%s", envp[i]);    getchar();    return 0;}
Output:
ALLUSERSPROFILE=C:\ProgramData
CommonProgramFiles=C:\Program Files\Common Files
HOMEDRIVE=C:
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 42 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=2a07
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
WATCOM=C:\watcom
windir=C:\Windows
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
C Basics
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Clojure - Case Statement

Clojure offers the ‘case’ statement which is similar to the ‘switch’ statement available in the Java programming language. Following is the general form of the case statement.
case expression
value1 statement #1
value2 statement #2
valueN statement #N
statement #Default

The general working of this statement is as follows −
The expression to be evaluated is placed in the ‘case’ statement. This generally will evaluate to a value, which is used in the subsequent statements.
The expression to be evaluated is placed in the ‘case’ statement. This generally will evaluate to a value, which is used in the subsequent statements.
Each value is evaluated against that which is passed by the ‘case’ expression. Depending on which value holds true, subsequent statement will be executed.
Each value is evaluated against that which is passed by the ‘case’ expression. Depending on which value holds true, subsequent statement will be executed.
There is also a default statement which gets executed if none of the prior values evaluate to be true.
There is also a default statement which gets executed if none of the prior values evaluate to be true.
Following diagram shows the flow of the ‘if’ statement.
Following is an example of the ‘case’ statement in Clojure.
(ns clojure.examples.hello
   (:gen-class))

;; This program displays Hello World
(defn Example []
   (def x 5) 
   (case x 5 (println "x is 5")
      10 (println "x is 10")
      (println "x is neither 5 nor 10")))
(Example)
In the above example, we are first initializing a variable ‘x’ to a value of 5. We then have a ‘case’ statement which evaluates the value of the variable ‘x’. Based on the value of the variable, it will execute the relevant case set of statements. The last statement is the default statement, if none of the previous statements are executed.
The above code produces the following output.
x is 5

 Print
 Add Notes
 Bookmark this page
How to read JSON file in Python

JSON stands for JavaScript Object Notation. It is commonly used for transmitting data in web applications( such as sending data from server to client to display on the web pages).
Example 1:
{
   "fruit": "Apple",
   "size": "Large",
   "color": "Red"
}
Example 2:
{
   'name': 'Karan',
   'languages': ['English', 'French']
}
The json file will have .json extension
Python has an in-built package called json which can be used to work with JSON data and to read JSON files. The json module has many functions among which load() and loads() are used to read the json files.
load() − This function is used to parse or read a json file.
loads() − This function is used to parse a json string.
To use json module in python, we need to import it first. The json module is imported as follows −
import json
Suppose we have json file named “persons.json” with contents as shown in Example 2 above. We want to open and read it using python. This can be done in following steps −
Import json module
Import json module
Open the file using the name of the json file witn open() function
Open the file using the name of the json file witn open() function
Open the file using the name of the json file witn open() function
Open the file using the name of the json file witn open() function
Read the json file using load() and put the json data into a variable.
Read the json file using load() and put the json data into a variable.
Use the data retrieved from the file or simply print it as in this case for simplicty.
Use the data retrieved from the file or simply print it as in this case for simplicty.
import json

with open('persons.json') as f:
   data = json.load(f)

print(data)
{'name': 'Karan', 'languages': ['English', 'French']}
Note:
Make sure the json file is saved with .json extension on your system.
Make sure the json file is saved with .json extension on your system.
Make sure the json file and the python program are saved in the same directory on your system, else an exception would be raised.
Make sure the json file and the python program are saved in the same directory on your system, else an exception would be raised.
How to pass an object as a parameter in JavaScript function?

To pass an object as a parameter in JavaScript, use this and prototype. You can try to run the following code to learn how to pass an object −
<html>
   <head>
      <script>
         var func = function(param1) {
            this.param1 = param1;
         };
         func.prototype.display = function() {
            return this.param1;
         };
         function display(val) {
            document.write(val());
         }
         var res = new func(99);

         display(res.display.bind(res));
      </script>
   </head>
</html>
Stack and Queue in C#

Stack class represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items.
The following is the property of Stack class −
Count− Gets the number of elements in the stack.
Count− Gets the number of elements in the stack.
The following are the methods of Stack class −
The following is an example showing how to work with Stack class and its Push() and Pop() method −
 Live Demo
using System;
using System.Collections;

namespace CollectionsApplication {
   class Program {
      static void Main(string[] args) {
         Stack st = new Stack();

         st.Push('A');
         st.Push('B');
         st.Push('C');
         st.Push('D');

         Console.WriteLine("Current stack: ");
         foreach (char c in st) {
            Console.Write(c + " ");
         }

         Console.WriteLine();

         st.Push('P');
         st.Push('Q');
         Console.WriteLine("The next poppable value in stack: {0}", st.Peek());
         Console.WriteLine("Current stack: ");

         foreach (char c in st) {
            Console.Write(c + " ");
         }
         Console.WriteLine();

         Console.WriteLine("Removing values....");
         st.Pop();
         st.Pop();
         st.Pop();

         Console.WriteLine("Current stack: ");
         foreach (char c in st) {
            Console.Write(c + " ");
         }
      }
   }
}
Current stack:
D C B A
The next poppable value in stack: Q
Current stack:
Q P D C B A
Removing values....
Current stack:
C B A
Queue collection class is a concept in C# that is included in the System.Collection namespace. The elements are stored in a QUEUE in FIFO. The first element added will be the first to go out like a queue of people outside a movie hall to buy tickets.
It has two methods −
Enqueue() method to add values
Dequeue() method to retrieve values
Add items in the queue.
Queue q = new Queue();
q.Enqueue(“Two”);
q.Enqueue(“One”);
Return items from the queue.
Queue q = new Queue();
q.Enqueue(“Two”);
q.Enqueue(“One”);

// remove elements
while (q.Count > 0)
Console.WriteLine(q.Dequeue());
How to Link Multiple Container in Docker ? - GeeksforGeeks

17 Jan, 2021
Docker is a free software created by Docker Inc. and it enables clients to create free and confined environments where the users can deploy their applications. 
A container is a standard unit of software that packages up code and all its dependencies from one computing environment and runs it quickly and reliably into another computing environment. 
Container linking allows multiple containers to link with each other. Linking the containers, provide a secure channel through which Docker containers can communicate with each other. This article describes the step-by-step process of container linking.
Installed docker software in your respective operating system.
Follow the below steps to link your c
Step 1:The first step is to download the Jenkins image from the docker hub repository using the below command:
sudo docker Jenkins pull
Step 2: Once you have downloaded the image, the next step is to run the container. Here you can also specify a name to the container using the name option. To do so follow the below command.
sudo docker run –name=jenkinsa -d jenkins
Step 3: Now after creating the source container, it’s time to launch the destination container. Along with launching the destination container, we will also link it with the source container. For our destination container, we will be using the standard Ubuntu image, you can also use any other image according to your convenience. Use the below command to launch and link the containers:
sudo docker run –name=jenkinsc –link=jenkinsa:alias-src -it ubuntu:latest /bin/bash
Step 4: You can use the below command to check which two containers are running.
sudo docker ps
Step 5: Now in this step we will attach to the receiving container using the below command.
sudo docker attach Jenkins
Step 6: After attaching to the receiving container you can run the below command and you will notice new variables for linking with the source container.
env
docker
How To
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
How to Install Jupyter Notebook on MacOS?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Create and Setup Spring Boot Project in Eclipse IDE?
How to Install Flutter on Visual Studio Code?
How to Check the OS Version in Linux?
How to Set Java Path in Windows and Linux?
How To Pass and Parse Linux Bash Script Arguments and Parameters
How to Install a local module using npm?
Tryit Editor v3.7

Tryit: The transition property
Sort list of dictionaries by values in C#

Firstly, let us create a dictionary −
var d = new Dictionary<string, int>(5);
Now add the key and value −
// add key and value
d.Add("car", 25);
d.Add("bus", 28);
d.Add("motorbike", 17);
Use orderby to order by values −
var val = from ele in d
orderby ele.Value ascending
select ele;
We have set ascending above to sort the dictionary in ascending order. You can also use descending.
Display the values in ascending order −
foreach (KeyValuePair ele in val) {
   Console.WriteLine("{0} = {1}", ele.Key, ele.Value);
}