code-rag-bench/online-tutorials huggingface dataset:
Interpolated Verbatim Strings in C# 8.0

29 Dec, 2019
Before C# 8.0 you are allowed to use string interpolation($) and verbatim identifier(@) together but in a specific sequence. It means when you use $ token and @ token together, it is necessary that $ token must appear before the @ token. If you use the @ token before $ token, then the compiler will give you an error, like as shown in the below example:
Example 1:
// C# program to illustrate the use// of interpolated verbatim stringsusing System;   class GFG {          // Main Method    static void Main()    {        int Base = 10;        int Height = 30;        int area = (Base * Height) / 2;           // Here, $ token appears before @ token        Console.WriteLine("Finding the area of a triangle:");        Console.WriteLine($@"Height = ""{Height}"" and Base = ""{Base}""");        Console.WriteLine($@"Area = ""{area}""");    }}
Output:
Finding the area of a triangle:
Height = "30" and Base = "10"
Area = "150"

Example 2:
// C# program to illustrate the use // of interpolated verbatim stringsusing System;   class GFG {          // Main Method    static void Main()    {        int Base = 10;        int Height = 30;        int area = (Base * Height) / 2;           // Here, @ token appears before $ token        // But the compiler will give an error        Console.WriteLine("Finding the area of a triangle:");        Console.WriteLine(@ $"Height = ""{Height}"" and Base = ""{Base}""");                           Console.WriteLine(@ $"Area = ""{area}""");    }}
Error:
error CS1646: Keyword, identifier, or string expected after verbatim specifier: @error CS1646: Keyword, identifier, or string expected after verbatim specifier: @
When we use a @ token before $ token, then the compiler gives an error. This problem is solved in C# 8.0, now you are allowed to use a @ token before $ token or $ token before @ token
$@"..."
Or
@$"..."

and the compiler will not give an error. As shown in the below example:
Example:
// C# program to illustrate the use// of interpolated verbatim stringsusing System;   namespace Geeks {      class GFG {          // Main Method    static void Main(string[] args)    {        int Base = 40;        int Height = 80;        int area = (Base * Height) / 2;        Console.WriteLine("Finding the area of a triangle:");           // Here, $ token appears before @ token        Console.WriteLine($@"Height = ""{Height}"" and Base = ""{Base}""");           // Here, @ token appears before $ token        Console.WriteLine(@$"Area = ""{area}""");    }}}
Output:
Finding the area of a triangle:
Height = "80" and Base = "40"
Area = "1600"

CSharp-8.0
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL – CREATE SCHEMA

28 Aug, 2020
PostgreSQL has a CREATE SCHEMA statement that is used to create a new schema in a database.
Syntax:
CREATE SCHEMA [IF NOT EXISTS] schema_name;
Let’s analyze the above syntax:
First, specify the name of the schema after the CREATE SCHEMA keywords. The schema name must be unique within the current database.
Second, optionally use IF NOT EXISTS to conditionally create the new schema only if it does not exist. Attempting to create a new schema that already exists without using the IF NOT EXISTS option will result in an error.
Note: To execute the CREATE SCHEMA statement, you must have the CREATE privilege in the current database.To create a schema for a user use the following:
Syntax:
CREATE SCHEMA [IF NOT EXISTS] AUTHORIZATION user_name;
Now that we have known the basics of creating a schema in PostgreSQL, let’s jump into some examples.
Example 1:The following statement uses the CREATE SCHEMA statement to create a new schema named marketing:
CREATE SCHEMA IF NOT EXISTS marketing;
The following statement returns all schemas from the current database:
SELECT 
  * 
FROM 
    pg_catalog.pg_namespace
ORDER BY 
    nspname;
Output:
Example 2:In this example, we will create a schema for a user (say, Raju). to do show let’s first create a user using the below statement:
CREATE USER Raju WITH ENCRYPTED PASSWORD 'Postgres123';
Now create a schema for the user Raju as follows:
CREATE SCHEMA AUTHORIZATION Raju;
Third, create a new schema that will be owned by Raju:
CREATE SCHEMA IF NOT EXISTS geeksforgeeks AUTHORIZATION Raju;
The following statement returns all schemas from the current database:
SELECT 
  * 
FROM 
    pg_catalog.pg_namespace
ORDER BY 
    nspname;
Output:
postgreSQL-schema
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Import JSON Data into SQL Server?

23 Sep, 2021
JSON refers to Javascript Object Notation. It is a popular text data format used to exchange data on modern web and mobile applications. It is based on a subset of the Javascript programming language. It is used to store random data in log files or NoSQL.
It also enables us to integrate NoSQL and related concepts into the same database. 
Lightweight data-interchange format.
Easy for humans to read and write.
Easy for machines to parse and generate.
We can parse the JSON text and read or modify the values.
Transform JSON objects into table format.
We can run any Transact-SQL query on the converted JSON objects.
Transform the results of Transact-SQL queries back to JSON format.
 
Now, to import JSON data in the SQL server, we will use OPENROWSET (BULK). 
Step 1: Use of OPENROWSET(BULK) 
It is a table-valued function that can read data from any file.. It returns a table with a single column that contains all the contents of the file. It can just load the entire contents of a file as a text value. (This single large value is known as a single character large object or SINGLE_CLOB.)
Syntax: 
SELECT * FROM OPENROWSET (BULK 'file_path', SINGLE_CLOB) as correlation_name;
It reads the content of the file and returns it in BulkColumn. The correlation name must be specified. We have the JSON file named “file1.json”. Content of JSON file:
Query:
[{"Firstname": "ROMY", "Lastname": "KUMARI", "Gender": "female", "AGE" : 22 },
{"Firstname": "PUSHKAR", "Lastname": "JHA", "Gender": "male", "AGE" : 22 },
{"Firstname": "SHALINI", "Lastname": "JHA", "Gender": "female", "AGE" : 21 },
{"Firstname": "SAMBHAVI", "Lastname": "JHA", "Gender": "female", "AGE" : 18 } ]
Step 2: Import file1.json into SQL server
Query:
SELECT * FROM OPENROWSET (BULK 'E:\file1.json', Single_CLOB) AS import;
Output:
The entire content is returned as a single column.
Step 3: Convert JSON data
Declare a variable.
Store data of Bulkcolumn in a variable.
Use OPENJSON() function for converting the JSON output from a variable into a tabular format.
WITH clause along with the column definition (key should be used as column name).
Query:
Declare @JSON varchar(max)
SELECT @JSON=BulkColumn
FROM OPENROWSET (BULK 'E:\file1.json', SINGLE_CLOB) import
SELECT * FROM OPENJSON (@JSON)
WITH  (
   [Firstname] varchar(20),  
   [Lastname] varchar(20),  
   [Gender] varchar(20),  
   [AGE] int );
Output:
Blogathon-2021
Picked
Blogathon
How To
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary Comprehension

07 Nov, 2017
Like List Comprehension, Python allows dictionary comprehensions. We can create dictionaries using simple expressions.A dictionary comprehension takes the form {key: value for (key, value) in iterable}
Let’s see a example,lets assume we have two lists named keys and value now,
# Python code to demonstrate dictionary # comprehension  # Lists to represent keys and valueskeys = ['a','b','c','d','e']values = [1,2,3,4,5]    # but this line shows dict comprehension here  myDict = { k:v for (k,v) in zip(keys, values)}    # We can use below too# myDict = dict(zip(keys, values))    print (myDict)
Output :
{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}
We can also make dictionary from a list using comprehension
# Python code to demonstrate dictionary # creation using list comprehensionmyDict = {x: x**2 for x in [1,2,3,4,5]}print (myDict)
Output :
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
and like,
sDict = {x.upper(): x*3 for x in 'coding '}print (sDict)
Output :
{'O': 'ooo', 'N': 'nnn', 'I': 'iii', 'C': 'ccc', 'D': 'ddd', 'G': 'ggg'}
We can use Dictionary comprehensions with if and else statements and with other expressions too. This example below maps the numbers to their cubes that are not divisible by 4:
# Python code to demonstrate dictionary # comprehension using if.newdict = {x: x**3 for x in range(10) if x**3 % 4 == 0}print(newdict)
Output :
{0: 0, 8: 512, 2: 8, 4: 64, 6: 216}
This article is contributed by Shantanu Sharma.. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
python-dict
Python
python-dict
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Find the tuples containing the given element from a list of tuples

26 Jul, 2021
Given a list of tuples, the task is to find all those tuples containing the given element, say n.Examples:  
Input: n = 11, list = [(11, 22), (33, 55), (55, 77), (11, 44)] Output: [(11, 22), (11, 44)]Input: n = 3, list = [(14, 3),(23, 41),(33, 62),(1, 3),(3, 3)] Output: [(14, 3), (1, 3), (3, 3)]
There are multiple ways we can find the tuples containing the given element from a list of tuples. Let’s see some of Pythonic ways to do this task. Method #2: Using list comprehension. It works only when there are fixed number of elements in every list. For example 2 elements in below code. 
Python3
# Python code to find the tuples containing# the given element from a list of tuples # List of tuplesInput = [(14, 3),(23, 41),(33, 62),(1, 3),(3, 3)] # Find an element in list of tuples.Output = [item for item in Input          if item[0] == 3 or item[1] == 3] # printing outputprint(Output)
[(14, 3), (1, 3), (3, 3)]
 
  Method #1 : Using filter In this solution, there can be variable number of nodes in lists. 
Python3
# Python code to find the tuples containing# the given element from a list of tuples # List of tuplesInput = [(11, 22), (33, 55), (55, 77),         (11, 44), (33, 22, 100, 11), (99, 11)] # Using filterOutput = list(filter(lambda x:11 in x, Input)) # Printing outputprint(Output)
[(11, 22), (11, 44), (33, 22, 100, 11), (99, 11)]
 
  
sumitgumber28
Python tuple-programs
python-tuple
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Haskell - Nested if-else statement

In the above example, we have seen the use of if-else statement in Haskell. Here, we will learn how to use multiple if-else statements in one Haskell program.
In Haskell, multiple lines of if will be used by separating each of the if statement with its corresponding else statement.
The following code shows how you can use nested if-else statement in Haskell −
main = do   
   let var = 26 
   
   if var == 0 
      then putStrLn "Number is zero" 
   else if var `rem` 2 == 0 
      then putStrLn "Number is Even" 
   else putStrLn "Number is Odd"
In the above example, we have introduced multiple conditions in one function. Depending on the function inputs, it will provide us different outputs. You can change the value of the variable "var" to check all the conditions.
Our code will produce the following output −
Number is Even

 Print
 Add Notes
 Bookmark this page
CodeIgniter - Application Profiling

When building a web application, we are very much concerned about the performance of the website in terms of how much time the controller took to execute and how much memory is used. Not only the performance, but we also need to see the insights of data like POST data, data of database queries, session data etc. for debugging purpose while developing some application. CodeIgniter has made this job easier for us by profiling an application.
To enable profiling of your application, simply execute the command given below in any of the method of your controller.
$this->output->enable_profiler(TRUE);

The report of the profiling can be seen at the bottom of the page after enabling it.
To disable profiling of your application, simply execute the command given below in any of the method of your controller.
$this->output->enable_profiler(FALSE);

Profiling can be done on section basis. You can enable or disable profiling of a section by setting a Boolean value TRUE or FALSE. If you want to set profiling on the application then you can do in a file located in application/config/profiler.php
For example, the following command will enable profiling queries for the whole application.
$config['queries'] = TRUE;

In the following table, the key is the parameter, which can be set in the config array to enable or disable a particular profile.
benchmarks
config
controller_info
get
http_headers
memory_usage
post
queries
uri_string
session_data
query_toggle_count
The profiler set in the file in application/config/profiler.php can be overridden by using the set_profiler_sections() function in controllers as shown below.
$sections = array( 
   'config'  => TRUE, 
   'queries' => TRUE 
); 
 
$this->output->set_profiler_sections($sections);
 Print
 Add Notes
 Bookmark this page
Python 3 - String join() Method

The join() method returns a string in which the string elements of sequence have been joined by str separator.
Following is the syntax for join() method −
str.join(sequence)

sequence − This is a sequence of the elements to be joined.
This method returns a string, which is the concatenation of the strings in the sequence seq. The separator between elements is the string providing this method.
The following example shows the usage of join() method.
#!/usr/bin/python3

s = "-"
seq = ("a", "b", "c") # This is sequence of strings.
print (s.join( seq ))
When we run above program, it produces the following result −
a-b-c


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Create a procedure in MySQL with parameters?

You can create a parameter using IN and OUT. IN is used to take input parameter and OUT can be used for output.
The syntax is as follows
DELIMITER //
CREATE PROCEDURE yourProcedureName(IN yourParameterName dataType,OUT
   yourParameterName dataType
)
BEGIN
yourStatement1;
yourStatement2;
.
.
N
END;
//
DELIMITER ;
First, we will create a table. The query to create a table is as follows
mysql> create table SumOfAll
   -> (
   -> Amount int
   -> );
Query OK, 0 rows affected (0.78 sec)
Insert some records in the table using insert command. The query is as follows
mysql> insert into SumOfAll values(100);
Query OK, 1 row affected (0.18 sec)

mysql> insert into SumOfAll values(330);
Query OK, 1 row affected (0.24 sec)

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

mysql> insert into SumOfAll values(400);
Query OK, 1 row affected (0.20 sec)
Display all records from the table using select statement. The query is as follows
mysql> select *from SumOfAll;
The following is the output
+--------+
| Amount |
+--------+
| 100    |
| 330    |
| 450    |
| 400    |
+--------+
4 rows in set (0.00 sec)
Now, we will create a stored procedure that will check the value is present in the table or not. If the given value is not present in the table then you will get a NULL value.
The stored procedure is as follows
mysql> DELIMITER //
mysql> create procedure sp_ChechValue(IN value1 int,OUT value2 int)
   -> begin
   -> set value2=(select Amount from SumOfAll where Amount=value1);
   -> end;
   -> //
Query OK, 0 rows affected (0.20 sec)
mysql> delimiter ;
Let us call the stored procedure with some value and store the output in a session variable.
Case 1: When the value is not present in the table.
mysql> call sp_ChechValue(300,@isPresent);
Query OK, 0 rows affected (0.00 sec)
Now check the value in a variable @isPresent using the select statement. The query is as follows
mysql> select @isPresent;
The following is the output
+------------+
| @isPresent |
+------------+
| NULL       |
+------------+
1 row in set (0.00 sec)
Case 2: When the value is present.
The query is as follows. Let us call the stored procedure
mysql> call sp_ChechValue(330,@isPresent);
Query OK, 0 rows affected (0.00 sec)
Check the value of a session variable @isPresent. The query is as follows
mysql> select @isPresent;
The following is the output
+------------+
| @isPresent |
+------------+
| 330        |
+------------+
1 row in set (0.00 sec)
Connect to external server by using phpMyAdmin

The below lines of code can be added to the /etc/phpmyadmin/config.inc.php file at the bottom −
$i++;
$cfg['Servers'][$i]['host'] = 'HostName:port'; 
// hostname and port are provided if they are not default values
$cfg['Servers'][$i]['user'] = 'userName'; 
//user name for the remote server
$cfg['Servers'][$i]['password'] = 'Password'; 
//the password
$cfg['Servers'][$i]['auth_type'] = 'config';
It will display “Current Server:” with drop down of both "127.0.0.1" and the one provided with cfg[′Servers′][i]['host'].
The user can switch between both the servers.
How to set focus on Entry widget in Tkinter?

Let us suppose that there are some widgets present in an application such that we have to focus on a particular widget. By using the focus_set() method, we can activate the focus on any widget and give them priority while executing the application.
#Import tkinter library
from tkinter import *

#Create an instance of tkinter frame
win = Tk()

#Set the geometry of tkinter window
win.geometry("750x250")

#Create an Entry Widget
entry= Entry(win, width= 25)
entry.insert(0,"ttk Entry widget")
entry.pack()

#Set the focus to Entry widget
entry.focus_set()
win.mainloop()
When we run our program, it will display a window with an active entry widget.
How to convert a Bitmap to Drawable in Kotlin?

This example demonstrates how to convert a Bitmap to Drawable in Kotlin.
Step 1 − Create a new project in Android Studio, go to File? New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity">
   <Button
      android:id="@+id/btnConvert"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="10dp"
      android:text="Convert bitmap to Drawable" />
   <ImageView
      android:id="@+id/imageView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_below="@id/btnConvert"
      android:layout_marginTop="10dp" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.kt
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() {
   lateinit var imageView: ImageView
   lateinit var button: Button
   lateinit var bitmap: Bitmap
   lateinit var drawable: Drawable
   override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_main)
      title = "KotlinApp"
      imageView = findViewById(R.id.imageView)
      button = findViewById(R.id.btnConvert)
      button.setOnClickListener {
         drawable = applicationContext.resources.getDrawable(R.drawable.image)
         bitmap = (drawable as BitmapDrawable).bitmap
         val d = BitmapDrawable(bitmap)
         imageView.setImageDrawable(d)
      }
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.myapplication">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click the Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen
How to handle a Button click event in tkinter?

Sometimes, handling events in a Tkinter application can become a daunting task for us. We have to manage the action and events which need to be executed at the time of running the application. The Button widget is useful for handling such events. We can use Button widget to perform a certain task or event by passing the callback in the command.
While giving the command to the Button widget, we can have an optional lambda or anonymous functions which interpret to ignore any errors in the program. These are just like a general function but they don't have any function bodies in it.
In this example, we will create a button and pass the function to show a popup message on the window.
# Import the required libraries
from tkinter import *
from tkinter import messagebox
from tkinter import ttk

# Create an instance of tkinter frame
win= Tk()

# Set the size of the tkinter window
win.geometry("700x350")

# Define a function to show the popup message
def show_msg():
   messagebox.showinfo("Message","Hey There! I hope you are doing well.")

# Add an optional Label widget
Label(win, text= "Welcome Folks!", font= ('Aerial 17 bold italic')).pack(pady= 30)

# Create a Button to display the message
ttk.Button(win, text= "Click Here", command=show_msg).pack(pady= 20)
win.mainloop()
Running the above code will display a window with a Button widget. When we click the button, it will trigger an event to happen.
Now, click the Button to see the event of displaying the popup message on the screen.
How to Create a Covariance Matrix in R? - GeeksforGeeks

04 Jan, 2022
In this article, we will discuss how to create a Covariance Matrix in the R Programming Language.
Covariance is the statistical measure that depicts the relationship between a pair of random variables that shows how the change in one variable causes changes in another variable. It is a measure of the degree to which two variables are linearly associated. 
A covariance matrix is a square matrix that shows the covariance between different variables of a data frame. This helps us in understanding the relationship between different variables in a dataset.
To create a Covariance matrix from a data frame in the R Language, we use the cov() function. The cov() function forms the variance-covariance matrix. It takes the data frame as an argument and returns the covariance matrix as result.
Syntax: 
cov( df )
Parameter:
df: determines the data frame for creating covariance matrix.
A positive value for the covariance matrix indicates that two variables tend to increase or decrease sequentially. A negative value for the covariance matrix indicates that as one variable increases, the second variable tends to decrease.
Example 1: Create Covariance matrix
R
# create sample data framesample_data <- data.frame( var1 = c(86, 82, 79, 83, 66),                           var2 = c(85, 83, 80, 84, 65),                           var3 = c(107, 127, 137, 117, 170))  # create covariance matrixcov( sample_data )
Output:
       var1   var2   var3
var1   60.7   63.9 -185.9
var2   63.9   68.3 -192.8
var3 -185.9 -192.8  585.8
Example 2: Create Covariance matrix
R
# create sample data framesample_data <- data.frame( var1 = rnorm(20,5,23),                           var2 = rnorm(20,8,10))  # create covariance matrixcov( sample_data )
Output:
          var1      var2
var1 642.00590 -14.66349
var2 -14.66349  88.71560
Picked
R-Matrix
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to Change Axis Scales in R Plots?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
R - if statement
How to filter R dataframe by multiple conditions?
Plot mean and standard deviation using ggplot2 in R
Time Series Analysis in R
Python – Replace String by Kth Dictionary value

01 Aug, 2020
Given list of Strings, replace the value mapped by Kth value of mapped list.
Input : test_list = [“Gfg”, “is”, “Best”], subs_dict = {“Gfg” : [5, 6, 7], “is” : [7, 4, 2]}, K = 0Output : [5, 7, “Best”]Explanation : “Gfg” and “is” is replaced by 5, 7 as 0th index in dictionary value list.
Input : test_list = [“Gfg”, “is”, “Best”], subs_dict = {“Gfg” : [5, 6, 7], “Best” : [7, 4, 2]}, K = 0Output : [5, “is”, 7]Explanation : “Gfg” and “Best” is replaced by 5, 7 as 0th index in dictionary value list.
Method #1 : Using list comprehension
This is one of the ways in which this task can be performed. In this, we perform the task iteration and conditional replacement inside one-liner in list comprehension.
Python3
# Python3 code to demonstrate working of # Replace String by Kth Dictionary value  # Using list comprehension  # initializing listtest_list = ["Gfg", "is", "Best"]  # printing original listprint("The original list : " + str(test_list))  # initializing subs. Dictionarysubs_dict = {    "Gfg" : [5, 6, 7],     "is" : [7, 4, 2], }  # initializing K K = 2  # using list comprehension to solve# problem using one linerres = [ele if ele not in subs_dict else subs_dict[ele][K]                                     for ele in test_list]          # printing result print("The list after substitution : " + str(res))
The original list : ['Gfg', 'is', 'Best']
The list after substitution : [7, 2, 'Best']

Method #2 : Using get() + list comprehension
The combination of above functions can be used to solve this problem. In this, we iterate using list comprehension and check for key existence and substitution using get().
Python3
# Python3 code to demonstrate working of # Replace String by Kth Dictionary value  # Using get() + list comprehension  # initializing listtest_list = ["Gfg", "is", "Best"]  # printing original listprint("The original list : " + str(test_list))  # initializing subs. Dictionarysubs_dict = {    "Gfg" : [5, 6, 7],     "is" : [7, 4, 2], }  # initializing K K = 2  # using list comprehension to solve problem using one liner# get() to perform presence checks and assign default valueres = [subs_dict.get(ele, ele) for ele in test_list]res = [ele[K] if isinstance(ele, list) else ele for ele in res]           # printing result print("The list after substitution : " + str(res))
The original list : ['Gfg', 'is', 'Best']
The list after substitution : [7, 2, 'Best']

Python dictionary-programs
Python list-programs
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
QTP - Child Objects

The objects (text box, combo box, links) contained in the frame or window is known as child objects. Sometimes, we would be in a situation to get the properties of all the links in a webpage or to get the values of all radio buttons in a window.
In these circumstances, if we want to work on the child objects, we need to use description of objects using which we will be able to work on all the objects in a particular window/page. Descriptive programming will be dealt in detail in the upcoming chapter but the significance of this chapter is to understand child objects and its usage.
The following Script gets the name of the links from the website "www.easycalculation.com"
Dim oDesc
Set oDesc = Description.Create
oDesc("micclass").value = "Link"

'Find all the Links
Set obj = Browser("Math Calculator").Page("Math Calculator").ChildObjects(oDesc)

Dim i
'obj.Count value has the number of links in the page

For i = 0 to obj.Count - 1				
   'get the name of all the links in the page
   x = obj(i).GetROProperty("innerhtml") 
   print x 
Next
The Result is printed in the output window as shown below −
How to Change the Oracle Database Password?

14 Sep, 2021
Select a secure password and implementing complex password policies are by far the most important defense for protecting against password-based security threats in any database. Here are several methods for changing or resetting the password for an Oracle database. We can change the Oracle database password using two different methods: 
By using ALTER USER command in the oracle database.
By using the PASSWORD command in the command prompt.
1. log in to your oracle database as you normally would. Here we log in as username system and password geeks123.
2. Use alter user command and specify the new password for your user
Syntax:
 ALTER USER  user_name IDENTIFIED BY new_password ;
Here ‘system’ is a username and now the new password for ‘system’ becomes ‘Newgeeks123’ it means ‘system’ is now identified by password Newgeeks123. The password is changed from geeks123 to Newgeeks123.
Output:
3. You don’t need any other privileges to change your own password. The same command can be used to change the password for another user from your database, that user behaves as a proxy user. You can use that proxy user and a new set password to login into your database.
4. Now if trying to log in with an old password (geeks123) it will show an invalid credential as shown below, it will log in successfully when login with a new password (Newgeeks123.)
1. Open command prompt window, enter sqlplus command to login into oracle database.
2. Enter your username and password.
3. It will show a message like connected to oracle database and your version name as shown below.
4. Enter the password at the SQL prompt. You will be prompted for your Old password and the New password.
5. Type your Old Password and press enter. Now type a New Password and press enter.
6. Enter the New Password again and press enter. You will receive a confirmation that your password has changed for the database to which you were logged in as shown below.
Oracle
Picked
How To
SQL
Oracle
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Convert Tick-by-Tick data into OHLC (Open-High-Low-Close) Data

17 Jul, 2020
In this post, we’ll explore a Python pandas package feature. We frequently find queries about converting tick-by-tick data to OHLC (Open, High, Low and Close). Using pandas kit this can be done with minimum effort. The OHLC data is used over a unit of time (1 day, 1 hour etc.) to perform a technical analysis of price movement.
The First Step:The first step relates to the collection of sample data. Let’s import tick sample tick by tick data. We will use the January data for AUD / JPY (Australian Dollar / Japanese Yen) pair which was downloaded from Pepperstone (an external source) for this tutorial.
# importing librariesimport pandas as pd
Code: Loading the data.
data_frame = pd.read_csv(    'AUDJPY-2016-01.csv', names=['Symbol', 'Date_Time', 'Bid', 'Ask'],                                       index_col=1, parse_dates=True)data_frame.head()
Data is stored with the name ‘AUDJPY-2016-01.csv’ in the working directory. As we saw earlier, there is no header to the data. We will then add a header to the data when importing it. Importing and adding headers thus occurs in the same line of code.The resample attribute of a data frame for pandas is used. The resample feature allows standard time-series data to be re-examined. For 15 minutes, we must resample the data and partition it into OHLC format. Using L for milliseconds, U for microseconds, and S for seconds if you want to resample for smaller time frames (milliseconds/microseconds/seconds), etc.
data_ask = data_frame['Ask'].resample('15Min').ohlc()data_bid = data_frame['Bid'].resample('15Min').ohlc()
Code: ‘Ask’ Dataframe
data_ask.head()
data_bid.head()
Code: Merging of ‘ask’ and ‘bid’ dataframe
data_ask_bid = pd.concat(    [data_ask, data_bid], axis=1,     keys=['Ask', 'Bid'])
Conclusion:This is a fast way of using TBT data to compute the OHLC. This can be applied across assets, and based on the OHLC data, one can devise various strategies. We can also plot OHLC-based maps, and generate trade signals. Another way to use the data is to build technical indicators in python, or to calculate risk-adjusted returns.
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Topological Sorting using graphlib Python module

17 Dec, 2020
Topological Sorting is a linear ordering for vertices of Directed Acyclic Graph. For every directed edge u v, vertex u comes before v in the topological sorting.
Python’s module graphlib introduced in Python 3.9.0, gives the topological sorting of a graph, where the graph is represented in a dictionary. Assume the graph with no parallel edges, the graph can be represented by a dictionary with vertices as keys and values are the nodes to which they are connected.
To install this module run this command into your terminal.
pip install graphlib
We will use class graphlib. TopologicalSorter(graph= None), and the following functions with the TopologicalSorter instance:
add( node, *predecessors ):
Adds a new node and it’s dependencies to a graph. For example, ts.add(3, 2, 1) adds key value 3 and it’s predecessors 2, 1 to the graph.  
static_order():
Returns an iterable of nodes in a topological order.
Check the programs below for topological sorting with graphlib.TopologicalSorter()
Example 1: Topological sorting using TopologicalSorter with graph not initialized.
Python3
# Python 3.9.0 program for# topological sorting using# graphlib modulefrom graphlib import TopologicalSorter  # creating an instance of TopologicalSorter# initial graph is optionalts = TopologicalSorter()  # adding vertex and it's nodests.add(3, 2, 1)# adding more node and predecessorts.add(1, 0)  # printing the topological order# returned by static_order()print([*ts.static_order()])
Output:
[2, 0, 1, 3]
Example 2: Topological sorting using TopologicalSorter using graph initialized.
Python3
# Python program for topological sorting# through graphlib module  from graphlib import TopologicalSorter  # making graphgraph = {2: {3}, 3: {1}, 4: {0, 1}, 5: {0, 2}}  # creating an instance of TopolocialSorter# with initial graph(initial graph is optional)ts = TopologicalSorter(graph)  # printing the topological order# returned by static_order()print([*ts.static_order()])
Output:
[1, 0, 3, 4, 2, 5]
python-modules
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
echo command in Linux with Examples

01 Jul, 2022
echo command in linux is used to display line of text/string that are passed as an argument . This is a built in command that is mostly used in shell scripts and batch files to output status text to the screen or a file. 
Syntax :
echo [option] [string]
Displaying a text/string : Syntax :
echo [string]
Example :  
Options of echo command NOTE :- -e here enables the interpretation of backslash escapes 
1. \b : it removes all the spaces in between the text Example :
echo -e "Geeks \bfor \bGeeks"
 
2. \c : suppress trailing new line with backspace interpreter ‘-e‘ to continue without emitting new line. Example :
echo -e "Geeks \cfor Geeks"
 
In above example, text after \c is not printed and omitted trailing new line. 
3. \n : this option creates new line from where it is used. Example :
 echo -e "Geeks \nfor \nGeeks"
 
4. \t : this option is used to create horizontal tab spaces. Example :
echo -e "Geeks \tfor \tGeeks"
 
5. \r : carriage return with backspace interpreter ‘-e‘ to have specified carriage return in output. Example :
echo -e "Geeks \rfor Geeks"
 
In the above example, text before \r is not printed. 
6. \v : this option is used to create vertical tab spaces. Example :
echo -e "Geeks \vfor \vGeeks
 
7. \a : alert return with backspace interpreter ‘-e‘ to have sound alert. Example :
echo -e "\aGeeks for Geeks
 
This command when executed, it will produce an alert sound or Bel . 
8. echo * : this command will print all files/folders, similar to ls command . Example :
echo *
 
9. -n : this option is used to omit echoing trailing newline . Example :
echo -n "Geeks for Geeks"
Linux Tutorials | General Purpose Utilities | GeeksforGeeks - YouTubeGeeksforGeeks529K subscribersLinux Tutorials | General Purpose Utilities | GeeksforGeeksWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:000:00 / 4:09•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=g6cPFj9ptdc" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>
?t=153
sidhanthnandansaaho
linux-command
Linux-Shell-Commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
tar command in Linux with examples
curl command in Linux with Examples
Conditional Statements | Shell Script
TCP Server-Client implementation in C
Tail command in Linux with examples
Docker - COPY Instruction
scp command in Linux with Examples
UDP Server-Client implementation in C
diff command in Linux with examples
How to get the source code of a web page using PHP ?

08 Feb, 2021
Given a webpage, for which we need to find its source code using PHP. For this, we are going to use the PHP htmlspecialchars() function which converts any predefined characters to their subsequent HTML entities.
Example 1: Suppose we take a sample website that looks like the below image, let us see what output would the code produce for the same.
HTML code:
HTML
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title>SAMPLE WEBSITE</title></head>  <body style="color: green;">    <h1>This is a Sample website</h1>      <p>        In this article we will learn         how to extract a web page's         source code through PHP    </p></body>  </html>
Output:
Output as source code contents:
Now let us suppose the above website is hosted on a localhost, the code would fail to load the source code in such a case. The output produced would be something similar to this.
Output:
Warning: file(file:///D:/Html%20website/gfg%20sample%20website/index.html): Failed to open stream: No such file or directory in C:\xampp\htdocs\programs\source code.php on line 2
Warning: foreach() argument must be of type array|object, bool given in C:\xampp\htdocs\programs\source code.php on line 3
Example 2:
Approach:
Store its elements into an array.
Traverse the array using a PHP programming loop.
Convert and print each character into its subsequent HTML entity.
PHP code: Below is the implementation of the above approach.
PHP
<?php  // Storing the elements of the webpage into an array$source_code = file('https://www.geeksforgeeks.org');  // 1. traversing through each element of the array// 2.printing their subsequent HTML entitiesforeach ($source_code as $line_number => $last_line) {    echo nl2br(htmlspecialchars($last_line) . "\n");}  ?>
Output:
PHP-Questions
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Implicit and Explicit Cursors - GeeksforGeeks

08 Feb, 2022
Databases such as ORACLE have a memory area, where processing of instructions and fetched data takes place.A cursor is a pointer which is pointing to this area.The data contained in this memory area is also known as Active Set. Cursors can be broadly classified into Implicit Cursors and Explicit Cursors. 
Difference between Implicit and Explicit Cursors :  
Implicit Cursors are defined as:  
BEGIN
SELECT attr_name from table_name
where CONDITION;
END
 
Explicit cursors are defined as:  
DECLARE
CURSOR cur_name IS
SELECT attr_name from table_name 
where CONDITION;
BEGIN
...
 
Few explicit cursors are: cur_name%FOUND, cur_name%NOTFOUND, cur_name%ROWCOUNT
surindertarika1234
rkbhola5
DBMS
Difference Between
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Functional dependencies in DBMS
Deadlock in DBMS
KDD Process in Data Mining
What is Temporary Table in SQL?
Conflict Serializability in DBMS
Difference between BFS and DFS
Class method vs Static method in Python
Differences between TCP and UDP
Difference between var, let and const keywords in JavaScript
Differences between IPv4 and IPv6
How to Access All Users in Linux Using Different Commands? - GeeksforGeeks

22 Jun, 2020
Linux allows multiple users with their own custom setting and configuration to work together on the same system, even at the same time. It can even allow a particular user to access several sessions from different locations in order to work on the system. Below is a list of different commands to access the list of users in Linux:
1. less command: Each local user’s information is stored in the “/etc/passwd/” file, where each line in the file represents login information for one user. less command extracts user information from that file.
Syntax:
$less /etc/passwd

Example:
Each line above has seven fields separated by colons which conatins the following information:
UsernameEncrypted PasswordUser ID number(UID)User group ID number(GID)Full name of the user(GECOS)user home directory andLogin shell respectively.
Username
Encrypted Password
User ID number(UID)
User group ID number(GID)
Full name of the user(GECOS)
user home directory and
Login shell respectively.
2. getent command: This command fetches user information from database configured in /etc/nsswitch.conf. file which also includes passwd database.
Syntax:
$getent passwd

Example:
3. awk or cut command: If only username is what you want, use awk or cut commands to print only the field containing the username.
Syntax:
$awk -F: '{print$1}' /etc/passwd

$cut -d: -f1 /etc/passwd

 
$getent passwd | awk -F: '{print$1}'

$getent passwd | cut -d: -f1

Example:
4. compgen command: This command also displays the name of all the users without any additional information.
Syntax:
$compgen -u

Example:
Note: One can use compgen -c command to list all commands available if he/she is not the admin on a Linux system and don’t have the sudo access.
5. who command: This will print the info of the currently logged in user.
Syntax:
$who

Example:
6. wc Command: This command will get the total number of users on a particular linux system.
Syntax:
$getent passwd |wc -l

Example:
nidhi_biet
linux-command
Picked
Linux-Unix
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
SED command in Linux | Set 2
mv command in Linux with examples
Docker - COPY Instruction
chown command in Linux with Examples
How to Find the Wi-Fi Password Using CMD in Windows?
Docker - COPY Instruction
Top Programming Languages for Android App Development
How to Run a Python Script using Docker?
Setting up the environment in Java
Aptitude - Squares & Cubes Online Quiz

Following quiz provides Multiple Choice Questions (MCQs) related to Squares & Cubes. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - √2500 +√961  = (?)2
A - 81
B - 3
C - 6561
D - 9
Let √(√2500+√961) =x2. Then
x2= √(50+31) = √81= 9. ∴ x = √9 = 3
Q 2 - √4375/√7 = ?
A - 24.75
B - 27.25
C - 25
D - 35
√4375/√7 = √4375/√7 = √625 = 25
Q 3 - (0.324*0.081*4.624)/(1.5625* 0.0289* 72.9* 64) = ?
A - 24
B - 2.4
C - 0.024
D - 0.24
Sum of decimel places being equal in numerator and denominator, we have
 Given Expression =   √324*81*4624/15625*289*729*64
= 18*9*68/125*17*27*8=3/125 =0.024
Q 4 - √9216+ √12544 =?
A - 196
B - 200
C - 208
D - 218
√9216+√12544 =(√(96 * 96)+ √(112 * 112))= 96 + 112 = 208
Q 5 - √0.04 =?
A - 0.002
B - 0.02
C - 0.2
D - none of these
√0.04  = √4/100 =2/10 = 0.2
Q 6 - √0.00004761 = ?
A - 0.00069
B - 0.0069
C - 0.0609
D - 0.069
√  0.00004761  =  √4761/100000000  =69/10000=  0.0069
Q 7 - Given that √13 = 3.605, √130 = 11.4 ,the value of√1.3 +√1300 +√0.013 is
A - 36.164
B - 36.304
C - 37.164
D - 37.04
√1.3+√1300+√0.013 = √13/10+√13*100+√13/1000
=√130/100+√13*100+√13/10000 =√130/10+10*√13+√130/100
= (11.4/10 +10* 3.605+ 11.4/100) =(1.14+36.05+0.114)=37.04
Q 8 - ( √3- 1/√3)2= ?
A - 1/3
B - 4/3
C - 7/3
D - 10/3
(√3-1/√3)2= (√3)2+(1/√3)2-2* √3*1/√3=  (3+1/3-2) =(1+1/3)=4/3
Q 9 - The value of 1/(√2+1)+1/(√3+√2)+1/(√4+√3)...+1/(√121+√120) is
A - √120
B - 12√2
C - 8
D - 10
given exp. =1/(√2+1)+1/(√3+√2)+1/(√4+√3)...+1/(√121+√120)
=1/(√2-1)* √2-1)/( √2-1)+1/(√3+√2)* √3-√2/√3-√2+1/(√4+√3)*( √4-√3)/( √4-√3)+?..+1/√121+√120*(√121-√120/√121-√120
= (√2-1)+( √3-√2)+( √4-√3)?..+( √121-√120) =(√121-1)
= (11-1) = 10.  ≤
Q 10 - √0.121 = ?
A - 0.11
B - 1.1
C - 0.347
D - 0.011
√0.121 =  √ 0.347 * 0.347 = 0.347

    87 Lectures 
     22.5 hours 

 Programming Line
 Print
 Add Notes
 Bookmark this page