code-rag-bench/online-tutorials huggingface dataset:
How to Use If Statement in Excel VBA? - GeeksforGeeks

19 Jul, 2021
VBA in Excel stands for Visual Basic for Applications which is Microsoft’s programming language. To optimize the performance and reduce the time in Excel we need Macros and VBA is the tool used in the backend.
In this article, we are going to use how to use the If statement in Excel VBA.
In the Microsoft Excel tabs, select the Developer Tab. Initially, the Developer Tab may not be available. 
The Developer Tab can be enabled easily by a two-step process :
Right-click on any of the existing tabs at the top of the Excel window.
Now select Customize the Ribbon from the pop-down menu.
In the Excel Options Box, check the box Developer to enable it and click on OK.
Now, the Developer Tab is visible.
Now click on the Visual Basic option in the Developer tab and make a new module to write the program using the Select Case statement.
Developer  -> Visual Basic -> Tools -> Macros
Now create a Macro and give any suitable name.
This will open the Editor window where can write the code.
The syntax is :
If condition/expression Then
Code Block for True value
Flow Diagram :
Example: Consider a company that wants to hire employees for a certain role. The company kept eligibility criteria as the age of the person. The age of the candidate who can apply for this interview must be less than 27 years.
Sub Allocate_Employee()
'Declaring and initializing the variable age
Dim age As Integer
age = 30
If age >= 27 Then
 MsgBox "You are not eligible for this post."
End If
End Sub
Output: 
Since, the age is 30, the IF condition becomes TRUE and the code block inside IF statement executes.
Some helpful links to get more insights about Macros, VBA in Excel :
Record Macros in Excel.How to Create a Macro in Excel?
Record Macros in Excel.
How to Create a Macro in Excel?
Picked
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Use Solver in Excel?
How to Find the Last Used Row and Column in Excel VBA?
How to Get Length of Array in Excel VBA?
Using CHOOSE Function along with VLOOKUP in Excel
Macros in Excel
Introduction to Excel Spreadsheet
How to Show Percentages in Stacked Column Chart in Excel?
How to Remove Duplicates From Array Using VBA in Excel?
How to Extract the Last Word From a Cell in Excel?
How to Calculate Deciles in Excel?
How to use if, else & elif in Python Lambda Functions - GeeksforGeeks

21 Feb, 2022
Lambda function can have multiple parameters but have only one expression. This one expression is evaluated and returned. Thus, We can use lambda functions as a function object. In this article, we will learn how to use if, else & elif in Lambda Functions.
The lambda function will return a value for every validated input. Here, if block will be returned when the condition is true, and else block will be returned when the condition is false. 
Syntax:
lambda <arguments> : <statement1> if <condition> else <statement2>
Here, the lambda function will return statement1 when if the condition is true and return statement2 when if the condition is false.
Example:
Here, We are going to find whether a number is even or odd. when we pass number 12 to lambda function it will execute statement 1 and statement2 for 11. 
Python3
# Use if-else in Lambda Functions # check if number is even or oddresult = lambda x : f"{x} is even" if x %2==0 else f"{x} is odd" # print for numbersprint(result(12))print(result(11))
12 is even
11 is odd
We can also use nested if, if-else in lambda function. Here we will create a lambda function to check if two number is equal or greater or lesser. We will implement this using the lambda function.
Syntax:
lambda <args> : <statement1> if <condition > ( <statement2> if <condition> else <statement3>)
Here, statement1 will be returned when if the condition is true, statement2 will be returned when elif true, and statement3 will be returned when else is executed. 
Example:
Here, we passed 2 numbers to the lambda function. and check the relation between them. That is if one number is greater or equal or lesser than another number
Python3
# Use if-else in Lambda Functions # check if two numbe is equal or greater or lesserresult = lambda x,y : f"{x} is smaller than {y}" \if x < y else (f"{x} is greater than {y}" if x > y \               else f"{x} is equal to {y}")  # print for numbersprint(result(12, 11))print(result(12, 12))print(result(12, 13))
  
12 is greater than 11
12 is equal to 12
12 is smaller than 13
 
sumitgumber28
Picked
python-lambda
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
MoviePy – Applying Resize effect on Video Clip - GeeksforGeeks

01 Aug, 2020
In this article we will see how we can apply resize effect on the video file clip in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. We can resize the video with the help of resize method to resize the video clip, resize filter is the type of filter applied on it.
In order to do this we will use fx method with the VideoFileClip object
Syntax : clip.fx( vfx.resize, width= 280)
Argument : It takes vfx object and width or height as optional argument
Return : It returns VideoFileClip object
Below is the implementation
# Import everything needed to edit video clipsfrom moviepy.editor import *   # loading video dsa gfg intro videoclip = VideoFileClip("dsa_geek.webm")   # getting only first 5 secondsclip = clip.subclip(0, 5)   # applying resize filterfinal = clip.fx( vfx.resize, width = 280)  # showing final clipfinal.ipython_display()
Output :
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4

Another example
# Import everything needed to edit video clipsfrom moviepy.editor import *  # loading video gfgclip = VideoFileClip("geeks.mp4")    # getting subclip from itclip = clip.subclip(0, 5)  # applying resize filterfinal = clip.fx( vfx.resize, width = 280)  # showing final clipfinal.ipython_display()
Output :
Moviepy - Building video __temp__.mp4.
MoviePy - Writing audio in __temp__TEMP_MPY_wvf_snd.mp3
                                                                                                                       
MoviePy - Done.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4


Python-MoviePy
Python
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
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
Convert integer to string in Python
Map of Sets in C++ STL with Examples - GeeksforGeeks

28 Oct, 2021
Maps are associative containers that store elements in a mapped fashion. Each element has a key value and a mapped value. No two mapped values can have same key values.
Sets are a type of associative container in which each element has to be unique because the value of the element identifies it. The value of the element cannot be modified once it is added to the set, though it is possible to remove and add the modified value of that element.
Map of Sets in STL: A map of sets can be very useful in designing complex data structures and algorithms.
Syntax:
map<datatype, set<datatype>> map_of_set : stores a set of numbers corresponding to a number
or
map<set<datatype>, datatype> map_of_set : stores a number corresponding to a set of numbers
Lets see how to implement Maps of Sets in C++:
C++
// C++ program to demonstrate use of map of set  #include <bits/stdc++.h>using namespace std;  void show(map<int, set<string> >& mapOfSet){    // Using iterator to access    // key, value pairs present    // inside the mapOfSet    for (auto it = mapOfSet.begin();         it != mapOfSet.end();         it++) {          // Key is integer        cout << it->first << " => ";          // Value is a set of string        set<string> st = it->second;          // Strings will be printed        // in sorted order as set        // maintains the order        for (auto it = st.begin();             it != st.end(); it++) {            cout << (*it) << ' ';        }        cout << '\n';    }}  // Driver codeint main(){    // Declaring a map whose key    // is of integer type and    // value is a set of string    map<int, set<string> > mapOfSet;      // Inserting values in the    // set mapped with key 1    mapOfSet[1].insert("Geeks");    mapOfSet[1].insert("For");      // Set stores unique or    // distinct elements only    mapOfSet[1].insert("Geeks");      // Inserting values in the    // set mapped with key 2    mapOfSet[2].insert("Is");    mapOfSet[2].insert("The");      // Inserting values in the    // set mapped with key 3    mapOfSet[3].insert("Great");    mapOfSet[3].insert("Learning");      // Inserting values in the    // set mapped with key 4    mapOfSet[4].insert("Platform");      show(mapOfSet);      return 0;}
1 => For Geeks 
2 => Is The 
3 => Great Learning 
4 => Platform 

cpp-map
cpp-set
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Friend class and function in C++
Sorting a vector in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Inline Functions in C++
Queue in C++ Standard Template Library (STL)
Array of Strings in C++ (5 Different Ways to Create)
Convert string to char array in C++
C Program For Writing A Function To Delete A Linked List - GeeksforGeeks

08 Dec, 2021
Algorithm For C:Iterate through the linked list and delete all the nodes one by one. The main point here is not to access the next of the current pointer if the current pointer is deleted.
Implementation:
C
// C program to delete a linked list#include<stdio.h>#include<stdlib.h>#include<assert.h>  // Link list node struct Node{    int data;    struct Node* next;};  // Function to delete the entire // linked list void deleteList(struct Node** head_ref){   // define head_ref to get the real head   struct Node* current = *head_ref;   struct Node* next;     while (current != NULL)    {       next = current->next;       free(current);       current = next;   }       // Define head_ref to affect the real    // head back in the caller.    *head_ref = NULL;}  /* Given a reference (pointer to pointer) to    the head of a list and an int, push a new    node on the front of the list. */void push(struct Node** head_ref,           int new_data){    // Allocate node     struct Node* new_node =           (struct Node*) malloc(sizeof(struct Node));      // Put in the data      new_node->data  = new_data;         // Link the old list off the new node     new_node->next = (*head_ref);         // Move the head to point to the new node     (*head_ref)    = new_node;}  // Driver codeint main(){    // Start with the empty list     struct Node* head = NULL;         // Use push() to construct list    // 1->12->1->4->1      push(&head, 1);    push(&head, 4);    push(&head, 1);     push(&head, 12);    push(&head, 1);            printf("Deleting linked list");    deleteList(&head);           printf("Linked list deleted");}
Output:
Deleting linked list
Linked list deleted
Time Complexity: O(n) Auxiliary Space: O(1)
Please refer complete article on Write a function to delete a Linked List for more details!
Delete a Linked List
Linked Lists
C Language
C Programs
Linked List
Linked List
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
TCP Server-Client implementation in C
Exception Handling in C++
Multithreading in C
'this' pointer in C++
Arrow operator -> in C/C++ with Examples
Strings in C
Arrow operator -> in C/C++ with Examples
C Program to read contents of Whole File
Header files in C/C++ and its uses
Basics of File Handling in C
Intersection of two dataframe in Pandas - Python - GeeksforGeeks

26 Jul, 2020
Intersection of Two data frames in Pandas can be easily calculated by using the pre-defined function merge(). This function takes both the data frames as argument and returns the intersection between them.
Syntax:
pd.merge(df1, df2, how)
Example 1:
import pandas as pd  # Creating Data framesdf1 = {'A': [1, 2, 3, 4],         'B': ['abc', 'def', 'efg', 'ghi']} df2 = {'A': [1, 2, 3, 4 ],         'B': ['Geeks', 'For', 'efg', 'ghi'],         'C':['Nikhil', 'Rishabh', 'Rahul', 'Shubham']}            d1 = pd.DataFrame(df1)d2 = pd.DataFrame(df2)   # Calling merge() functionint_df = pd.merge(d1, d2, how ='inner', on =['A', 'B'])print(int_df)
Output:
   A    B        C
0  3  efg    Rahul
1  4  ghi  Shubham

Example 2:
import pandas as pd  # Creating Data framesdf1 = {'A': [1, 2, 3, 4],         'B': ['Geeks', 'For', 'efg', 'ghi']} df2 = {'A': [1, 2, 3, 4 ],         'B': ['Geeks', 'For', 'abc', 'cde'],         'C':['Nikhil', 'Rishabh', 'Rahul', 'Shubham']}            d1 = pd.DataFrame(df1)d2 = pd.DataFrame(df2)   # Calling merge() functionint_df = pd.merge(d1, d2, how='inner', on=['A', 'B'])print(int_df)
Output:
   A      B        C
0  1  Geeks   Nikhil
1  2    For  Rishabh

Python pandas-dataFrame
Python-pandas
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 find the minimum and maximum element of a Vector using STL in C++? - GeeksforGeeks

20 Mar, 2019
Given a vector, find the minimum and maximum element of this vector using STL in C++.
Example:
Input: {1, 45, 54, 71, 76, 12}
Output: min = 1, max = 76

Input: {10, 7, 5, 4, 6, 12}
Output: min = 1, max = 76

Approach:
Min or Minimum element can be found with the help of *min_element() function provided in STL.
Max or Maximum element can be found with the help of *max_element() function provided in STL.
Syntax:
*min_element (first_index, last_index);

*max_element (first_index, last_index);

Below is the implementation of the above approach:
// C++ program to find the min and max element// of Vector using *min_element() in STL  #include <bits/stdc++.h>using namespace std;  int main(){    // Get the vector    vector<int> a = { 1, 45, 54, 71, 76, 12 };      // Print the vector    cout << "Vector: ";    for (int i = 0; i < a.size(); i++)        cout << a[i] << " ";    cout << endl;      // Find the min element    cout << "\nMin Element = "         << *min_element(a.begin(), a.end());      // Find the max element    cout << "\nMax Element = "         << *max_element(a.begin(), a.end());    return 0;}
Vector: 1 45 54 71 76 12 

Min Element = 1
Max Element = 76

cpp-vector
STL
C++
C++ Programs
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in C++
Map in C++ Standard Template Library (STL)
C++ Classes and Objects
Virtual Function in C++
Bitwise Operators in C/C++
Header files in C/C++ and its uses
Program to print ASCII Value of a character
How to return multiple values from a function in C or C++?
C++ Program for QuickSort
Sorting a Map by value in C++ STL
Algorithms | Misc | Question 11 - GeeksforGeeks

28 Jun, 2021
Given 8 identical coins out of which one coin is heavy and a pan balance. How many minimum number of measurements are needed to find the heavy coin?(A) 2(B) 3(C) 4(D) 7Answer: (A)Explanation:
Divide the coins into three groups and name the coins according to there group:
A: A1, A2, A3
B: B1, B2, B3
C: C1, C2

Measure group A and group B. Two cases arise:
1. They are equal. One more measurement is needed to find the heavy 
   coin in group C. Total two measurements needed in this case.
2. They are not equal. Find the heavy group, say A. Pick any two coins
   from this group,  say A1 and A3. Measure A1 and A3 in the pan balance. 
   Two cases arise:
   2.1 They are equal. A2 is the heavy coin. Total two measurements 
       needed.
   2.2 They are not equal. It is known which of A1 or A3 is heavy. 
       Total two measurements needed.
So, the above observations says that in any case, 2 measurements are enough
to find the heavy coin.

Follow up:
Generalize the minimum number of measurements for n coins 
with one coin heavy.

Quiz of this Question
Algorithms-Misc
Misc
Algorithms Quiz
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Algorithms | Graph Traversals | Question 2
Algorithms | Graph Traversals | Question 12
Algorithms | Analysis of Algorithms | Question 17
Algorithms | Recursion | Question 2
Algorithms | Recursion | Question 5
Algorithms | Backtracking | Question 1
Algorithms | Recursion | Question 3
Algorithms | Recursion | Question 4
Algorithms | NP Complete | Question 2
Algorithms | NP Complete | Question 1
How to design a responsive website?

A responsive website is a website that looks good and amazing on all devices i.e. desktops, tablets, and cell phones. A website should have a responsive design to make it responsive. It’s all about playing around with HTML and CSS for changing the size, hiding, or enlarging the screen.
Let’s see an example and what does responsive means while resizing a website,
The website design on Desktop −
The website design looks like this on a tablet. You can easily compare the changes with the above shown desktop screenshot −
The website design looks like this on Mobile −
To develop a responsive website, which looks good irrespective of the device size, you need to work on the following concepts −
A viewport is used to control layout on mobile browsers. It is used inside the <meta> tag to give the browser instructions on how to work for controlling the web page’s dimensions and scaling.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Here, 
The width=device-width sets the width of the page in order to follow the screen-width of the device. The initial-scale=1.0 is to set the initial zoom level. This helps when the page gets loaded by the web browser for the first time.
With Media queries, add a breakpoint where some parts of the design behave differently on each side of the breakpoint. 
For images to be responsive, you need to set the width property to 100% and height to auto.
numpy.rollaxis

This function rolls the specified axis backwards, until it lies in a specified position. The function takes three parameters.
numpy.rollaxis(arr, axis, start)

Where,
arr
Input array
axis
Axis to roll backwards. The position of the other axes do not change relative to one another
start
Zero by default leading to the complete roll. Rolls until it reaches the specified position
# It creates 3 dimensional ndarray 
import numpy as np 
a = np.arange(8).reshape(2,2,2) 

print 'The original array:' 
print a 
print '\n'
# to roll axis-2 to axis-0 (along width to along depth) 

print 'After applying rollaxis function:' 
print np.rollaxis(a,2)  
# to roll axis 0 to 1 (along width to height) 
print '\n' 

print 'After applying rollaxis function:' 
print np.rollaxis(a,2,1)
Its output is as follows −
The original array:
[[[0 1]
 [2 3]]
 [[4 5]
 [6 7]]]

After applying rollaxis function:
[[[0 2]
 [4 6]]
 [[1 3]
 [5 7]]]

After applying rollaxis function:
[[[0 2]
 [1 3]]
 [[4 6]
 [5 7]]]


    63 Lectures 
     6 hours 

 Abhilash Nelson

    19 Lectures 
     8 hours 

 DATAhill Solutions Srinivas Reddy

    12 Lectures 
     3 hours 

 DATAhill Solutions Srinivas Reddy

    10 Lectures 
     2.5 hours 

 Akbar Khan

    20 Lectures 
     2 hours 

 Pruthviraja L

    63 Lectures 
     6 hours 

 Anmol
 Print
 Add Notes
 Bookmark this page
GATE | GATE-CS-2016 (Set 1) | Question 42 - GeeksforGeeks

30 Sep, 2021
The stage delays in a 4-stage pipeline are 800, 500, 400 and 300 picoseconds. The first stage (with delay 800 picoseconds) is replaced with a functionally equivalent design involving two stages with respective delays 600 and 350 picoseconds. The throughput increase of the pipeline is _______ percent.
[This Question was originally a Fill-in-the-Blanks question](A) 33 or 34(B) 30 or 31(C) 38 or 39(D) 100Answer: (A)Explanation:
Throughput of 1st case T1: 1/max delay =1/800
Throughput of 2nd case T2: 1/max delay= 1/600
%age increase in throughput: (T2-T1)/T1
            = ( (1/600) - (1/800) ) / (1/800)
            = 33.33%
YouTubeGeeksforGeeks GATE Computer Science16.1K subscribersPipelining: Previous Year Question part-IV | COA | GeeksforGeeks GATE | Harshit NigamWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:007:30 / 31:50•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=PmA5Ic9vc9o" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
aparimeet
GATE-CS-2016 (Set 1)
GATE-GATE-CS-2016 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2015 (Set 3) | Question 65
C++ Program to count Vowels in a string using Pointer
GATE | GATE-CS-2014-(Set-1) | Question 65
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2015 (Set 1) | Question 42
Highlight Pandas DataFrame's specific columns using applymap() - GeeksforGeeks

17 Aug, 2020
Let us see how to highlight elements and specific columns of a Pandas DataFrame. We can do this using the applymap() function of the Styler class.
Syntax : Styler.applymap(self, func, subset = None, **kwargs)
Parameters :
func : takes a scalar and returns a scalar.
subset : valid indexer to limit data to before applying the function.
**kwargs : dict pass along to func.
Returns : Styler
Let’s understand with examples:
First of all create a simple data frame:
# importing pandas as pd import pandas as pd   # creating the dataframe  df = pd.DataFrame({"A" : [14, 4, 5, 4, 1],                    "B" : [5, 2, 54, 3, 2],                   "C" : [20, 20, 7, 3, 8],                   "D" : [14, 3, 6, 2, 6]})   print("Original DataFrame :")display(df)
Output :
Example 1 : For every cell in the DataFrame, if the value is less than 6 then we will highlight the cell with red color, otherwise with blue color.
# function definitiondef highlight_cols(s):    color = 'red' if s < 6 else 'blue'    return 'background-color: % s' % color  # highlighting the cellsdisplay(df.style.applymap(highlight_cols))
Output :
Example 2 : This time we will highlight only the cells in some specified columns.
# function definitiondef highlight_cols(s):    return 'background-color: % s' % 'yellow'  # highlighting the cellsdisplay(df.style.applymap(highlight_cols,                           subset = pd.IndexSlice[:, ['B', 'C']]))
Output :
Highlight specific columns with the help of Indexing:
Python3
df.style.applymap(highlight_cols, subset = pd.IndexSlice[:, ['B', 'C']])
Python pandas-dataFrame
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Defaultdict in Python
How to Install PIP on Windows ?
Deque in Python
Bar Plot in Matplotlib
Check if element exists in list in Python
Python math function | sqrt()
Python | Output Formatting
Python - Pandas dataframe.append()
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Computer Organization and Architecture - GeeksforGeeks

19 Nov, 2018
     MBR ← PC 
     MAR ← X  
     PC ← Y  
     Memory ← MBR
Pipeline will have to be stalled till Ei stage of l4 completes, 
as Ei stage will tell whether to take branch or not. 

After that l4(WO) and l9(Fi) can go in parallel and later the
following instructions.
So, till l4(Ei) completes : 7 cycles * (10 + 1 ) ns = 77ns
From l4(WO) or l9(Fi) to l12(WO) : 8 cycles * (10 + 1)ns = 88ns
Total = 77 + 88 = 165 ns
RAM chip size = 1k ×8[1024 words of 8 bits each]
RAM to construct =16k ×16
Number of chips required = (16k x 16)/ ( 1k x 8)
                         = (16 x 2)
[16 chips vertically with each having 2 chips
horizontally]
So to select one chip out of 16 vertical chips, 
we need 4 x 16 decoder.

Available decoder is  2 x 4 decoder
To be constructed is 4 x 16 decoder

Hence 4 + 1 = 5 decoders are required.
   c = a + b;
   d = c * a;
   e = c + a;
   x = c * c;
   if (x > a) {
      y = a * a;
   }
   else {
     d = d * d;
     e = e * e;
  }
r1......r2
a.......b......c = a + b
a.......c......x = c * c
a.......x......but we will have to store c in mem as we don't know if x > a
................. or not
y.......x......y = a * a
choosing the best case of x > a , min spills = 1 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Best Time to Buy and Sell Stock
Must Do Coding Questions for Product Based Companies
How to calculate MOVING AVERAGE in a Pandas DataFrame?
What is Transmission Control Protocol (TCP)?
How to Calculate Number of Host in a Subnet?
Python OpenCV - Canny() Function
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
How to read any request header in PHP - GeeksforGeeks

13 Nov, 2018
HTTP Header: HTTP headers are the code that transfers the data between web server and browser. The HTTP headers are mainly intended for the communication between the server and the client in both directions.
HTTP Request Header: When type a URL in the address bar of browser and try to access it, the browser sends an HTTP request to the server. The HTTP request header contains information in a text-record form, which includes many useful informations such as the type, capabilities, and version of the browser that generates the request, the operating system used by the client, the page that was requested, the various types of outputs accepted by the browser, and so on. Receiving the request header, the web server will send an HTTP response header back to the client.
Read any request header: It can be achieved by using getallheaders() function.
Example 1:
<?phpforeach (getallheaders() as $name => $value) {    echo "$name: $value <br>";}?>
Output:
Host: 127.0.0.3:2025 
Connection: keep-alive 
Cache-Control: max-age=0 
Upgrade-Insecure-Requests: 1 
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, 
like Gecko) Chrome/70.0.3538.67 Safari/537.36 
Accept: text/html, application/xhtml+xml, application/xml;q=0.9, 
image/webp, image/apng, */*;q=0.8 
Accept-Encoding: gzip, deflate, br 
Accept-Language: en-US, en;q=0.9 

Example 2: It can be achieved by using apache_request_headers() function.
<?php$header = apache_request_headers();  foreach ($header as $headers => $value) {    echo "$headers: $value <br />\n";}?>
Host: 127.0.0.6:2027 
Connection: keep-alive 
Cache-Control: max-age=0 
Upgrade-Insecure-Requests: 1 
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/70.0.3538.67 Safari/537.36 
Accept: text/html, application/xhtml+xml, application/xml;q=0.9, 
image/webp, image/apng, */*;q=0.8 
Accept-Encoding: gzip, deflate, br 
Accept-Language: en-US, en;q=0.9 

Reference: http://php.net/manual/en/function.header.php
Picked
Technical Scripter 2018
PHP
PHP Programs
Technical Scripter
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 ?
PHP | Converting string to Date and DateTime
Comparing two dates in PHP
How to receive JSON POST with PHP ?
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
Comparing two dates in PHP
How to pass JavaScript variables to PHP ?
Split a comma delimited string into an array in PHP
HTML | <input type="checkbox"> - GeeksforGeeks

28 May, 2019
the HTML <input type=”checkbox”> is used to define a checkbox field. The checkbox is shown as a square box that is ticked when it is activated. It allows the user to select one or more option among all the limited choices.
Syntax:
<input type="checkbox"> 
Example:
<!DOCTYPE html><html>  <head>    <title>        Input type = "checkbox"    </title></head>  <body style="text-align: center;">      <h1 style="color:green;">             GeeksforGeeks         </h1>      <h2><input type="checkbox"></h2>      <form>          <!-- Below input elements have attribute                 checked -->        <input type="checkbox"               name="check"               id="GFG"                value="1"                checked>      Checked by default        <br>        <input type="checkbox"                name="check"               value="2">       Not checked by default        <br>    </form>    <br>  </body>  </html>
Output:
Supported Browsers:
Google Chrome
Firefox
Edge
Opera
Apple Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
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 ?
Difference between var, let and const keywords in JavaScript
How to Install Seaborn on Windows? - GeeksforGeeks

09 Sep, 2021
In this article, we will look into the process of installing Python Seaborn on Windows.
Python
PIP or conda (Depending upon user preference)
PIP users can open up the command prompt and run the below command to install Python Seaborn Package on Windows:
pip install Seaborn
The following message will be shown once the installation is completed:
To verify the installation use the below code in your python ide:
Python3
import seaborn as snssns.__version__
Output:
Conda users can open up the Anaconda Power Shell Prompt and use the below command to install Python Seaborn package on Windows:
conda install -c anaconda seaborn
The following message will be shown once the installation is completed:
To verify the installation use the below code in your python ide:
Python3
import seaborn as snssns.__version__
Output:
Blogathon-2021
how-to-install
Picked
Python-Seaborn
Blogathon
How To
Installation Guide
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Create a Table With Multiple Foreign Keys in SQL?
How to Import JSON Data into SQL Server?
Stratified Sampling in Pandas
How to Install Tkinter in Windows?
Python program to convert XML to Dictionary
How to Install PIP on Windows ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to install Jupyter Notebook on Windows?
How to Align Text in HTML?
How to Install OpenCV for Python on Windows?
Dice Rolling Simulator using Python-random - GeeksforGeeks

13 May, 2022
In this article, we will create a classic rolling dice simulator with the help of basic Python knowledge. Here we will be using the random module since we randomize the dice simulator for random outputs.
1) random.randint(): This function generates a random number in the given range. Below is the implementation.
Example 1: Dice Simulator
Python3
import random  x = "y"  while x == "y":         # Generates a random number    # between 1 and 6 (including    # both 1 and 6)    no = random.randint(1,6)         if no == 1:        print("[-----]")        print("[     ]")        print("[  0  ]")        print("[     ]")        print("[-----]")    if no == 2:        print("[-----]")        print("[ 0   ]")        print("[     ]")        print("[   0 ]")        print("[-----]")    if no == 3:        print("[-----]")        print("[     ]")        print("[0 0 0]")        print("[     ]")        print("[-----]")    if no == 4:        print("[-----]")        print("[0   0]")        print("[     ]")        print("[0   0]")        print("[-----]")    if no == 5:        print("[-----]")        print("[0   0]")        print("[  0  ]")        print("[0   0]")        print("[-----]")    if no == 6:        print("[-----]")        print("[0 0 0]")        print("[     ]")        print("[0 0 0]")        print("[-----]")             x=input("press y to roll again and n to exit:")    print("\n")
Output: 
Example 2: Dice simulator
Python
import randomwhile True:  print('''1.roll the dice    2.To exit ''')  user = int(input("what you want to do\n"))  if user==1:    number = random.randint(1,6)    print(number)  else:    break
Output:
 
 
varshagumber28
ayushcoding100
Python-random
Python
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()
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
sum() function in Python
HTML | data-* Attributes - GeeksforGeeks

03 May, 2021
Custom Data Attributes allow you to add your own information to tags in HTML. Even though the name suggests otherwise, these are not specific to HTML5 and you can use the data-* attribute on all HTML elements. The data-* attributes can be used to define our own custom data attributes. It is used to store custom data in private to the page or application. There are mainly 2 parts of the Data Attributes:  
Attribute Name: Must be at least one character long, contain no capital letters and be prefixed with ‘data-‘.Attribute Value: Can be any string.
Attribute Name: Must be at least one character long, contain no capital letters and be prefixed with ‘data-‘.
Attribute Value: Can be any string.
Syntax:  
<li data-book-author="Rabindra Nath Tagore"> Gitanjali </li>
Example:  
HTML
<!DOCTYPE html><html><head>    <script>        function showDetails(book) {            var bookauthor = book.getAttribute("data-book-author");            alert(book.innerHTML + " is written by "                                    + bookauthor + ".");        }    </script></head> <body>    <h1>Books</h1>     <p>Click on the book name to know author's name :</p>          <ul>        <li onclick="showDetails(this)" id="gitanjali"                data-book-author="Rabindra Nath Tagore">            Gitanjali        </li>                 <li onclick="showDetails(this)" id="conquest_of_self"                data-book-author="Mahatma Gandhi">            Conquest of Self        </li>                <li onclick="showDetails(this)" id="broken_wings"                data-book-author="Sarojini Naidu">            Broken Wings        </li>    </ul></body></html>                   
Output:  
When we click on the book, we can see the name of the author in a separate dialogue box.  
Supported Browsers: The browser supported by HTML | data-* Attribute
  are listed below:  
Google Chrome
Internet Explorer
Firefox
Safari
Opera
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
hritikbhatnagar2182
HTML-Attributes
Picked
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
How to apply style to parent if it has child with CSS?
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
Python – Insertion at the beginning in OrderedDict

15 Oct, 2021
Given an ordered dict, write a program to insert items in beginning of ordered dict.Examples –  
Input: 
original_dict = {'a':1, 'b':2}
item to be inserted ('c', 3)

Output:  {'c':3, 'a':1, 'b':2}

Input: 
original_dict = {'akshat':1, 'manjeet':2}
item to be inserted ('nikhil', 3)

Output:  {'nikhil':3, 'akshat':1, 'manjeet':2}
 Below are various methods to insert items in starting of ordered dict.Method #1: Using OrderedDict.move_to_end()  
Python3
# Python code to demonstrate# insertion of items in beginning of ordered dictfrom collections import OrderedDict # initialising ordered_dictiniordered_dict = OrderedDict([('akshat', '1'), ('nikhil', '2')]) # inserting items in starting of dictiniordered_dict.update({'manjeet':'3'})iniordered_dict.move_to_end('manjeet', last = False) # print resultprint ("Resultant Dictionary : "+str(iniordered_dict))
Output:  
Resultant Dictionary : OrderedDict([(‘manjeet’, ‘3’), (‘akshat’, ‘1’), (‘nikhil’, ‘2’)])  
  Method #2: Using Naive ApproachThis method only works in case of unique keys  
Python3
# Python code to demonstrate# insertion of items in beginning of ordered dictfrom collections import OrderedDict # initialising ordered_dictini_dict1 = OrderedDict([('akshat', '1'), ('nikhil', '2')])ini_dict2 = OrderedDict([("manjeet", '4'), ("akash", '4')]) # adding in beginning of dictboth = OrderedDict(list(ini_dict2.items()) + list(ini_dict1.items())) # print resultprint ("Resultant Dictionary :"+str(both))
Output:  
Resultant Dictionary :OrderedDict([(‘manjeet’, ‘4’), (‘akash’, ‘4’), (‘akshat’, ‘1’), (‘nikhil’, ‘2’)])  
 
anikakapoor
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Python OOPs Concepts
Introduction To PYTHON
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
Python | Convert string dictionary to dictionary
How to send email using PowerShell?

To send email using PowerShell, there are multiple methods but there is a simple command called SendMailMessage. This command is a part of the module called Microsoft.PowerShell.Utility
To send email using the specific SMTP server we need to add the SMTP server parameter.
Send-MailMessage `
   -From 'User1@TestDomain.com' `
   -To 'User2@TestDomain.com' `
   -Subject 'Test Email' `
   -SmtpServer 'Smtp.TestDomain.com'
In the above example, an email will be sent from the -From parameter, a user to -To parameter users with the subject name ‘Test Email’ with the specified SMTP server name.
If you have multiple users then you can separate them using a comma and you can also add CC and BCC recipients. For example,
Send-MailMessage `
   -From 'User1@TestDomain.com' `
   -To 'User2@TestDomain.com','User3@TestDomain.com' `
   -Cc 'Manager1@Testdomain.com' `
   -Bcc 'Manager2@testdomain.com'
   -Subject 'Test Email' `
   -Attachments 'C:\Temp\Confidential.pdf'
   -SmtpServer 'Smtp.TestDomain.com'
In the above example, an attachment will be stored from the location C:\temp.
If your SMTP server requires an SSL connection on the specific port then you can also specify it for example,
Send-MailMessage `
   -From 'User1@TestDomain.com' `
   -To 'User2@TestDomain.com','User3@TestDomain.com' `
   -Subject 'Test Email' `
   -SmtpServer 'Smtp.TestDomain.com' `
   -UseSsl -Port 587 -Priority High
We are using here SSL connection on the 587 port with a High Priority email. You can also set Priority to Normal (Default) or Low.
If your server using different SMTP credentials then you can provide credential parameters as well and you can also the Delivery Notification on Delay, Success, Failure, or Never. The default is None.
$creds = Get-Credential
Send-MailMessage `
   -From 'User1@TestDomain.com' `
   -To 'User2@TestDomain.com','User3@TestDomain.com' `
   -Subject 'Test Email' `
   -SmtpServer 'Smtp.TestDomain.com' `
   -UseSsl -Port 587 -Priority High `
   -Credential $creds `
   -DeliveryNotificationOption OnSuccess
GDB - Debugging Symbols

A Debugging Symbol Table maps instructions in the compiled binary program to their corresponding variable, function, or line in the source code. This mapping could be something like:
Program instruction ⇒ item name, item type, original file, line number defined.
Program instruction ⇒ item name, item type, original file, line number defined.
Symbol tables may be embedded into the program or stored as a separate file. So if you plan to debug your program, then it is required to create a symbol table which will have the required information to debug the program.
We can infer the following facts about symbol tables:
A symbol table works for a particular version of the program – if the program changes, a new table must be created.
A symbol table works for a particular version of the program – if the program changes, a new table must be created.
Debug builds are often larger and slower than retail (non-debug) builds; debug builds contain the symbol table and other ancillary information.
Debug builds are often larger and slower than retail (non-debug) builds; debug builds contain the symbol table and other ancillary information.
If you wish to debug a binary program you did not compile yourself, you must get the symbol tables from the author.
If you wish to debug a binary program you did not compile yourself, you must get the symbol tables from the author.
To let GDB be able to read all that information line by line from the symbol table, we need to compile it a bit differently. Normally we compile our programs as:
gcc hello.cc -o hello 

Instead of doing this, we need to compile with the -g flag as shown below:
gcc -g hello.cc -o hello 

 Print
 Add Notes
 Bookmark this page
How to Run a Cron Job Every Day on a Linux System

This article will teach you on, how to schedule a corn job for executing a script or command or shell script at a particular time every day. As a system administrator, we know the importance of running the routine maintenance jobs in the background automatically. The Linux corn utility will help us to maintain these jobs to run in the background.
MIN HOUR Day of month Month Day of Week Command
0-59 0-23 1-31 1-12 0-6 Any Linux command or script
To see a list of cron jobs which exists on the machine, run the below command –
# crontab -l
no crontab for root
To add the new cron job run the below command –
#crontab -e
no crontab for root - using an empty one
Select an editor. To change later, run 'select-editor'.
1. /bin/ed
2. /bin/nano <---- easiest
3. /usr/bin/vim.basic
4. /usr/bin/vim.tiny
Choose 1-4 [2]:2
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
Add the below example to execute the specified log backup shell script at 11:00 on every day. We can specify the comma-separated value in a field specifies that the script needs to be executed in all the mentioned time.
00 11 * * * /home/backups/scripts/log_backup.sh
Conclusion: At the end of the configuration you are able to run a script or command at a specific time every day, like this we can specify the time for multiple execution with comma separated values.
Split a document by its subdocuments in MongoDB

To split a document by its subdocuments, use $unwind in MongoDB. Let us create a collection with documents −
> db.demo276.insertOne({"Name":"Chris","Subjects":["MySQL","MongoDB"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e48f953dd099650a5401a51")
}
Display all documents from a collection with the help of find() method −
> db.demo276.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e48f953dd099650a5401a51"),
   "Name" : "Chris",
   "Subjects" : [
      "MySQL",
      "MongoDB"
   ]
}
Following is the query to split a document by its subdocuments −
> db.demo276.aggregate( [ { $unwind : "$Subjects" } ] )
This will produce the following output −
{ "_id" : ObjectId("5e48f953dd099650a5401a51"), "Name" : "Chris", "Subjects" : "MySQL" }
{ "_id" : ObjectId("5e48f953dd099650a5401a51"), "Name" : "Chris", "Subjects" : "MongoDB" }