code-rag-bench/online-tutorials huggingface dataset:
How to redirect to another webpage in HTML? - GeeksforGeeks

24 Apr, 2019
It is often required to redirect to another webpage on loading a webpage, for example, due to the contents being moved to the new webpage.
Demonstrated here are two simple methods to redirect to another webpage on load.
Method-1: Using http-equiv attribute of the meta tag in HTML.
Syntax:
<meta http-equiv="refresh" content="seconds; url=URL">

Example-1:
<!DOCTYPE HTML><html>  <head>    <title>        Redirect to GeeksforGeeks    </title>    <!-- meta tag to redirect to      ide.geeksforgeeks.org after 2 seconds -->    <meta http-equiv="refresh"          content="2;                 url=https://ide.geeksforgeeks.org/"></head>  <body>    <!-- Link to the destination page       in case the refresh does not work -->    You will be redirected to GeeksforGeeks in a moment.    <br>     If you are not redirected automatically,     <a href="https://ide.geeksforgeeks.org/">      click here    </a>.</body>  </html>
Output:Before:
After 2 seconds:
Note: In some older browsers, like Internet Explorer 6, refresh may cause unexpected results and impair the browser’s Back button. This is compensated for in most modern browsers (Internet Explorer 7 and higher, Google Chrome, Mozilla Firefox, Microsoft Edge).
Method-2: Using location.href in JavaScript.
Syntax:
window.location.href = "URL"

Example-2:
<!DOCTYPE HTML><html>  <head>    <title>        Redirect to GeeksforGeeks    </title>    <script type="text/javascript">                /* location.href used to        redirect to ide.geeksforgeeks.org */        window.location.href =          "https://ide.geeksforgeeks.org/"    </script></head>  <body>    <!-- Link to the destination page in     case the redirect does not work -->    You will be redirected to GeeksforGeeks in a moment.    <br>    If you are not redirected automatically,   <a href="https://ide.geeksforgeeks.org/">    click here    </a>.</body>  </html>
Output:
Note: This method works fine for any JavaScript enabled browser.
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Misc
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
Python - Read CSV Columns Into List - GeeksforGeeks

17 Sep, 2021
CSV file stores tabular data (numbers and text) in plain text. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format. In this article, we will read data from a CSV file into a list. We will use the panda’s library to read the data into a list. 
File Used: file.
Method 1: Using Pandas
Here, we have the read_csv() function which helps to read the CSV file by simply creating its object. The column name can be written inside this object to access a particular column, the same as we do in accessing the elements of the array. Pandas library has a function named as tolist() that converts the data into a list that can be used as per our requirement. So, we will use this to convert the column data into a list. Finally, we will print the list.
Approach:
Import the module.
Read data from CSV file.
Convert it into the list.
Print the list.
Below is the implementation:
Python3
# importing modulefrom pandas import * # reading CSV filedata = read_csv("company_sales_data.csv") # converting column data to listmonth = data['month_number'].tolist()fc = data['facecream'].tolist()fw = data['facewash'].tolist()tp = data['toothpaste'].tolist()sh = data['shampoo'].tolist() # printing list dataprint('Facecream:', fc)print('Facewash:', fw)print('Toothpaste:', tp)print('Shampoo:', sh)
Output:
Method 2: Using csv module
In this method we will import the csv library and open the file in reading mode, then we will use the DictReader() function to read the data of the CSV file. This function is like a regular reader, but it maps the information to a dictionary whose keys are given by the column names and all the values as keys. We will create empty lists so that we can store the values in it. Finally, we access the key values and append them into the empty lists and print that list.
Python3
# importing the moduleimport csv # open the file in read modefilename = open('company_sales_data.csv', 'r') # creating dictreader objectfile = csv.DictReader(filename) # creating empty listsmonth = []totalprofit = []totalunit = [] # iterating over each row and append# values to empty listfor col in file:    month.append(col['month_number'])    totalprofit.append(col['moisturizer'])    totalunit.append(col['total_units']) # printing listsprint('Month:', month)print('Moisturizer:', totalprofit)print('Total Units:', totalunit)
Output:
anikakapoor
rajeev0719singh
Picked
python-csv
Technical Scripter 2020
Python
Technical Scripter
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
Python | Sort list of list by specified index - GeeksforGeeks

23 Dec, 2018
We can sort list of list using the conventional sort function. This sorts the list by the first index of lists. But more than often there can be circumstances that requires the sorting of list of list by other index elements than first. Lets discuss certain ways in which this task can be performed.
Method #1 : Using sort() + lambdasort() can be used to perform this variation of sort by passing a function as a key that performs the sorting according to the desired inner list index.
# Python 3 code to demonstrate # to sort list of list by given index # using sort() + lambda    # initializing list test_list = [['Rash', 4, 28], ['Varsha', 2, 20], ['Nikhil', 1, 20], ['Akshat', 3, 21]]  # printing original list print ("The original list is : " + str(test_list))  # using sort() + lambda# to sort list of list # sort by second indextest_list.sort(key = lambda test_list: test_list[1])  # printing resultprint ("List after sorting by 2nd element of lists : " + str(test_list))
Output :
The original list is : [['Rash', 4, 28], ['Varsha', 2, 20], ['Nikhil', 1, 20], ['Akshat', 3, 21]]
List after sorting by 2nd element of lists : [['Nikhil', 1, 20], ['Varsha', 2, 20], ['Akshat', 3, 21], ['Rash', 4, 28]]

Method #2 : Using sorted() + itemgetter()This can also be applied to perform this particular task. The advantage that it holds is that it does not modify the original list. itemgetter() is used to get the index element by which the sort operation needs to be performed.
# Python3 code to demonstrate # to sort list of list by given index # using sorted() + itemgetter()from operator import itemgetter  # initializing list test_list = [['Rash', 4, 28], ['Varsha', 2, 20], ['Nikhil', 1, 20], ['Akshat', 3, 21]]  # printing original list print ("The original list is : " + str(test_list))  # using sort() + lambda# to sort list of list # sort by second indexres = sorted(test_list, key = itemgetter(1))  # printing resultprint ("List after sorting by 2nd element of lists : " + str(res))
Output :
The original list is : [['Rash', 4, 28], ['Varsha', 2, 20], ['Nikhil', 1, 20], ['Akshat', 3, 21]]
List after sorting by 2nd element of lists : [['Nikhil', 1, 20], ['Varsha', 2, 20], ['Akshat', 3, 21], ['Rash', 4, 28]]

Python list-programs
python-list
Python
Sorting
python-list
Sorting
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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
Tailwind CSS Font Size - GeeksforGeeks

23 Mar, 2022
This class accepts lots of value in tailwind CSS in which all the properties are covered as in class form.  It is the alternative to the CSS font-size property. This class is used to set the font size of the text in an HTML document.
Font size classes:
text-xs: This class defines the text size as extra small.
text-sm: This class defines the text size as small.
text-base: This class defines the text size as base size.
text-lg: This class defines the text size as large.
text-xl: This class defines the text size as extra-large.
text-2xl: This class defines the text size as 2 times extra-large.
text-3xl: This class defines the text size as 3 times extra-large.
text-4xl: This class defines the text size as 4 times extra-large.
text-5xl: This class defines the text size as 5 times extra-large.
text-6xl: This class defines the text size as 6 times extra-large.
text-7xl: This class defines the text size as 7 times extra-large.
text-8xl: This class defines the text size as 8 times extra-large.
text-9xl: This class defines the text size as 9 times extra-large.
Note: Change the size in the component with the required size mentioned above.
Syntax:
<element class="text-size">...</element>
Example:
HTML
<!DOCTYPE html> <head>     <link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"           rel="stylesheet"> </head>   <body class="text-center mx-4 space-y-2">     <h1 class="text-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>     <b>Tailwind CSS Font Size Class</b>     <div class="mx-24 bg-green-200">        <p class="text-xs">            Geeksforgeeks: A Computer Science portal for Geeks        </p>          <p class="text-sm">            Geeksforgeeks: A Computer Science portal for Geeks        </p>          <p class="text-base">            Geeksforgeeks: A Computer Science portal for Geeks        </p>          <p class="text-lg">            Geeksforgeeks: A Computer Science portal for Geeks        </p>          <p class="text-xl">            Geeksforgeeks: A Computer Science portal for Geeks        </p>      </div></body>   </html> 
Output:
Tailwind CSS
Tailwind-Typography
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
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?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to Run a Python Script using Docker? - GeeksforGeeks

14 Apr, 2022
The task is to build a docker image and execute a python script that adds two given numbers. This has been achieved via a series of steps.
We will be creating a Folder docker_2 at the desktop location in our PC . Inside the Folder another Folder called docker_assignment is created. Then two files dockerfile and test.py are created in this folder.
Folder 
Inside the dockerfile we will start by first taking the python base image from docker hub. A tag latest is used to get the latest official python image. It is very important to set your working directory inside your container. I have chosen /usr/src/app. All commands will be executed here as well as the images will be copied here only.
I have then copied the test.py file from my pc to the container current working directory(./ or /usr/src/app)  by using the COPY command. 
#Deriving the latest base image
FROM python:latest


#Labels as key value pair
LABEL Maintainer="roushan.me17"


# Any working directory can be chosen as per choice like '/' or '/home' etc
# i have chosen /usr/app/src
WORKDIR /usr/app/src

#to COPY the remote file at working directory in container
COPY test.py ./
# Now the structure looks like this '/usr/app/src/test.py'


#CMD instruction should be used to run the software
#contained by your image, along with any arguments.

CMD [ "python", "./test.py"]
After you have created both the Python script and the Dockerfile, you can now use the Docker build command to build your Docker Image.
Here -t is for adding tags so as to identify your image easily.
docker image build -t python:0.0.1 /home/roushan/Desktop/docker_2/docker_assignment
After you have built your Docker Image, you can list all the Images to check whether your image has been successfully built or not.
docker images
You will find your Image name listed here and with the tag name, you can easily find it.
Now, you can use the Docker run command to run your Docker Container.
docker run python:0.0.1
After running the Docker Container, you will see the output printed after adding the two numbers.
To conclude, in this article, we saw how to build a simple addition Python script and run it inside the Docker Container.
wolowitzcoefficient
sumitgumber28
rkbhola5
gtasop
Docker Container
linux
Advanced Computer Subject
Python
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Linear Regression
Reinforcement learning
Decision Tree
Decision Tree Introduction with example
System Design Tutorial
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Chomsky Hierarchy in Theory of Computation - GeeksforGeeks

10 May, 2022
According to Chomsky hierarchy, grammar is divided into 4 types as follows: 
Type 0 is known as unrestricted grammar.Type 1 is known as context-sensitive grammar.Type 2 is known as a context-free grammar.Type 3 Regular Grammar.
Type 0 is known as unrestricted grammar.
Type 1 is known as context-sensitive grammar.
Type 2 is known as a context-free grammar.
Type 3 Regular Grammar.
Type 0: Unrestricted Grammar: 
Type-0 grammars include all formal grammar. Type 0 grammar languages are recognized by turing machine. These languages are also known as the Recursively Enumerable languages. 
Grammar Production in the form of  where 
\alpha         is ( V + T)* V ( V + T)* 
V : Variables 
T : Terminals. 
is ( V + T )*. 
In type 0 there must be at least one variable on the Left side of production. 
For example: 
Sab --> ba 
A --> S
Here, Variables are S, A, and Terminals a, b. 
Type 1: Context-Sensitive Grammar
Type-1 grammars generate context-sensitive languages. The language generated by the grammar is recognized by the Linear Bound Automata 
In Type 1 
First of all Type 1 grammar should be Type 0. 
Grammar Production in the form of 

|\alpha |<=|\beta |
That is the count of symbol in is less than or equal to 
Also β  ∈ (V + T)+
i.e. β can not be ε  For Example:
S --> AB
AB --> abc 
B --> b  
Type 2: Context-Free Grammar: Type-2 grammars generate context-free languages. The language generated by the grammar is recognized by a Pushdown automata.  In Type 2:
First of all, it should be Type 1. 
The left-hand side of production can have only one variable and there is no restriction on 
|\alpha         | = 1.  
For example:
S --> AB 
A --> a 
B --> b 
Type 3: Regular Grammar: Type-3 grammars generate regular languages. These languages are exactly all languages that can be accepted by a finite-state automaton. Type 3 is the most restricted form of grammar. 
Type 3 should be in the given form only : 
V --> VT / T          (left-regular grammar)
(or)
V --> TV /T          (right-regular grammar)
For example:
S --> a
The above form is called strictly regular grammar.
There is another form of regular grammar called extended regular grammar. In this form:
V --> VT* / T*.        (extended left-regular grammar)
(or) 
V --> T*V /T*          (extended right-regular grammar)
For example : 
S --> ab. 
Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above.
VaibhavRai3
chaitalykundu
sandravsnair
umeshg17
niharikatanwar61
bumblebeecoding
Theory of Computation & Automata
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between DFA and NFA
Regular expression to ∈-NFA
NPDA for accepting the language L = {wwR | w ∈ (a,b)*}
Design 101 sequence detector (Mealy machine)
Closure properties of Regular languages
Conversion of Epsilon-NFA to NFA
Difference between Pushdown Automata and Finite Automata
Last Minute Notes - Theory of Computation
Variation of Turing Machine
Boyer-Moore Majority Voting Algorithm
Set the width of an element to 100% in Bootstrap

To set the width of an element to 100%, use the .w-100 class in Bootstrap.
You can try to run the following code to set element’s width
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link rel = "stylesheet" href = "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
      <script src = "https://maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <h3>Set element width</h3>
         <div class = "w-100 bg-success">Normal width</div>
         <div class = "w-50 bg-danger">Width is 25%</div>
      </div>
   </body>
</html>
JasmineJS - Inequality Check

Till now, we have discussed different methods in Jasmine which help us test different scenarios based on our requirements. In this chapter, we will learn about different matchers that will help us check the inequality condition in JS file. Following are the matchers used for this purpose.
As the name suggests this matcher helps to check greater than condition. Let us modify our customerMatcher.js using the following piece of code.
describe("Different Methods of Expect Block",function () { 
   var exp = 8;  
	
   it("Example of  toBeGreaterThan()", function () {
      expect(exp).toBeGreaterThan(5);
   });
}); 
In the above piece of code, we are expecting that the value of the variable “exp” will be greater than 5. Now as the value of the variable “exp” is “8” which is greater than “5”, this piece of code will generate a green screenshot.
Now again let us modify the value of the variable to “4” and make this test fail. To do that we need to modify the js file using the following piece of code.
describe("Different Methods of Expect Block",function () {  
   var exp = 4;  
	
   it ("Example of toBeGreaterThan()", function () {
      expect(exp).toBeGreaterThan(5); 
   });
});
This code will fail because value 4 cannot be greater than 5. Hence it will produce the following output.
This matcher helps to check the less than condition of the test scenario. It behaves exactly opposite to that of toBeGreaterThan() matcher. Now let us see how this matcher works. Let us modify the customerMatcher.js file accordingly.
describe("Different Methodsof Expect Block",function () { 
   var exp = 4;  
	
   it("Example of toBeLessThan()", function() { 
      expect(exp).toBeLessThan(5);    
   });
}); 
Like the previous example, we have one variable having value as “4”. In this piece of code, we are checking whether the value of this variable is less than 5 or not. This piece of code will generate the following output.
Now to make this fail, we need to assign some bigger number to the variable exp. Let us do that and test the application. We will assign 25 as the value to the exp, which will definitely throw an error and yield the following screenshot in red.
 Print
 Add Notes
 Bookmark this page
C# Program to count vowels in a string

You need to check for both the vowels and consonants, but do not forget to check for both the uppercase as well lowercase.
For counting vowels, check for “aeiou” characters separately i.e.
if (myStr[i] == 'a' || myStr[i] == 'e' || myStr[i] == 'i' || myStr[i] == 'o' || myStr[i] == 'u' || myStr[i] == 'A' || myStr[i] == 'E' || myStr[i] == 'I' || myStr[i] == 'O' || myStr[i] == 'U') {
   vowel_count++;
}
The following is the code to count the number of Vowels in a string.
Live Demo
using System;
public class Demo {
   public static void Main() {
      string myStr;
      int i, len, vowel_count, cons_count;
      myStr = "Avengers";
      vowel_count = 0;
      cons_count = 0;
      // find length
      len = myStr.Length;
      for(i=0; i<len; i++) {
         if(myStr[i] =='a' || myStr[i]=='e' || myStr[i]=='i' || myStr[i]=='o' || myStr[i]=='u' || myStr[i]=='A' || myStr[i]=='E' || myStr[i]=='I' || myStr[i]=='O' || myStr[i]=='U') {
            vowel_count++;
         } else {
            cons_count++;
         }
      }
      Console.Write("\nVowels in the string: {0}\n", vowel_count);
   }
}
Vowels in the string: 3
for loop in java

A for loop is a repetition control structure that allows you to efficiently write a loop that needs to be executed a specific number of times.
A for loop is useful when you know how many times a task is to be repeated.
The syntax of a for loop is −
for(initialization; Boolean_expression; update) {
   // Statements
}

Here is the flow of control in a for loop −
The initialization step is executed first, and only once. This step allows you to declare and initialize any loop control variables and this step ends with a semi colon (;).
The initialization step is executed first, and only once. This step allows you to declare and initialize any loop control variables and this step ends with a semi colon (;).
Next, the Boolean expression is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop will not be executed and control jumps to the next statement past the for loop.
Next, the Boolean expression is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop will not be executed and control jumps to the next statement past the for loop.
After the body of the for loop gets executed, the control jumps back up to the update statement. This statement allows you to update any loop control variables. This statement can be left blank with a semicolon at the end.
After the body of the for loop gets executed, the control jumps back up to the update statement. This statement allows you to update any loop control variables. This statement can be left blank with a semicolon at the end.
The Boolean expression is now evaluated again. If it is true, the loop executes and the process repeats (body of loop, then update step, then Boolean expression). After the Boolean expression is false, the for loop terminates.
The Boolean expression is now evaluated again. If it is true, the loop executes and the process repeats (body of loop, then update step, then Boolean expression). After the Boolean expression is false, the for loop terminates.
Following is an example code of the for loop in Java.
public class Test {

   public static void main(String args[]) {

      for(int x = 10; x < 20; x = x + 1) {
         System.out.print("value of x : " + x );
         System.out.print("\n");
      }
   }
}
This will produce the following result −
value of x : 10
value of x : 11
value of x : 12
value of x : 13
value of x : 14
value of x : 15
value of x : 16
value of x : 17
value of x : 18
value of x : 19


    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
How to create Horizontal Slider in Java?

To create Horizontal slider in Java, use the Swing JSlider. Let us first create a frame and a Horizontal slider in it −
JFrame frame = new JFrame("Frame with Slider");
JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 70);
Now, we will set the values for the slider. Display the ticks −
slider.setMinorTickSpacing(5);
slider.setMajorTickSpacing(20);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
Add the slider in the panel:
JPanel panel = new JPanel();
panel.add(slider);
The following is an example to create horizontal slider −
package my;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.WindowConstants;
public class SwingDemo {
   public static void main(String[] args) {
      JFrame frame = new JFrame("Frame with Slider");
      JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 70);
      slider.setMinorTickSpacing(5);
      slider.setMajorTickSpacing(20);
      slider.setPaintTicks(true);
      slider.setPaintLabels(true);
      JPanel panel = new JPanel();
      panel.add(slider);
      frame.add(panel);
      frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
      frame.setSize(500, 300);
      frame.setVisible(true);
   }
}
Comparing two strings in MySQL?

To compare two strings, which are numbers, let us first create a table. Following is the query −
mysql> create table compareTwoStringsDemo
   -> (
   -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> Value varchar(100)
   -> );
Query OK, 0 rows affected (0.52 sec)
Following is the query to insert some records in the table using insert command −
mysql> insert into compareTwoStringsDemo(Value) values('1235667');
Query OK, 1 row affected (0.66 sec)

mysql> insert into compareTwoStringsDemo(Value) values('999999');
Query OK, 1 row affected (0.11 sec)

mysql> insert into compareTwoStringsDemo(Value) values('999888');
Query OK, 1 row affected (0.17 sec)

mysql> insert into compareTwoStringsDemo(Value) values('567433');
mysql> insert into compareTwoStringsDemo(Value) values('567433');
Query OK, 1 row affected (0.23 sec)

mysql> insert into compareTwoStringsDemo(Value) values('2345123');
Query OK, 1 row affected (0.13 sec)
Following is the query to display all records from the table using select statement −
mysql> select *from compareTwoStringsDemo;
This will produce the following output −
+----+---------+
| Id | Value   |
+----+---------+
| 1  | 1235667 |
| 2  | 999999  |
| 3  | 999888  |
| 4  | 567433  |
| 5  | 2345123 |
+----+---------+
5 rows in set (0.00 sec)
Following is the query to compare two strings which are numbers −
mysql> select *from compareTwoStringsDemo
-> where cast(Value as signed) = 999999;
This will produce the following output. The record with the matching string gets displayed −
+----+--------+
| Id | Value  |
+----+--------+
| 2  | 999999 |
+----+--------+
1 row in set (0.00 sec)
DB2 - Schemas

This chapter introduces and describes the concept of Schema.
A schema is a collection of named objects classified logically in the database.
In a database, you cannot create multiple database objects with same name. To do so, the schema provides a group environment. You can create multiple schemas in a database and you can create multiple database objects with same name, with different schema groups.
A schema can contain tables, functions, indices, tablespaces, procedures, triggers etc. For example, you create two different schemas named as “Professional” and “Personal” for an “employee” database.  It is possible to make two different tables with the same name “Employee”. In this environment, one table has professional information and the other has personal information of employee. In spite of having two tables with the same name, they have two different schemas “Personal” and “Professional”. Hence, the user can work with both without encountering any problem. This feature is useful when there are constraints on the naming of tables.
Let us see few commands related to Schema:
Syntax:
db2 get schema  
Example: [To get current database schema]
db2 get schema   
Syntax:
db2 set schema=<schema_name>  
Example: [To arrange ‘schema1’ to current instance environment]
db2 set schema=schema1 
Syntax: [To create a new schema with authorized user id]
db2 create schema <schema_name> authroization <inst_user> 
Example: [To create “schema1” schema authorized with ‘db2inst2”]
db2 create schema schema1 authorization db2inst2 
Let us create two different tables with same name but two different schemas. Here, you create employee table with two different schemas, one for personal and the other for professional information.
Step 1: Create two schemas.
Schema 1: [To create schema named professional]
db2 create schema professional authorization db2inst2 
Schema 2: [To create schema named personal]
db2 create schema personal authorization db2inst2
Step 2: Create two tables with the same name for Employee details
Table1: professional.employee
[To create a new table ‘employee’ in the database using schema name ‘professional’]
db2 create table professional.employee(id number, name 
varchar(20), profession varchar(20), join_date date, 
salary number); 
Table2: personal.employee
[To create a new table ‘employee’ in the same database, with schema name ‘personal’]
db2 create table personal.employee(id number, name 
varchar(20), d_birth date, phone bigint, address 
varchar(200));  
After executing these steps, you get two tables with same name ’employee’, with two different schemas.

    10 Lectures 
     1.5 hours 

 Nishant Malik

    41 Lectures 
     8.5 hours 

 Parth Panjabi

    53 Lectures 
     11.5 hours 

 Parth Panjabi

    33 Lectures 
     7 hours 

 Parth Panjabi

    44 Lectures 
     3 hours 

 Arnab Chakraborty

    178 Lectures 
     14.5 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Redis - Transactions

Redis transactions allow the execution of a group of commands in a single step. Following are the two properties of Transactions.
All commands in a transaction are sequentially executed as a single isolated operation. It is not possible that a request issued by another client is served in the middle of the execution of a Redis transaction.
All commands in a transaction are sequentially executed as a single isolated operation. It is not possible that a request issued by another client is served in the middle of the execution of a Redis transaction.
Redis transaction is also atomic. Atomic means either all of the commands or none are processed.
Redis transaction is also atomic. Atomic means either all of the commands or none are processed.
Redis transaction is initiated by command MULTI and then you need to pass a list of commands that should be executed in the transaction, after which the entire transaction is executed by EXEC command.
redis 127.0.0.1:6379> MULTI 
OK 
List of commands here 
redis 127.0.0.1:6379> EXEC

Following example explains how Redis transaction can be initiated and executed.
redis 127.0.0.1:6379> MULTI 
OK 
redis 127.0.0.1:6379> SET tutorial redis 
QUEUED 
redis 127.0.0.1:6379> GET tutorial 
QUEUED 
redis 127.0.0.1:6379> INCR visitors 
QUEUED 
redis 127.0.0.1:6379> EXEC  
1) OK 
2) "redis" 
3) (integer) 1 

Following table shows some basic commands related to Redis transactions.
Discards all commands issued after MULTI
Executes all commands issued after MULTI
Marks the start of a transaction block
Forgets about all watched keys
Watches the given keys to determine the execution of the MULTI/EXEC block

    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page
java.time.LocalDateTime.truncatedTo() Method Example

The java.time.LocalDateTime.truncatedTo(TemporalUnit unit) method returns a copy of this LocalDateTime with the time truncated.
Following is the declaration for java.time.LocalDateTime.truncatedTo(TemporalUnit unit) method.
public LocalDateTime truncatedTo(TemporalUnit unit)

unit − the unit to truncate to, not null.
a LocalDateTime based on this date-time with the time truncated, not null.
DateTimeException − if unable to truncate.
DateTimeException − if unable to truncate.
UnsupportedTemporalTypeException − if the unit is not supported.
UnsupportedTemporalTypeException − if the unit is not supported.
The following example shows the usage of java.time.LocalDateTime.truncatedTo(TemporalUnit unit) method.
package com.tutorialspoint;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public class LocalDateTimeDemo {
   public static void main(String[] args) {
 
      LocalDateTime date = LocalDateTime.now();
      System.out.println(date.truncatedTo(ChronoUnit.DAYS));  
   }
}
Let us compile and run the above program, this will produce the following result −
2017-03-17T00:00

 Print
 Add Notes
 Bookmark this page
Angular 4 - Environment Setup

In this chapter, we will discuss the Environment Setup required for Angular 4. To install Angular 4, we require the following −
Nodejs
Npm
Angular CLI
IDE for writing your code
Nodejs has to be greater than 4 and npm has to be greater than 3.
To check if nodejs is installed on your system, type node –v in the terminal. This will help you see the version of nodejs currently installed on your system.
C:\>node –v
v6.11.0

If it does not print anything, install nodejs on your system. To install nodejs, go the homepage https://nodejs.org/en/download/ of nodejs and install the package based on your OS.
The homepage of nodejs will look like the following −
Based on your OS, install the required package. Once nodejs is installed, npm will also get installed along with it. To check if npm is installed or not, type npm –v in the terminal. It should display the version of the npm.
C:\>npm –v
5.3.0

Angular 4 installations are very simple with the help of angular CLI. Visit the homepage https://cli.angular.io/ of angular to get the reference of the command.
Type npm install –g @angular/cli, to install angular cli on your system.
You will get the above installation in your terminal, once Angular CLI is installed. You can use any IDE of your choice, i.e., WebStorm, Atom, Visual Studio Code, etc.
The details of the project setup is explained in the next chapter.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
Find sum of elements in list in Python program

In this article, we will learn about the solution to the problem statement given below.
Problem statement − We are given a list iterable, we need to compute the sum of the list
Here we will be discussing 3 approaches as discussed below
 Live Demo
# sum
total = 0
# creating a list
list1 = [11, 22,33,44,55,66]
# iterating over the list
for ele in range(0, len(list1)):
   total = total + list1[ele]
# printing total value
print("Sum of all elements in given list: ", total)
Sum of the array is 231
 Live Demo
# Python program to find sum of elements in list
total = 0
ele = 0
# creating a list
list1 = [11,22,33,44,55,66]
# iterating using loop
while(ele < len(list1)):
   total = total + list1[ele]
   ele += 1
# printing total value
print("Sum of all elements in given list: ", total)
Sum of the array is 231
# list
list1 = [11,22,33,44,55,66]
# function following recursion
def sumOfList(list, size):
if (size == 0):
   return 0
else:
   return list[size - 1] + sumOfList(list, size - 1)
# main
total = sumOfList(list1, len(list1))
print("Sum of all elements in given list: ", total)
Sum of the array is 231
In this article, we have learned how to print the sum of elements in a list.
How to make a unique field in MongoDB?

To make a unique field in MongoDB, use unique − true. Let us create a collection with documents −
> db.demo82.createIndex({"EmployeeName":1},{unique:true});
{
   "createdCollectionAutomatically" : true,
   "numIndexesBefore" : 1,
   "numIndexesAfter" : 2,
   "ok" : 1
}
> db.demo82.insertOne({"EmployeeName":"Chris"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e2bfb1b71bf0181ecc422a0")
}
> db.demo82.insertOne({"EmployeeName":"David"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e2bfb1f71bf0181ecc422a1")
}
> db.demo82.insertOne({"EmployeeName":"Chris"});
2020-01-25T13:54:00.410+0530 E QUERY [js] WriteError: E11000 duplicate key error collection: test.demo82 index: EmployeeName_1 dup key: { : "Chris" } :
WriteError({
   "index" : 0,
   "code" : 11000,
   "errmsg" : "E11000 duplicate key error collection: test.demo82 index: EmployeeName_1 dup key: { : \"Chris\" }",
   "op" : {
      "_id" : ObjectId("5e2bfb2071bf0181ecc422a2"),
      "EmployeeName" : "Chris"
   }
})
WriteError@src/mongo/shell/bulk_api.js:461:48
Bulk/mergeBatchResults@src/mongo/shell/bulk_api.js:841:49
Bulk/executeBatch@src/mongo/shell/bulk_api.js:906:13
Bulk/this.execute@src/mongo/shell/bulk_api.js:1150:21
DBCollection.prototype.insertOne@src/mongo/shell/crud_api.js:252:9
@(shell):1:1
Display all documents from a collection with the help of find() method −
> db.demo82.find();
This will produce the following output. Since, we use unique − true above, therefore the duplicate values won’t get insert −
{ "_id" : ObjectId("5e2bfb1b71bf0181ecc422a0"), "EmployeeName" : "Chris" }
{ "_id" : ObjectId("5e2bfb1f71bf0181ecc422a1"), "EmployeeName" : "David" }
HTML - <p> Tag

The HTML <p> tag defines a paragraph of text.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML p Tag</title>
   </head>

   <body>
      <p>This paragraph is defined using the HTML p tag</p>
   </body>

</html>
This will produce the following result −
This paragraph is defined using the HTML p tag
This tag supports all the global attributes described in − HTML Attribute Reference
The HTML <p> tag also supports the following additional attributes −
This tag supports all the event attributes described in − HTML Events Reference

    19 Lectures 
     2 hours 

 Anadi Sharma

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    18 Lectures 
     1.5 hours 

 Frahaan Hussain

    57 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)

    54 Lectures 
     6 hours 

 DigiFisk (Programming Is Fun)

    45 Lectures 
     5.5 hours 

 DigiFisk (Programming Is Fun)
 Print
 Add Notes
 Bookmark this page
C library function - strerror()

The C library function char *strerror(int errnum) searches an internal array for the error number errnum and returns a pointer to an error message string. The error strings produced by strerror depend on the developing platform and compiler.
Following is the declaration for strerror() function.
char *strerror(int errnum)
errnum − This is the error number, usually errno.
errnum − This is the error number, usually errno.
This function returns a pointer to the error string describing error errnum.
The following example shows the usage of strerror() function.
#include <stdio.h>
#include <string.h>
#include <errno.h>

int main () {
   FILE *fp;

   fp = fopen("file.txt","r");
   if( fp == NULL ) {
      printf("Error: %s\n", strerror(errno));
   }
   
   return(0);
}
Let us compile and run the above program that will produce the following result because we are trying to open a file which does not exist −
Error: No such file or directory


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
8085 program to convert a BCD number to binary - GeeksforGeeks

20 Nov, 2019
Problem – Write an assembly language program for converting a 2 digit BCD number to its binary equivalent using 8085 microprocessor.
Examples:
Input : 72H (0111 0010)2
Output : 48H (in hexadecimal) (0011 0000)2
((4x16)+(8x1))=72

Algorithm:
Load the BCD number in the accumulatorUnpack the 2 digit BCD number into two separate digits. Let the left digit be BCD1 and the right one BCD2Multiply BCD1 by 10 and add BCD2 to it
Load the BCD number in the accumulator
Unpack the 2 digit BCD number into two separate digits. Let the left digit be BCD1 and the right one BCD2
Multiply BCD1 by 10 and add BCD2 to it
If the 2 digit BCD number is 72, then its binary equivalent will be7 x OAH + 2 = 46H + 2 = 48H
Steps:
Load the BCD number from the memory location (201FH, arbitrary choice) into the accumulatorTemporarily store the accumulator’s value in BObtain BCD2 by ANDing the accumulator with 0FH and store it in CRestore the original value of the accumulator by moving the value in B to A. AND the accumulator with F0HIf the value in the accumulator equals 0, then BCD2 is the final answer and store it in the memory location, 2020H (arbitrary)Else, shift the accumulator to right 4 times to obtain BCD1. Next step is to multiply BCD1 by 0AHMultiplication: Move BCD1 to D and initialise E with 0AH as the counter. Clear the accumulator to 0 and add D to it E number of timesFinally, add C to the accumulator and store the result in 2020H
Load the BCD number from the memory location (201FH, arbitrary choice) into the accumulator
Temporarily store the accumulator’s value in B
Obtain BCD2 by ANDing the accumulator with 0FH and store it in C
Restore the original value of the accumulator by moving the value in B to A. AND the accumulator with F0H
If the value in the accumulator equals 0, then BCD2 is the final answer and store it in the memory location, 2020H (arbitrary)
Else, shift the accumulator to right 4 times to obtain BCD1. Next step is to multiply BCD1 by 0AH
Multiplication: Move BCD1 to D and initialise E with 0AH as the counter. Clear the accumulator to 0 and add D to it E number of times
Finally, add C to the accumulator and store the result in 2020H
2020H contains the result.
Store the BCD number in 201FH. 2020H contains its binary equivalent.
Akanksha_Rai
microprocessor
system-programming
Computer Organization & Architecture
microprocessor
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Addressing modes in 8085 microprocessor
Logical and Physical Address in Operating System
Memory Hierarchy Design and its Characteristics
8085 program to add two 8 bit numbers
Architecture of 8085 microprocessor
Computer Organization and Architecture | Pipelining | Set 1 (Execution, Stages and Throughput)
Pin diagram of 8086 microprocessor
Architecture of 8086
Memory mapped I/O and Isolated I/O
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Matplotlib – Plot over an image background in Python

To plot over an image background, we can take the following steps−
Read an image from a file into an array.
Create a figure (fig) and add a set of subplots (ax) with extent [0, 300, 0, 300].
Create an array x of range (300).
Plot x using plot() method with linestyle=dotted, linewidth=2, and color=red.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
im = plt.imread("bird.jpg")
fig, ax = plt.subplots()
im = ax.imshow(im, extent=[0, 300, 0, 300])
x = np.array(range(300))
ax.plot(x, x, ls='dotted', linewidth=2, color='red')
plt.show()
stack top() in C++ STL

In this article, we will be discussing the working, syntax, and examples of
stack::top() function in C++ STL.
Stacks are the data structure that stores the data in LIFO (Last In First Out) where we do insertion and deletion from the top of the last element inserted. Like a stack of plates, if we want to push a new plate into the stack we insert on the top and if we want to remove the plate from the stack, we then also remove it
from the top.
stack::top() function is an inbuilt function in C++ STL, which is defined in <stack>
header file. top() is used to access the element at the top of the stack container. In a stack, the top element is the element that is inserted at the last or most recently inserted element.
stack_name.top();
The function accepts no parameter(s) −
This function returns a reference of the element at the top of the stack container.
Input 
std::stack<int> odd;
odd.emplace(1);
odd.emplace(3);
odd.emplace(5);
odd.top();
Output
5
 Live Demo
#include <iostream>
#include <stack&lgt;
using namespace std;
int main(){
   stack<int> stck_1, stck_2;
   //inserting elements to stack 1
   stck_1.push(1);
   stck_1.push(2);
   stck_1.push(3);
   stck_1.push(4);
   //swapping elements of stack 1 in stack 2 and vice-versa
   cout<<"The top element in stack using TOP(): "<<stck_1.top();
   cout<<"\nElements in stack are: ";
   while (!stck_1.empty()){
      cout<<stck_1.top()<<" ";
      stck_1.pop();
   }
   return 0;
}
If we run the above code it will generate the following output −
The top element in stack using TOP(): 4
Elements in stack are: 4 3 2 1
override Keyword in C++

The function overriding is the most common feature of C++. Basically function overriding means redefine a function which is present in the base class, also be defined in the derived class. So the function signatures are the same but the behavior will be different.
But there may be a situation when a programmer makes a mistake while overriding that function. Like if the signature is not the same, then that will be treated as another function, but not the overridden method or that. In that case, we can use the override keyword. This keyword is introduced in C+ +11. When the compiler finds this kind of keyword, it can understand that this is an overridden version of the same class.
Let us see the example to understand the concept.
#include <iostream>
using namespace std;
class BaseClass{
   public:
      virtual void display() {
         cout << "Displaying from Base Class\n";
      }
};
class DerivedClass : public BaseClass{
   public:
      void display() {
         cout << "Displaying from Derived Class\n";
      }
};
main() {
   BaseClass *b_ptr;
   b_ptr = new DerivedClass();
   b_ptr->display();
}
Displaying from Derived Class
In this case the program is working fine as the signatures are the same. In the following example, the signature will be different. For the override keyword, it will generate an error.
#include <iostream>
using namespace std;
class BaseClass{
   public:
      virtual void display() {
         cout << "Displaying from Base Class\n";
      }
};
class DerivedClass : public BaseClass{
   public:
      void display(int x) override{
         cout << "Displaying from Derived Class\n";
      }
};
main() {
   BaseClass *b_ptr;
   b_ptr = new DerivedClass();
   b_ptr->display();
}
[Error] 'void DerivedClass::display(int)' marked override, but does not override
In this case, the program is working fine as the signatures are the same. In the following example, the signature will be different. For the override keyword, it will generate error.
Program to count number of elements in a list that contains odd number of digits in Python

Suppose we have a list of positive numbers called nums, we have to find the number of
elements that have odd number of digits.
So, if the input is like [1, 300, 12, 10, 3, 51236, 1245], then the output will be 4
To solve this, we will follow these steps −
c:= 0
for i in range 0 to size of nums, dos:= digit count of nums[i]if s is odd, thenc:= c+1
s:= digit count of nums[i]
if s is odd, thenc:= c+1
c:= c+1
return c
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, nums):
      c=0
      for i in range(len(nums)):
         s=len(str(nums[i]))
         if s%2!=0:
            c=c+1
      return c
ob = Solution()
print(ob.solve([1, 300, 12, 10, 3, 51236, 1245]))
[1, 300, 12, 10, 3, 51236, 1245]
4