code-rag-bench/online-tutorials huggingface dataset:
Vectors with Uniformly Spaced Elements

MATLAB allows you to create a vector with uniformly spaced elements.
To create a vector v with the first element f, last element l, and the difference between elements is any real number n, we write −
v = [f : n : l]

Create a script file with the following code −
v = [1: 2: 20];
sqv = v.^2;
disp(v);
disp(sqv);
When you run the file, it displays the following result −
1    3    5    7    9   11   13   15   17   19
   1     9    25    49    81   121   169   225   289   361


    30 Lectures 
     4 hours 

 Nouman Azam

    127 Lectures 
     12 hours 

 Nouman Azam

    17 Lectures 
     3 hours 

 Sanjeev

    37 Lectures 
     5 hours 

 TELCOMA Global

    22 Lectures 
     4 hours 

 TELCOMA Global

    18 Lectures 
     3 hours 

 Phinite Academy
 Print
 Add Notes
 Bookmark this page
How to count the number of columns in a table in Selenium with python?

We can count the number of columns in a table in Selenium. The headers
of a table are represented by <th> tag in html and always in the first row of the
table. The rows are identified with <tr> tag in html. The total count of the number
of column headers is mostly equal to the total number of columns. A <th> tag’s
parent is always a <tr> tag.
The logic is to get all the headers. We shall use the locator xpath and then use find_elements_by_xpath method. The list of headers will be returned. Next we need to compute the size of the list with the help of len method.
driver.find_elements_by_xpath("//table/tbody/tr[1]/th")
The html code snippet of a table column count is as described below −
Code Implementation for getting total column count.
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then
#invoke actual browser
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/plsql/plsql_basic_syntax.htm")
#to refresh the browser
driver.refresh()
# identifying the header from row1 having <th> tag
cols = driver.find_elements_by_xpath("//table/tbody/tr[1]/th")
# len method is used to get the size of that list
print(len(cols))
#to close the browser
driver.close()
Jackson Annotations - Mixin

Mixin Annotation is a way to associate annotations without modifying the target class. See the example below −
import java.io.IOException;

import com.fasterxml.jackson.annotation.JsonIgnoreType;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JacksonTester {
   public static void main(String args[]) {
      ObjectMapper mapper = new ObjectMapper();
      try {
         Student student = new Student(1,11,"1ab","Mark");       
         String jsonString = mapper
            .writerWithDefaultPrettyPrinter()
            .writeValueAsString(student);
         System.out.println(jsonString);

         ObjectMapper mapper1 = new ObjectMapper();
         mapper1.addMixIn(Name.class, MixInForIgnoreType.class);
         jsonString = mapper1
            .writerWithDefaultPrettyPrinter()
            .writeValueAsString(student);
         System.out.println(jsonString);
      }
      catch (IOException e) { 
         e.printStackTrace();
      }     
   }
}
class Student {
   public int id;
   public String systemId;
   public int rollNo;
   public Name nameObj;

   Student(int id, int rollNo, String systemId, String name) {
      this.id = id;
      this.systemId = systemId;
      this.rollNo = rollNo;
      nameObj = new Name(name);
   }
}
class Name {
   public String name;
   Name(String name){
      this.name = name;
   }       
}
@JsonIgnoreType
class MixInForIgnoreType {}
{
   "id" : 1,
   "systemId" : "1ab",
   "rollNo" : 11,
   "nameObj" : {
      "name" : "Mark"
   }
}
{
   "id" : 1,
   "systemId" : "1ab",
   "rollNo" : 11
}

 Print
 Add Notes
 Bookmark this page
Groovy - pop()

Removes the last item from this List.
Object pop() 

None
The popped value from the list.
Following is an example of the usage of this method −
class Example { 
   static void main(String[] args) { 
      def lst = [11, 12, 13, 14]; 

      println(lst.pop()); 
      println(lst); 
   } 
}
When we run the above program, we will get the following result −
14 
[11, 12, 13]


    52 Lectures 
     8 hours 

 Krishna Sakinala

    49 Lectures 
     2.5 hours 

 Packt Publishing
 Print
 Add Notes
 Bookmark this page
GATE | GATE-CS-2009 | Question 33 - GeeksforGeeks

28 Jun, 2021
The enter_CS() and leave_CS() functions to implement critical section of a process are realized using test-and-set instruction as follows:
void enter_CS(X)
{
    while test-and-set(X) ;
}
void leave_CS(X)
{
   X = 0;
}
In the above solution, X is a memory location associated with the CS and is initialized to 0. Now consider the following statements:I. The above solution to CS problem is deadlock-freeII. The solution is starvation free.III. The processes enter CS in FIFO order.IV More than one process can enter CS at the same time.
Which of the above statements is TRUE?
(A) I only(B) I and II(C) II and III(D) IV onlyAnswer: (A)Explanation: The above solution is a simple test-and-set solution that makes sure that deadlock doesn’t occur, but it doesn’t use any queue to avoid starvation or to have FIFO order.Quiz of this Question
GATE-CS-2009
GATE-GATE-CS-2009
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 71
GATE | GATE CS 2011 | Question 7
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2016 (Set 1) | Question 63
GATE | GATE-CS-2014-(Set-2) | Question 65
Tryit Editor v3.7

Tryit: HTML image size
Call a method on a Super Class in Scala - GeeksforGeeks

05 Aug, 2019
This concept is used when we want to call super class method. So whenever a base and subclass have same named methods then to resolve ambiguity we use super keyword to call base class method. The keyword “super” came into this with the concept of Inheritance.
Below is the example of call a method on a superclass.
Example #1:
// Scala program to call a method// on a superclass in Scala  /* Base class ComputerScience */class ComputerScience{    def read     {        println("I'm reading")    }    def write    {        println("I'm writing")    }}  /* Subclass Scala */class Scala extends ComputerScience{    // Note that readThanWrite() is only in Scala class     def readThanWrite()     {        // Will invoke or call parent class read() method         super.read                  // Will invoke or call parent class write() method         super.write    }}  // Creating object object Geeks{    // Main method     def main(args: Array[String])     {         var ob = new Scala();                  // Calling readThanWrite() of Scala        ob.readThanWrite();    } } 
I'm reading
I'm writing

In above example, we are calling multiple method of super class by using super keyword.
Example #2:
// Scala program to call a method// on a superclass in Scala  /* Super class Person */class Person {     def message()     {         println("This is person class");     }   }   /* Subclass Student */class Student extends Person {      override def message()    {         println("This is student class")    }          // Note that display() is only in Student class     def display()     {         // will invoke or call current class message() method          message ()                  // will invoke or call parent class message() method         super.message    } }   /* Creating object */object Geeks{     // Main method    def main(args: Array[String])     {         var s = new Student();           // Calling display() of Student         s.display();     } } 
This is student class
This is person class

In the above example, we have seen that if we only call method message() then, the current class message() is invoked but with the use of super keyword, message() of super class could also be invoked.
Scala-OOPS
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Hello World in Scala
Inheritance in Scala
Scala | Option
How to install Scala on Windows?
Scala Sequence
Scala | Traits
Scala | Decision Making (if, if-else, Nested if-else, if-else if)
Scala ListBuffer
Scala Map get() method with example
Scala | Case Class and Case Object
MoviePy – Creating Composite Video Clips

21 May, 2021
In this article, we will see how we can composite video file in MoviePy. MoviePy is a Python module for video editing, which can be used for basic operations on videos and GIF’s. Meaning of composite is combining different elements, composite video is the combination of different video clips unlike stacking and concatenation of video files composite files are easy to implement but complex structure. Composite file combine the clips over one another and get played at the same time, position and timing of video playback can be set any time.
In order to do this we will use CompositeVideoClip methodSyntax : CompositeVideoClip(clips)Argument : It takes list of video clips as argumentReturn : It returns VideoFileClip object  
Below is the implementation  
Python3
# Import everything needed to edit video clipsfrom moviepy.editor import *  # loading video dsa gfg intro video and getting only first 5 secondsclip1 = VideoFileClip("dsa_geek.webm").subclip(0, 5)  # rotating clip1 by 90 degree to get the clip2clip2 = clip1.margin(40).set_start(3)  # rotating clip1 by 180 degree to get the clip3clip3 = clip1.rotate(180).set_start(6)  # creating a composite videofinal = CompositeVideoClip([clip2, clip1, clip3])  # showing final clipfinal.ipython_display(width = 480)
Output : 
Moviepy - Building video __temp__.mp4.
Moviepy - Writing video __temp__.mp4

                                                                                                                       
Moviepy - Done !
Moviepy - video ready __temp__.mp4
 
Another example 
Python3
# Import everything needed to edit video clipsfrom moviepy.editor import * # loading video gfgclip = VideoFileClip("geeks.mp4")  # getting subclip from itclip1 = clip.subclip(0, 5) # mirroring image according to the y axisclip2 = clip.fx(vfx.mirror_y).set_start((4))  # creating a composite videofinal = CompositeVideoClip([clip1, clip2])  # showing final clipfinal.ipython_display(width = 480)
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
 
 
anikaseth98
Python-MoviePy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Lodash | _.differenceWith() Method - GeeksforGeeks

08 May, 2020
The _.differenceWith() method is similar to _.difference() method that returns the array containing the values that are in the first array not in the second array but in _.differenceWith() all the elements of the first array are compared with the second array by applying comparison provided in third. It may be a little complex to understand by reading this but it will become simple when you see the example.
Syntax:
_.differenceWith(array, [values], [comparator])
Parameters: This method accept three parameters as mentioned above and described below:
array: This parameter holds the array that values are checked or inspect.
values: This parameter holds the value that need to be removed.
comparator: This parameter holds the comparison invoked per element.
Return Value: This method returns an array according to the condition explained above.
Example 1:
const _ = require('lodash')  let x = [1, 2, 3]  let y = [2, 4, 5]  let result = _.differenceWith(x, y, _.isEqual);  console.log(result);
Here, const _ = require('lodash') is used to import the lodash library into the file.
Output:
[1, 3]
So, here each element of the first array is compared with each element of the second array according to the third comparator, in our case its _.isEqual. So, if the value becomes equal it removes it.
Example 2:
const _ = require('lodash');  let x = [{a: 1}, {b: 2}, 6]  let y = [{a: 1}, 7, 6]  let result = _.differenceWith(x, y, _.isEqual);  console.log(result);
Output:
[{b: 2}]

Example 3:
const _ = require('lodash');  let x1 = [1, 2, 3]  let y1 = [2, 4, 5]  let result1 = _.differenceWith(x1, y1, _.isEqual);  console.log(result1);  let x2 = [{a: 1}, {b: 2}, 6]  let y2 = [{a: 1}, 7, 6]  let result2 = _.differenceWith(x2, y2, _.isEqual);  console.log('\n\n', result2);
Output:
Note: This will not work in normal JavaScript because it requires the library lodash to be installed.
Reference: https://lodash.com/docs/4.17.15#differenceWith
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to calculate the number of days between two dates in javascript?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Convert a string to an integer in JavaScript
File uploading in React.js
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
C++ Program to Make a Simple Calculator to Add, Subtract, Multiply or Divide Using switch...case

Let us see a program to create a simple calculator in C++, with Add, Subtract, Multiply and Divide operations.
 Live Demo
#include <iostream>
using namespace std;
void calculator(int a, int b, char op) {
   switch (op) {
      case '+': {
         cout<<"Sum of "<<a<<" and "<<b<<" is "<<a+b<<endl;
         break;
      }
      case '-': {
         cout<<"Difference of "<<a<<" and "<<b<<" is "<<a-b<<endl;
         break;
      }
      case '*': {
         cout<<"Product of "<<a<<" and "<<b<<" is "<<a*b<<endl;
         break;
      }
      case '/': {
         cout<<"Division of "<<a<<" and "<<b<<" is "<<a/b<<endl;
         break;
      }
      default:
      cout<<"Invalid Input"<<endl;
   }
}
int main() {
   calculator(5,4,'+');
   calculator(10,3,'-');
   calculator(3,2,'*');
   calculator(20,5,'/');
   calculator(5,2,'?');
   return 0;
}
Sum of 5 and 4 is 9
Difference of 10 and 3 is 7
Product of 3 and 2 is 6
Division of 20 and 5 is 4
Invalid Input
In the above program, a function calculator is used to add, subtract, multiply and divide two numbers. This is done using a switch case statement. The function takes 3 parameters i.e. two numbers on which the operation is to be performed and what operation is to be performed. This is shown as follows −
void calculator(int a, int b, char op)
There are 4 cases in the switch case statement and one default case. The first case is used when addition is to be performed. The two numbers are added and their sum is displayed. This is shown using the following code snippet.
case '+': {
   cout<<"Sum of "<<a<<" and "<<b<<" is "<<a+b<<endl;
   break;
}
The second case is used when subtraction is to be performed. The two numbers are subtracted and their difference is displayed. This is shown using the following code snippet.
case '-': {
   cout<<"Difference of "<<a<<" and "<<b<<" is "<<a-b<<endl;
   break;
}
The third case is used when multiplication is to be performed. The two numbers are multiplied and their product is displayed. This is shown using the following code snippet.
case '*': {
   cout<<"Product of "<<a<<" and "<<b<<" is "<<a*b<<endl;
   break;
}
The fourth case is used when division is to be performed. The two numbers are divided and their division is displayed. This is shown using the following code snippet.
case '/': {
cout<<"Division of "<<a<<" and "<<b<<" is "<<a/b<<endl;
break;
}
The default case is used for invalid operator provided.This is shown using the following code snippet.
default: cout<<"Invalid Input"<<endl;
The function calculator() is called from main() for different operations and using different operands. This is demonstrated by the following code snippet.
calculator(5,4,'+');
calculator(10,3,'-');
calculator(3,2,'*');
calculator(20,5,'/');
calculator(5,2,'?');
Difference Between For and Foreach in PHP

In this post, we will understand the differences between 'for' and 'foreach' loops in PHP −
It is an iterative loop that repeats a set of code till a specified condition is reached. It is used to execute a set of code for a specific number of times. Here, the number of times is the iterator variable.
Syntax:
for( initialization; condition; increment/decrement ) {
   // code to iterate and execute
}
Initialization: It is used to initialize the iterator variables. It also helps execute them one at a time without running the conditional statement at the beginning of the loop's condition.
Condition: This statement is executed and if the condition returns a True value, the loop continues and the statements within it are executed. If the condition gives a False value, the execution comes out of the loop.
Increment: It increments/increases the counter in the loop. It is executed at the end of every iteration without a break.
It doesn't hide the iteration.
It is complex in comparison to 'foreach' loop.
It takes more time to execute in comparison to 'foreach' loop.
Let us see an example −
<?php
for($i = 1; $i <= 2; $i++) {
   echo $i . " Hi \n";
}
?>
It iterates over the elements of the array data structure.
It hides the iteration.
It is simple.
It performs better in comparison to 'for' loop.
It takes less time for the iteration.
Syntax:
foreach( $array as $element ) {
   // PHP Code to execute
}
foreach( $array as $key => $element) {
   // PHP Code to execute
}
<?php
$peop = array( "Will", "Jane", "Harold" );
foreach( $ peop as $element ) {
   echo $element . "<br>";
}
?>
Will
Jane
Harold
Conclusion
In this post, we understood about the significant differences between the 'for' and 'foreach' loop in PHP.
Iterate over lines from multiple input streams in Python

Python’s built-in open() function opens one file in read/write mode and read/write operations on it. To perform processing on multiple files in a batch, one has to use fileinput module of Python’s standard library. This module provides a Fileinput class with functionality of iterating over files. The module also defines helper functions for the same purpose.
Primary interface to this module is input() function. This function returns instance of Fileinput class.
fileinput.input(files, inplace, mode)
The files parameter is name of one or more files to be read one by one. Each file acts as a generator and using a for loop it can be iterated upon. Each line in the file will be printed on Python console.
>>> for line in fileinput.input('data.txt'):
print (line)
The files parameter can be a tuple consisting of many files. Contents of files will be displayed one by one.
>>> for line in fileinput.input(files=('a.txt', 'b.txt')):
print (line)
The Fileinput class can also be used a context manager in the with statement.
>>> with fileinput.input(files=('a.txt', 'b.txt')) as f:
for line in f:
print (line)
The fileinput module has following functions defined in it.
Following statement prints each line in the file along with the line number
>>> for line in fileinput.input('books.py'):
print ('{}->{}'.format(fileinput.filelineno(), line))
The sample output of above code is
1->import sqlite3
2->conn = sqlite3.connect('c:/python36/books.db')
3->cursor = conn.cursor()
4->cursor.execute("SELECT * from books;")
5->print(cursor.fetchall())
Following code print each file name in folder followed by numbered lines in it. In this program glob() function is used which returns list of files in current path optionally with matching wild cards. Here glob(‘*.py’) will return list of all files with .py extension in the current folder. This list is used as files parameter to fileinput.input() function.
import fileinput, glob, sys
for line in fileinput.input(glob.glob("*.py")):
if fileinput.isfirstline():
print (fileinput.filename(),'>')
sys.stdout.write ("{}.{}".format(fileinput.filelineno(),line))
Note the use of isfirstline() function. When iteration of new file starts, this function returns true and file name as returned by fileinput.filename() function is printed first and then the lines with numbers are displayed. For example
1.py >
1.a = 10
2.b = 20
3.print ('addition=',a+b)
hello.py >
1.x = 10
2.y = 20
3.z = x+y
4.print ("x+y=",z)
By default, inplace = False for fileinput.input() function. If it is set to True, it makes the input file writable.
Assuming that there is a ‘msg.txt’ with following text in it.
Hello Python. Good morning
Following code opens the file using fileinput module and modifies its contents in place.
>>> for line in fileinput.input(files='msg.txt',inplace = True):
line = line.replace('morning', 'evening')
sys.stdout.write(line)
The ‘msg.txt’ will show the changes done.
Draw Cube and Cuboid in Python using Turtle

22 Jun, 2020
Prerequisite: Turtle Programming Basics
Turtle is an inbuilt module in Python. It provides drawing using a screen (cardboard) and turtle (pen). To draw something on the screen, we need to move the turtle (pen). To move the turtle, there are some functions i.e forward(), backward(), etc.
Following steps are used:
First draw the front square
Move to back square through one bottom left side
Draw the back square
Draw the remaining side as shown in code.
Below is the implementation.
Python3
#import the turtle modules import turtle   # Forming the window screentut = turtle.Screen()  # background color greentut.bgcolor("green")  # window title Turtletut.title("Turtle")my_pen = turtle.Turtle()  # object colormy_pen.color("orange")tut = turtle.Screen()             # forming front square facefor i in range(4):    my_pen.forward(100)    my_pen.left(90)  # bottom left sidemy_pen.goto(50,50)  # forming back square facefor i in range(4):    my_pen.forward(100)    my_pen.left(90)  # bottom right sidemy_pen.goto(150,50)my_pen.goto(100,0)  # top right sidemy_pen.goto(100,100)my_pen.goto(150,150)  # top left sidemy_pen.goto(50,150)my_pen.goto(0,100)
Output :
Following steps are used:
First draw the front rectangle
Move to back rectangle through one bottom left side
Draw the back rectangle
Draw the remaining side as shown in code.
Below is the implementation.
Python3
#import the turtle modules import turtle   # Forming the window screentut = turtle.Screen()  # background color greentut.bgcolor("green")  # window title Turtletut.title("Turtle")my_pen = turtle.Turtle()  # object colormy_pen.color("orange")tut=turtle.Screen()             # forming front rectangle facefor i in range(2):    my_pen.forward(100)    my_pen.left(90)    my_pen.forward(150)    my_pen.left(90)  # bottom left sidemy_pen.goto(50,50)  # forming back rectangle facefor i in range(2):    my_pen.forward(100)    my_pen.left(90)    my_pen.forward(150)    my_pen.left(90)  # bottom right sidemy_pen.goto(150,50)my_pen.goto(100,0)  # top right sidemy_pen.goto(100,150)my_pen.goto(150,200)  # top left sidemy_pen.goto(50,200)my_pen.goto(0,150)
Output :
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What are the differences between HTTP module and Express.js module ?

05 Jul, 2022
HTTP and Express both are used in NodeJS for development. In this article, we’ll go through HTTP and express modules separately
HTTP: It is an in-build module which is pre-installed along with NodeJS. It is used to create server and set up connections. Using this connection, data sending and receiving can be done as long as connections use a hypertext transfer protocol.
Example: Creating a server using the HTTP module in NodeJS.
index.js
// Importing http module var http = require('http');  // Create a server object which listens on port 300http.createServer(function (req, res) {    // Write a response to the client    res.write('Hello World!');      // End the response    res.end();}).listen(3000);
 
Run the index.js file using the following command.
node index.js
Output:
Express: Express as a whole is known as a framework, not just as a module. It gives you an API, submodules, functions, and methodology and conventions for quickly and easily typing together all the components necessary to put up a modern, functional web server with all the conveniences necessary for that (static asset hosting, templating, handling CSRF, CORS, cookie parsing, POST data handling, and many more functionalities.
Module Installation: You can install the express module using the following command.
npm i express
Example: Creating a server using the express module in NodeJS.
index.js
// Importing expressconst express = require('express');  // Creating instance of expressconst app = express();  // Handling GET / Requestapp.get('/', function (req, res) {    res.send("Hello World!, I am server created by expresss");})  // Listening to server at port 3000app.listen(3000, function () {    console.log("server started");})
Run the index.js file using the following command.
node index.js
Output:
Difference between HTTP module and Express.js module:
HTTP
Express
venkatp30p
Express.js
http
NodeJS-Questions
Picked
Difference Between
Node.js
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
Difference Between Method Overloading and Method Overriding in Java
Similarities and Difference between Java and C++
Difference between Internal and External fragmentation
Difference between MANET and VANET
How to update Node.js and NPM to next version ?
Installation of Node.js on Linux
Node.js fs.readFileSync() Method
How to install the previous version of node.js and npm ?
Node.js fs.writeFile() Method
Conversion of J-K Flip-Flop into T Flip-Flop

17 Jun, 2022
Prerequisite – Flip-flop 
1. J-K Flip-Flop: JK flip-flop shares the initials of Jack Kilby, who won a Nobel prize for his fabrication of the world’s first integrated circuit, some people speculate that this type of flip flop was named after him because a  flip-flop was the first device that Kilby build when he was developing integrated circuits. J-K flip-flop is the gated version of SR flip-flop with an addition of extra input i.e. clock input. It prevents invalid output conditions when both the inputs are at the same value. 
2. T Flip-Flop: T flip-flop means Toggle flip-flop. It changes the output on each clock edge and gives an output that is half the frequency of the signal to the input. 
Step-1: Construct the characteristic table of T flip-flop and excitation table of the J-K flip-flop. 
Step-2: Using the K map, find the boolean expression for J and K in terms of T. 
J = T
K = T 
Step-3: Construct the circuit diagram for the conversion of the J-K flip-flop into a T flip-flop. 
dishaagrawal1
Digital Electronics & Logic Design
GATE CS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | SortedDictionary.Remove() Method

01 Feb, 2019
This method is used to remove the value with the specified key from the SortedDictionary<TKey, TValue>.
Syntax:
public bool Remove (TKey key);

Return Value: This method returns true if the element is successfully found and removed; otherwise it returns false. This method returns false if key is not found in the SortedDictionary.
Exception: This method will give ArgumentNullException if the key is null.
Below are the programs to illustrate the use of the above-discussed method:
Example 1:
// C# code to remove the entry with// the specified key from the// SortedDictionaryusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Create a new dictionary of        // strings, with string keys.        SortedDictionary<string, string> myDict =           new SortedDictionary<string, string>();          // Adding key/value pairs in myDict        myDict.Add("Australia", "Canberra");        myDict.Add("Belgium", "Brussels");        myDict.Add("Netherlands", "Amsterdam");        myDict.Add("China", "Beijing");        myDict.Add("Russia", "Moscow");        myDict.Add("India", "New Delhi");          // To get count of key/value pairs in myDict        Console.WriteLine("Total key/value pairs"            + " in myDict are : " + myDict.Count);          // Remove the entry with the specified        // key from the Dictionary        myDict.Remove("Russia");          Console.WriteLine("After remove operation");          // To get count of key/value pairs in myDict        Console.WriteLine("Total key/value pairs"           + " in myDict are : " + myDict.Count);    }}
Total key/value pairs in myDict are : 6
After remove operation
Total key/value pairs in myDict are : 5

Example 2:
// C# code to remove the entry with// the specified key from the// SortedDictionaryusing System;using System.Collections.Generic;  class GFG {      // Driver code    public static void Main()    {          // Create a new SortedDictionary        // of ints, with int keys.        SortedDictionary<int, int> myDict =           new SortedDictionary<int, int>();          // Adding key/value pairs in myDict        myDict.Add(9, 8);        myDict.Add(3, 4);        myDict.Add(4, 7);        myDict.Add(1, 7);          // To get count of key/value pairs in myDict        Console.WriteLine("Total key/value pairs "             + "in myDict are : " + myDict.Count);          // Remove the entry with the specified        // key from the Dictionary        myDict.Remove(9);          Console.WriteLine("After remove operation");          // To get count of key/value pairs in myDict        Console.WriteLine("Total key/value pairs in"                 + " myDict are : " + myDict.Count);    }}
Total key/value pairs in myDict are : 4
After remove operation
Total key/value pairs in myDict are : 3

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.sorteddictionary-2.remove?view=netframework-4.7.2
CSharp SortedDictionary Class
CSharp-Generic-Namespace
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to count number of NULLs in a row with MySQL?

Use ISNULL() from MySQL. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Number1 int,
   -> Number2 int
   -> );
Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(10,NULL);
Query OK, 1 row affected (0.17 sec)

mysql> insert into DemoTable values(NULL,NULL);
Query OK, 1 row affected (0.10 sec)

mysql> insert into DemoTable values(29,98);
Query OK, 1 row affected (0.14 sec)

mysql> insert into DemoTable values(NULL,119);
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement.
mysql> select *from DemoTable;
This will produce the following output −
+---------+---------+
| Number1 | Number2 |
+---------+---------+
|      10 | NULL    |
|    NULL | NULL    |
|      29 | 98      |
|    NULL | 119     |
+---------+---------+
4 rows in set (0.00 sec)
Following is the query to count the number of NULLs in a row.
mysql> select Number1,Number2,isnull(Number1)+isnull(Number2) AS NumberofNULLS from DemoTable;
This will produce the following output −
+---------+---------+--------------+
| Number1 | Number2 | NumberofNULLS|
+---------+---------+--------------+
|      10 | NULL    | 1            |
|    NULL | NULL    | 2            |
|      29 | 98      | 0            |
|    NULL | 119     | 1            |
+---------+---------+--------------+
4 rows in set (0.00 sec)
How to check an array is associative or sequential in PHP? - GeeksforGeeks

24 Sep, 2018
In PHP there is no need to write the variable type before the variable because it is loosely-typed. It takes datatype from user defined values that are stored in it. Arrays in PHP is a type of data structure that allows to store multiple elements of similar data type under a single variable thereby saving the effort of creating a different variable for every data.There are basically three types of arrays in PHP:
Sequential (Indexed) arrays
Associative arrays
Multidimensional arrays
Sequential Arrays: Those arrays which have numerical indexes in an ordered sequential manner (starting from 0 and ending with n-1) are called Sequential or Indexed arrays. In PHP, by default array Indexed array.
<?php// Example of sequential array  $arr = array("January", "February", "March");  // 1st elementecho $arr[0] . "\n";  // 2nd elementecho $arr[1] . "\n";  // 3rd element     echo $arr[2] . "\n";?>
January
February
March

Associative arrays: The arrays which are having string type keys instead of indexes or which exist in (‘key’, ‘value’)pairs are called associative arrays.
<?php// Example of associative array  $arr1= array("Month1" => "January",             "Month2" => "February",             "Month3" => "March"         );  echo $arr1["Month1"] . "\n";echo $arr1["Month2"] . "\n";echo $arr1["Month3"] . "\n";?>
January
February
March

How to check if PHP array is associative or sequential?There is no inbuilt method in PHP to know the type of array. If the sequential array contains n elements then their index lies between 0 to (n-1). So find the array key value and check if it exist in 0 to (n-1) then it is sequential otherwise associative array.
<?php// Example to check Sequential array  // Associative array$arr1= array("Month1" => "January",             "Month2" => "February",              "Month3" => "March"         );      // Checking for sequential keys of array arrif(array_keys($arr1) !== range(0, count($arr1) - 1))    echo "Array is associative"; else    echo "Array is sequential \n";?>
Array is associative

Note:
=== It returns True if $x and $y are equal and same type.
!== It returns True if $x and $y are not equal or not same type.
== It returns True if $x and $y are equal.
!= It returns True if $x not equal to $y.
Picked
PHP
PHP Programs
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
PHP str_replace() Function
How to create admin login page using PHP?
Different ways for passing data to view in Laravel
Create a drop-down list that options fetched from a MySQL database in PHP
How to call PHP function on the click of a Button ?
How to fetch data from localserver database and display on HTML table using PHP ?
How to create admin login page using PHP?
How to pass form variables from one page to other page in PHP ?
PHP | Ternary Operator
Access the elements of a Series in Pandas - GeeksforGeeks

06 Dec, 2018
Pandas Series is a one-dimensional labeled array capable of holding data of any type (integer, string, float, python objects, etc.). Labels need not be unique but must be a hashable type.
Let’s discuss different ways to access the elements of given Pandas Series.
First create a Pandas Series.
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")   ser = pd.Series(df['Name'])ser.head(10)# or simply df['Name'].head(10)
Output: Example #1: Get the first element of series
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")   df['Name'].head(10)  # get the first elementser[0]
Output:
 Example #2: Access multiple elements by providing position of item
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")   df['Name'].head(10)  # get multiple elements at given indexser[[0, 3, 6, 9]]
Output: Example #3: Access first 5 elements in Series
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")   df['Name'].head(10)  # get first five namesser[:5]
Output: Example #4: Get last 10 elements in Series
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")   df['Name'].head(10)  # get last 10 namesser[-10:]
Output: Example #5: Access multiple elements by providing label of index
# importing pandas module import pandas as pd import numpy as np  ser = pd.Series(np.arange(3, 15), index = list("abcdefghijkl"))  ser[['a', 'd', 'g', 'l']]
Output:
pandas-series-program
Python pandas-series
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()
Reading and Writing to text files in Python
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Sorting Algorithms - GeeksQuiz

06 Sep, 2021
Selection sort makes O(n) swaps which is minimum among all sorting algorithms mentioned above.
2  5  1  7  9  12  11  10 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Python Program for Breadth First Search or BFS for a Graph
Best Time to Buy and Sell Stock
Must Do Coding Questions for Product Based Companies
How to calculate MOVING AVERAGE in a Pandas DataFrame?
How to insert a pandas DataFrame to an existing PostgreSQL table?
What is "network ID" and "host ID" in IP Addresses?
What is Transmission Control Protocol (TCP)?
How to Find Length of String in Bash Script?
Bash Scripting - How to read a file line by line
Converting nested JSON structures to Pandas DataFrames
Get row numbers of NumPy array having element larger than X

11 Oct, 2020
Let’s see how to getting the row numbers of a numpy array that have at least one item is larger than a specified value X. So, for doing this task we will use numpy.where() and numpy.any() functions together.
Syntax: numpy.where(condition[, x, y])
Return: [ndarray or tuple of ndarrays] If both x and y are specified, the output array contains elements of x where condition is True, and elements from y elsewhere.
Syntax: numpy.any(a, axis = None, out = None, keepdims = class numpy._globals._NoValue at 0x40ba726c)
Return: [ndarray, optional]Output array with same dimensions as Input array, Placed with result
Example :
Arr = [[1,2,3,4,5], 
      [10,-3,30,4,5], 
      [3,2,5,-4,5], 
      [9,7,3,6,5]] 
and X = 6 then output is [ 0, 2 ].

Here, 
[[1,2,3,4,5],
no element is greater than 6 so output is [0].

[10,-3,30,4,5],
10 is greater than 6 so output is [0].

[3,2,5,-4,5],
no element is greater than 6 so output is [0, 2].

[4,7,3,6,5]]
7 is greater than 6 so output is [0, 2].

Below is the implementation:
Python3
# importing libraryimport numpy  # create numpy arrayarr = numpy.array([[1, 2, 3, 4, 5],                  [10, -3, 30, 4, 5],                  [3, 2, 5, -4, 5],                  [9, 7, 3, 6, 5]                  ])  # declare specified valueX = 6  # view arrayprint("Given Array:\n", arr)  # finding out the row numbersoutput  = numpy.where(numpy.any(arr > X,                                axis = 1))  # view outputprint("Result:\n", output)
Output:
Given Array:
[[ 1  2  3  4  5]
[10 -3 30  4  5]
[ 3  2  5 -4  5]
[ 9  7  3  6  5]]
Result:
(array([1, 3], dtype=int64),)

Python numpy-Indexing
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
How to setup cron jobs in Ubuntu

27 Feb, 2020
The Cron software utility is a time-based job scheduler in Unix-like operating systems. Cron allows Linux and Unix users to run commands or scripts at a given time and date. Once can schedule scripts to be executed periodically. It is usually used for system admin jobs such as backups or cleaning/tmp/ directories and more.
The following steps to be followed to set up a cron job in Ubuntu:
Connect to server and update the system:Before begin with setting up crontab connect the server and update the system software to the latest version available. We can do this by using below command:#apt-get update && #apt-get upgrade
#apt-get update && #apt-get upgrade
Check if cron package is installed:To check if cron is installed, run the following command –#dpkg -l cron 
#dpkg -l cron 
If cron is not installed, install the cron package on Ubuntu:One can Install the cron package with package Manager using the following command-#apt-get install cron
#apt-get install cron
Verify if cron service is running:To check whether the cron service is running on the system, we can use the following command-#systemctl status cron
#systemctl status cron
Configure cron job on ubuntu:In order to set up cron jobs, one needs to modify the /etc/crontab file which can be done by only root user. You can edit the crontab file with following text editor.Example:#nano /etc/crontab
Example:
#nano /etc/crontab
Before we take example of cron tab execution let’s understand the common syntax of cron tab:
Syntax:
* * * * * /path/to/command arg1 arg2
OR
* * * * * /root/backup.sh
In the syntax first * stand for representing minutes [0-59]. Second * stands for representing hour[0-23]. Third * stand for representing day [0-31]. Fourth star stands for representing month[0-12]. Fifth * stand for representing day of the week[0-7].
 After all step for installation of cron tab and understanding common syntax, let’s execute a cron tab with suitable example.
Example #1: If we want to schedule a backup on first day of each month at 9 PM, the following command performs this operation.
#crontab -e //install your cron job by running this command.
// Append the following entry.

0 9 1 * * /path/to/script/backup-script.sh
 Example #2: Set up and run php script as cron job to run script every day at 10 AM.
#crontab -e //add cron job

// Append the following entry.
0 10 * * * /path/to/myphpscript.php
Following options are available in crontab:crontab -l : List the all your cron jobs.crontab -r : Delete the current cron jobs.
For more information about cron, one can check the manual pages using:
man cron
man crontab 
Samdare B
linux-command
Picked
Linux-Unix
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Server – PATINDEX() Function

23 Sep, 2021
The PATINDEX() function in the SQL server is used to return the starting index of the first occurrence of a pattern in a string or a specified expression. 
It returns zero if the pattern is not found.
It returns NULL if either pattern or expression is NULL.
Starting index is 1.
PATINDEX ( '%pattern%' , expression )
There are two parameters and both are required.
Pattern – This is the sequence to be found in the string that must be surrounded by %. Other wildcard characters can be used in patterns. The pattern has a limit of 8000 characters. Other wildcard characters are ‘%’ , ‘-‘ , ‘[]’ , ‘[^]’.
Expression – A string that is searched for the specified pattern.
The function PATINDEX() is applicable to the following databases.
SQL Server (all supported versions)
Azure SQL Database
Azure SQL Data Warehouse
Azure SQL Managed Instance
Azure Synapse Analytics Analytics Platform System (PDW)
Parallel Data Warehouse
Suppose if we want to find the first occurrence of ‘ek’ in the string ‘GeeksforGeeks’.then query will be like:
Query:
SELECT PATINDEX('%ek%', 'GeeksforGeeks');
Output:
3
Now if we finding the first occurrence of the letter ‘z’ in the string ‘GeeksforGeeks’.
Query:
SELECT PATINDEX('%[z]%', 'GeeksforGeeks');
Output:
It returns 0 because the given string does not contain the letter ‘z.
0
Take another example for finding the first occurrence of the symbol in the string ‘How are you?’.
Query:
SELECT position = PATINDEX('%[^ 0-9A-z]%', 'How are you?');
Output:
12
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
What is Temporary Table in SQL?
SQL | Sub queries in From Clause
SQL using Python
RANK() Function in SQL Server
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
How to Write a SQL Query For a Specific Date Range and Date Time?
compgen command in Linux with Examples

22 Jun, 2020
compgen is a bash built-in command which is used to list all the commands that could be executed in the Linux system. This command could also be used to count the total number of commands present in the terminal or even to look for a command with the specific keyword. This command is even used to print the bash details like bash builtin functions and stuff.
1. To list all commands available to be directly executed.
compgen -c
This will list all the commands available to you for direct use.
2. To search for commands having a specific keyword
compgen -c | grep gnome
This will search the commands having the keyword gnome in them.
3. To count total number of commands available for use
compgen -c | wc -l
This command will count the total number of commands that could be used.
4. To list all the bash alias
compgen -a
This command will list all the bash alias present in your system.
5. To list all the bash built-ins
compgen -b
This command will list all the bash built-ins present in your system.
6. To list all the bash keywords
compgen -k
This command will list all the bash keywords present in your system.
7. To list all the bash functions.
compgen -A function
This command will list all the bash functions present in your system.
linux-command
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
SED command in Linux | Set 2
nohup Command in Linux with Examples
mv command in Linux with examples
chmod command in Linux with examples
Array Basics in Shell Scripting | Set 1
Introduction to Linux Operating System
Basic Operators in Shell Scripting