code-rag-bench/online-tutorials huggingface dataset:
Print a 2 D Array or Matrix in C#

First, set a two-dimensional array.
int[,] arr = new int[10, 10];
Now, get the elements from the user −
for (i = 0; i < m; i++) {
   for (j = 0; j < n; j++) {
      arr[i, j] = Convert.ToInt16(Console.ReadLine());
   }
}
Let us see the complete example to display the matrix.
 Live Demo
using System;
using System.Linq;

class Demo {

   static void Main() {

      int m, n, i, j;

      // rows and columns of the matrix+
      m = 2;
      n = 2;

      int[,] arr = new int[10, 10];

      Console.Write("Enter elements of the Matrix: ");
      for (i = 0; i < m; i++) {
         for (j = 0; j < n; j++) {
            arr[i, j] = Convert.ToInt16(Console.ReadLine());
         }
      }

      Console.WriteLine("Printing Matrix: ");
      for (i = 0; i < m; i++) {
         for (j = 0; j < n; j++) {
            Console.Write(arr[i, j] + "\t");
         }
         Console.WriteLine();
      }

      Console.ReadLine();
   }
}
The following is the output.
Enter elements of the Matrix: 5 10 12 15
Printing Matrix:
510
1215
Python os.chdir() method

01 Nov, 2021
OS module in Python provides functions for interacting with the operating system. OS, comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality. os.chdir() method in Python used to change the current working directory to specified path. It takes only a single argument as new directory path. 
Syntax: os.chdir(path)Parameters: path: A complete path of directory to be changed to new directory path.Returns: Doesn’t return any value
Code #1: Use chdir() to change the directory
Python3
# Python3 program to change the# directory of file using os.chdir() method # import os libraryimport os # change the current directory# to specified directoryos.chdir(r"C:\Users\Gfg\Desktop\geeks") print("Directory changed")
Output:  
Directory changed
Code #2: Use of os.getcwd() To know the current working directory of the file, getcwd() method can be used. After changing the path, one can verify the path of current working directory using this method. 
Python3
# import os moduleimport os # change the current working directory# to specified pathos.chdir('c:\\gfg_dir') # verify the path using getcwd()cwd = os.getcwd() # print the current directoryprint("Current working directory is:", cwd)
Output:  
Current working directory is: c:\\gfg_dir
  Code #3: Handling the errors while changing the directory 
Python3
# importing all necessary librariesimport sys, os # initial directorycwd = os.getcwd() # some non existing directoryfd = 'false_dir / temp' # trying to insert to false directorytry:    os.chdir(fd)    print("Inserting inside-", os.getcwd())     # Caching the exception   except:    print("Something wrong with specified\          directory. Exception- ", sys.exc_info())           # handling with finally         finally:    print("Restoring the path")    os.chdir(cwd)    print("Current directory is-", os.getcwd())
Output: 
Inserting inside- c:\gfg_dir\gfg
Something wrong with specified directory. Exception- 
Restoring the path
Current directory is- c:\gfg_dir\gfg
sumitgumber28
prachisoda1234
python-modules
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Python String | replace()
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Iterate over a list in Python
Angular ngx Bootstrap Tooltip Component - GeeksforGeeks

02 Sep, 2021
Angular ngx bootstrap is a bootstrap framework used with angular to create components with great styling and this framework is very easy to use and is used to make responsive websites.In this article, we will see how to use Tooltip in angular ngx bootstrap.
Installation syntax:
npm install ngx-bootstrap --save
Approach:
First, install the angular ngx bootstrap using the above-mentioned command.
Add the following script in index.html<link href=”https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css” rel=”stylesheet”>
<link href=”https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css” rel=”stylesheet”>
Import tooltip component in module.ts
In app.component.html make a tooltip component.
Serve the app using ng serve.
 
Example:
index.html
<!DOCTYPE html><html lang="en">  <head>    <meta charset="utf-8" />    <title>Demo</title>    <base href="/" />    <meta name="viewport" content=        "width=device-width, initial-scale=1" />    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"        rel="stylesheet" />      <link rel="icon" type="image/x-icon" href="favicon.ico" />    <link rel="preconnect" href="https://fonts.gstatic.com" />    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap"        rel="stylesheet" />    <link href="https://fonts.googleapis.com/icon?family=Material+Icons"    rel="stylesheet" /></head>  <body class="mat-typography">    <app-root></app-root></body>  </html>
app.component.html
<button id='gfg' type="button"     class="btn btn-success"    tooltip="Tooltip component in Angular ngx bootstrap.">    GeeksforGeeks</button>
app.module.ts
import { NgModule } from '@angular/core';  // Importing forms moduleimport { FormsModule, ReactiveFormsModule  }from '@angular/forms';import { BrowserModule }from '@angular/platform-browser';import { BrowserAnimationsModule } from '@angular/platform-browser/animations';import { TooltipModule} from 'ngx-bootstrap/tooltip';  import { AppComponent }  from './app.component';   @NgModule({  bootstrap: [    AppComponent  ],  declarations: [    AppComponent  ],  imports: [    FormsModule,    BrowserModule,    BrowserAnimationsModule,    ReactiveFormsModule,    TooltipModule.forRoot()  ]})export class AppModule { }
app.component.css
#gfg {    margin: 10px;}
app.component.ts
import { Component } from '@angular/core';  @Component({    selector: 'app-root',    templateUrl: './app.component.html',    styleUrls: ['./app.component.css']})export class AppComponent {}
Output:
ysachin2314
Angular-ngx-bootstrap
AngularJS
Bootstrap
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Angular PrimeNG Calendar Component
Angular PrimeNG Messages Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
How to change navigation bar color in Bootstrap ?
Form validation using jQuery
How to pass data into a bootstrap modal?
How to align navbar items to the right in Bootstrap 4 ?
How to Show Images on Click using HTML ?
How to find Min/Max numbers in a java array?

You can find the minimum and maximum values of an array using for loops −
Live Demo
public class MinAndMax {
   public int max(int [] array) {
      int max = 0;
     
      for(int i=0; i<array.length; i++ ) {
         if(array[i]>max) {
            max = array[i];
         }
      }
      return max;
   }
   public int min(int [] array) {
      int min = array[0];
     
      for(int i=0; i<array.length; i++ ) {
         if(array[i]<min) {
            min = array[i];
         }
      }
      return min;
   }
   public static void main(String args[]) {
      int[] myArray = {23, 92, 56, 39, 93};
      MinAndMax m = new MinAndMax();
      System.out.println("Maximum value in the array is::"+m.max(myArray));
      System.out.println("Minimum value in the array is::"+m.min(myArray));
   }
}
Maximum value in the array is ::93
Minimum value in the array is ::23
8085 program for hexadecimal counter - GeeksforGeeks

12 Dec, 2018
Write a program to count continuously in hexadecimal from FFH to 00H in a system with clock frequency 0.5 microseconds. Use register C to set up a delay of 1ms between each count and display output at one of the output ports.
Problem Analysis:
The hexadecimal counter is set by loading a register with starting number and decrementing it till zero is reached and then again decrementing it to will produce -1, which is two’s complement of FFH. Hence, the register again reaches FFH.The 1ms time delay is set up by the procedure shown in flowchart-The register is loaded with appropriate number such that the execution of above loop produces a time delay of 1ms.
The hexadecimal counter is set by loading a register with starting number and decrementing it till zero is reached and then again decrementing it to will produce -1, which is two’s complement of FFH. Hence, the register again reaches FFH.
The 1ms time delay is set up by the procedure shown in flowchart-The register is loaded with appropriate number such that the execution of above loop produces a time delay of 1ms.
Program:
The C register is the time delay register which is loaded by a value COUNT to produce a time delay of 1ms.To find the value of COUNT we do-
TD = TL + TO
where- TD = Time Delay
TL = Time delay inside loop
TO = Time delay outside loop

The delay loop includes two instructions- DCR C (4 T-states) and JNZ (10 T-states)So TL = 14*Clock period*COUNT=> 14*(0.5*10-6)*COUNT=> (7*10-6)*COUNT
Delay outside the loop includes-DCR B : 4TMVI C, COUNT : 7TMOV A, B : 4TOUTPORT : 10TJMP : 10TTotal : 35T
TO= 35*Clock period => 17.5 microseconds
So, 1ms= (17.5+ 7*COUNT)microsecond
Therefore, COUNT=(140)10
Kartikaybhutani
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
Architecture of 8085 microprocessor
Computer Organization and Architecture | Pipelining | Set 2 (Dependencies and Data Hazard)
Pin diagram of 8086 microprocessor
Direct Access Media (DMA) Controller in Computer Architecture
Memory mapped I/O and Isolated I/O
General purpose registers in 8086 microprocessor
Difference between SRAM and DRAM
Registers of 8085 microprocessor
8085 program to multiply two 8 bit numbers
8085 program to add two 16 bit numbers
Create Table Using Tkinter

24 Feb, 2022
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using Tkinter is an easy task.Note: For more information, refer to Python GUI – tkinter 
A table is useful to display data in the form of rows and columns. Unfortunately, Tkinter does not provide a Table widget to create a table. But we can create a table using alternate methods. For example, we can make a table by repeatedly displaying entry widgets in the form of rows and columns.To create a table with five rows and four columns we can use two for loops as:  
for i in range(5):
    for j in range(4):
Inside these loops, we have to create an Entry widget by creating an object of Entry class, as:  
e = Entry(root, width=20, fg='blue', font=('Arial', 16, 'bold')
Now, we need logic to place this Entry widget in rows and columns. This can be done by using grid() method to which we can pass row and column positions, as:  
# here i and j indicate 
# row and column positions
e.grid(row=i, column=j)
We can insert data into the Entry widget using insert() method, as:  
e.insert(END, data)
Here, ‘END’ indicates that the data continuous to append at the end of previous data in the Entry widget.This is the logic that is used in the program given below using the data that is coming from a list. We have taken a list containing 5 tuples and each tuple contains four values which indicate student id, name, city and age.Hence, we will have a table with 5 rows and 4 columns in each row. This program can also be applied on data coming from a database to display the entire data in the form of a table.Source Code:  
Python3
# Python program to create a table  from tkinter import *  class Table:         def __init__(self,root):                 # code for creating table        for i in range(total_rows):            for j in range(total_columns):                                 self.e = Entry(root, width=20, fg='blue',                               font=('Arial',16,'bold'))                                 self.e.grid(row=i, column=j)                self.e.insert(END, lst[i][j]) # take the datalst = [(1,'Raj','Mumbai',19),       (2,'Aaryan','Pune',18),       (3,'Vaishnavi','Mumbai',20),       (4,'Rachna','Mumbai',21),       (5,'Shubham','Delhi',21)]  # find total number of rows and# columns in listtotal_rows = len(lst)total_columns = len(lst[0])  # create root windowroot = Tk()t = Table(root)root.mainloop()
Output:  
 
geeky01adarsh
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Convert integer to string in Python
Python | sympy.Matrix.row_del() method

12 Jun, 2019
With the help of sympy.Matrix.row_del() method, we can delete the rows of the matrix.
Syntax : sympy.Matrix().row_del()Return : Return a new matrix.
Example #1 :
# Import all the methods from sympyfrom sympy import *  # use the row_del() method for matrixgfg_val = Matrix([[1, 2], [2, 1]]).col_row(1)  print(gfg_val)
Output :
Matrix([1, 2])
Example #2 :
from sympy import *  # use the row_del() method for matrixgfg_val = Matrix([[1, 2], [2, 3], [23, 45]]).row_del(0)  print(gfg_val)
Output :
Matrix([[2, 3], [23, 45]])
SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Create a directory in Python
Minimum of two numbers in Python

17 May, 2020
Given two numbers, write a Python code to find the Minimum of these two numbers.
Examples:
Input: a = 2, b = 4
Output: 2

Input: a = -1, b = -4
Output: -4

Method #1: This is the naive approach where we will compare the numbers using if-else statement and will print the output accordingly.
Example:
# Python program to find the# minimum of two numbers    def minimum(a, b):          if a <= b:        return a    else:        return b      # Driver codea = 2b = 4print(minimum(a, b))
Output:
2
Method #2: Using min() function
This function is used to find the minimum of the values passed as its arguments.
Example:
# Python program to find the# minimum of two numbers    a = 2b = 4  minimum = min(a, b)print(minimum)
Output:
2
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Python | Check if a given object is list or not

19 Mar, 2019
Given an object, the task is to check whether the object is list or not.
Method #1: Using isinstance
# Python code to demonstrate# check whether the object # is a list or not  # initialisation listini_list1 = [1, 2, 3, 4, 5]ini_list2 = '12345'  # code to check whether# object is a list or notif isinstance(ini_list1, list):  print("your object is a list !")else:    print("your object is not a list")    if isinstance(ini_list2, list):    print("your object is a list")else:    print("your object is not a list")
your object is a list !
your object is not a list

 Method #2: Using type(x)
# Python code to demonstrate# check whether object # is a list or not  # initialisation listini_list1 = [1, 2, 3, 4, 5]ini_list2 = (12, 22, 33)  # code to check whether# object is a list or notif type(ini_list1) is list:    print("your object is a list")else:    print("your object is not a list")  if type(ini_list2) is list:    print("your object is a list")else:    print("your object is not a list")
your object is a list
your object is not a list

Python list-programs
python-list
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
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
How to Display Changed Browser URL Without Reloading Through alert using JavaScript ?

30 Jan, 2020
To change the URL in the browser without loading the new page, we can use history.pushState() method and replaceState() method from JavaScript. To display the browser-URL before changing the URL we will use window.location.href in the alert() function and will use again after changing the browsers-URL.
Note: The history.pushState() method combines HTML 5 History and JavaScript pushState() method.
Syntax:
alert(" Message:" + window.location.hrf);
Below examples illustrate the above approach:
Example 1:
<!DOCTYPE html><html>  <head>    <script type="text/javascript">        function geeks() {            alert("The current URL of this"            + " page is: " + window.location.href);        }          function change_url() {            window.history.pushState("stateObj",                 "new page", "changedURL.html");                          alert("The URL of this page is: "                    + window.location.href);        }    </script></head>  <body onload="geeks()">    <a href="javascript:change_url()">        Click to change url    </a></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <script type="text/javascript">        function geeks() {            alert("The current URL of this "            + "page is: " + window.location.href);        }          function change_url() {            window.history.replaceState("stateObj",                    "new page", "changedURL.html");                          alert("The URL of this page is: "                    + window.location.href);        }    </script></head>  <body onload="geeks()">    <a href="javascript:change_url()">        Click to change url    </a></body>  </html>
Output:
JavaScript-Misc
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyQt5 QColorDialog – Changing Font

24 Jun, 2020
In this article we will see how we can change the font of QColorDialog. Font is the style i.e properties of the text present in the color dialog.
Note : Increasing size of font will increase the size of the dialog box although dialog size is fixed
In order to do this we use setFont method with the QColorDialog object
Syntax : dialog.setFont(font)
Argument : It takes QFont object as argument
Return : It returns None
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 500, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()        # method for components    def UiComponents(self):          # creating a QColorDialog object        dialog = QColorDialog(self)          # setting custom colors        dialog.setCustomColor(1, Qt.red)        dialog.setCustomColor(2, Qt.green)        dialog.setCustomColor(3, Qt.yellow)        dialog.setCustomColor(4, Qt.blue)          # font        font = QFont('Times', 12)          # setting font to the dialog        dialog.setFont(font)          # creating label        label = QLabel("Geeks for Geeks", self)          label.setAlignment(Qt.AlignCenter)          # making label multi line        label.setWordWrap(True)          # setting stylesheet of the label        label.setStyleSheet("QLabel"                            "{"                            "border : 5px solid black;"                            "}")            # getting the custom color        color = dialog.customColor(4)          # setting graphic effect to the label        graphic = QGraphicsColorizeEffect(self)          # setting color to the graphic        graphic.setColor(color)          # setting graphic to the label        label.setGraphicsEffect(graphic)          layout = dialog.layout()          layout.addWidget(label)          dialog.setLayout(layout)            dialog.exec_()          self.deleteLater()      # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-QColorDialog
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Create a directory in Python
numpy string operations | strip() function

17 Jan, 2019
numpy.core.defchararray.strip(arr, chars=None) is another function for doing string operations in numpy. It returns a copy with the leading and trailing characters removed for each element in arr.
Parameters:arr : array_like of str or unicode.char : [str or unicode, optional] the set of characters to be removed. If omitted or None, it removes whitespace. The chars argument is not a prefix or suffix; it is all combinations of its values which we want to strip.
Returns : [ndarray] Output array of str or unicode, depending on input type.
Code #1 :
# Python program explaining# numpy.char.strip() method   import numpy as geek  # input arrays  in_arr = geek.array(['Sun', '  Moon  ', 'Star'])print ("Input array : ", in_arr)   out_arr = geek.char.strip(in_arr)  # whitespace removed from arr[1] # as we have set chars = Noneprint ("Output array: ", out_arr) 
Input array :  ['Sun' ' Moon ' 'Star']
Output array:  ['Sun' 'Moon' 'Star']

 Code #2 :
# Python program explaining# numpy.char.strip() method   import numpy as geek  # input arrays  in_arr = geek.array(['Sun', '  Moon  ', 'Star'])print ("Input array : ", in_arr)   out_arr = geek.char.strip(in_arr, chars ='Sun')  # 'Sun' removed from arr[0] as we have set chars = Sunprint ("Output array: ", out_arr) 
Input array :  ['Sun' ' Moon ' 'Star']
Output array:  ['' ' Moon ' 'tar']

 Code #3 :
# Python program explaining# numpy.char.strip() method   import numpy as geek  # input arrays in_arr = geek.array([ 'Geeks', 'For', 'Geeks'] )print ("Input array : ", in_arr)   out_arr = geek.char.strip(in_arr, chars ='G')  #'G' removed from arr[0] and arr[2]# as we have set chars ='G'print ("Output array: ", out_arr) 
Input array :  ['Geeks' 'For' 'Geeks']
Output array:  ['eeks' 'For' 'eeks']

Python numpy-String Operation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
What is stdClass in PHP?

01 Aug, 2021
The stdClass is the empty class in PHP which is used to cast other types to object. It is similar to Java or Python object. The stdClass is not the base class of the objects. If an object is converted to object, it is not modified. But, if object type is converted/type-casted an instance of stdClass is created, if it is not NULL. If it is NULL, the new instance will be empty.
Uses:
The stdClass directly access the members by calling them.
It is useful in dynamic object.
It is used to set dynamic properties etc.
Program 1: Using array to storing data
<?php      // Array definition of an employee$employee_detail_array = array(    "name" => "John Doe",    "position" => "Software Engineer",    "address" => "53, nth street, city",    "status" => "best");  // Display the array contentprint_r($employee_detail_array);?>
Array
(
    [name] => John Doe
    [position] => Software Engineer
    [address] => 53, nth street, city
    [status] => best
)

Program 2: Using stdClass instead of array to store employee details (dynamic properties)
<?php      // Object-styled definition of an employee$employee_object = new stdClass;$employee_object->name = "John Doe";$employee_object->position = "Software Engineer";$employee_object->address = "53, nth street, city";$employee_object->status = "Best";      // Display the employee contentsprint_r($employee_object);?>
stdClass Object
(
    [name] => John Doe
    [position] => Software Engineer
    [address] => 53, nth street, city
    [status] => Best
)

Note: The type casting of array into object and object to array is possible.
Program 3: Converting array into object
<?php  // Aarray definition of an employee$employee_detail_array = array(    "name" => "John Doe",    "position" => "Software Engineer",    "address" => "53, nth street, city",    "status" => "best");  // type casting from array to object$employee = (object) $employee_detail_array;      print_r($employee);?>
stdClass Object
(
    [name] => John Doe
    [position] => Software Engineer
    [address] => 53, nth street, city
    [status] => best
)

Program 4: Converting object properties into array
<?php      // Object-styled definition of an employee$employee_object = new stdClass;$employee_object->name = "John Doe";$employee_object->position = "Software Engineer";$employee_object->address = "53, nth street, city";$employee_object->status = "Best";  // The object is converted into array // using type casting$employee_array = (array) $employee_object;  // Display the result in arrayprint_r($employee_array);?>
Array
(
    [name] => John Doe
    [position] => Software Engineer
    [address] => 53, nth street, city
    [status] => Best
)

PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.
Picked
PHP
PHP Programs
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Index.unique()

24 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Index.unique() function return unique values in the index. Uniques are returned in order of appearance, this does NOT sort.
Syntax: Index.unique(level=None)
Parameters :level : Only return values from specified level (for MultiIndex)
Returns : Index without duplicates
Example #1: Use Index.unique() function to return unique values in the index.
# importing pandas as pdimport pandas as pd  # Creating the indexidx = pd.Index(['Harry', 'Mike', 'Arther', 'Nick',                'Harry', 'Arther'], name ='Student')  # Print the Indexprint(idx)
Output :
Let’s find all the unique values in the Index.
# find unique values in the indexidx.unique()
Output :The function has returned a new index having all the unique values of the original index. Example #2: Use Index.unique() function to find the unique values in the index
# importing pandas as pdimport pandas as pd  # Creating the indexidx = pd.Index([21, 10, 30, 40, 50, 10, 50])  # Print the Indexprint(idx)
Output :
Let’s find all the unique values in the index
# for finding the unique values in the indexidx.unique()
Output :The function has returned a new index that contains all of the unique values in the original index.
Python pandas-indexing
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
if-else statement in java

An if statement can be followed by an optional else statement, which executes when the Boolean expression is false.
Following is the syntax of an if...else statement −
if(Boolean_expression) {
   // Executes when the Boolean expression is true
}else {
   // Executes when the Boolean expression is false
}

If the boolean expression evaluates to true, then the if block of code will be executed, otherwise else block of code will be executed.
public class Test {

   public static void main(String args[]) {
      int x = 30;

      if( x < 20 ) {
         System.out.print("This is if statement");
      }else {
         System.out.print("This is else statement");
      }
   }
}
This will produce the following result −
This is else statement

An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement.
When using if, else if, else statements there are a few points to keep in mind.
An if can have zero or one else's and it must come after any else if's.
An if can have zero or one else's and it must come after any else if's.
An if can have zero to many else if's and they must come before the else.
An if can have zero to many else if's and they must come before the else.
Once an else if succeeds, none of the remaining else if's or else's will be tested.
Once an else if succeeds, none of the remaining else if's or else's will be tested.
Following is the syntax of an if...else statement −
if(Boolean_expression 1) {
   // Executes when the Boolean expression 1 is true
}else if(Boolean_expression 2) {
   // Executes when the Boolean expression 2 is true
}else if(Boolean_expression 3) {
   // Executes when the Boolean expression 3 is true
}else {
   // Executes when the none of the above condition is true.
}

public class Test {

   public static void main(String args[]) {
      int x = 30;

      if( x == 10 ) {
         System.out.print("Value of X is 10");
      }else if( x == 20 ) {
         System.out.print("Value of X is 20");
      }else if( x == 30 ) {
         System.out.print("Value of X is 30");
      }else {
         System.out.print("This is else statement");
      }
   }
}
This will produce the following result −
Value of X is 30
Decimal Struct in C#

15 Feb, 2019
In C#, Decimal Struct class is used to represent a decimal floating-point number. The range of decimal numbers is +79,228,162,514,264,337,593,543,950,335 to -79,228,162,514,264,337,593,543,950,335. Due to its wide range, it is generally used for financial calculations which required large numbers of significant integral and fractional digits and no round-off errors. You can also perform the mathematical operations on Decimal type like addition, subtraction, division, multiplication, etc.
Example:
// C# program to illustrate the// use of MaxValue and MinValue fieldusing System;  public class GFG {      // Main method    static public void Main()    {          // Display the Minimum and Maximum values        Console.WriteLine("Display Maximum value "+               "of Decimal: {0}", Decimal.MaxValue);          Console.WriteLine("Display Minimum value of "+                    "Decimal: {0}", Decimal.MinValue);    }}
Display Maximum value of Decimal: 79228162514264337593543950335
Display Minimum value of Decimal: -79228162514264337593543950335

Example:
// C# program to illustrate the// use of Add(Decimal, Decimal)// methodusing System;  class GFG {      // Main method    static public void Main()    {          // Addition of two Decimal values        // Using Add() method        Decimal val1 = 349;        Decimal val2 = 590;        Decimal result;        result = Decimal.Add(val1, val2);          // Display the result        Console.WriteLine("Addition is: {0}", result);    }}
Addition is: 939

Example:
// C# program to illustrate the// use of Decrement and Increment// operatorusing System;  class GFG {      static public void Main()    {        Decimal myval1 = 1000;        Decimal myval2 = 10000;          // Using Decrement operator we decrease myval1 by 1        Console.WriteLine("My value 1 is: {0}", myval1);        Console.WriteLine("Decrease myval1 by 1:{0}", --myval1);        Console.WriteLine();          // Using Increment operator we increase myval2 by 1        Console.WriteLine("My value 2 is: {0}", myval2);        Console.WriteLine("Increase myval2 by 1:{0}", ++myval2);    }}
My value 1 is: 1000
Decrease myval1 by 1:999

My value 2 is: 10000
Increase myval2 by 1:10001

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.decimal?view=netframework-4.7.2
CSharp-Decimal-Struct
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Multiple inheritance using interfaces
Introduction to .NET Framework
Differences Between .NET Core and .NET Framework
C# | Delegates
C# | String.IndexOf( ) Method | Set - 1
C# | Replace() Method
C# | Arrays
Extension Method in C#
C# | List Class
Multi-dimensional lists in Python

09 Dec, 2018
There can be more than one additional dimension to lists in Python. Keeping in mind that a list can hold other lists, that basic principle can be applied over and over. Multi-dimensional lists are the lists within lists. Usually, a dictionary will be the better choice rather than a multi-dimensional list in Python.
Approach 1:
# Python program to demonstrate printing# of complete multidimensional lista = [[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20]]print(a)
[[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20]]

Approach 2: Accessing with the help of loop.
# Python program to demonstrate printing# of complete multidimensional list row# by row.a = [[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20]]for record in a:    print(record)
[2, 4, 6, 8, 10]
[3, 6, 9, 12, 15]
[4, 8, 12, 16, 20]

Approach 3: Accessing using square brackets.Example:
# Python program to demonstrate that we# can access multidimensional list using# square bracketsa = [ [2, 4, 6, 8 ],     [ 1, 3, 5, 7 ],     [ 8, 6, 4, 2 ],     [ 7, 5, 3, 1 ] ]           for i in range(len(a)) :     for j in range(len(a[i])) :         print(a[i][j], end=" ")    print()    
2 4 6 8 
1 3 5 7 
8 6 4 2 
7 5 3 1

# Python program to create a m x n matrix# with all 0sm = 4n = 5  a = [[0 for x in range(n)] for x in range(m)]print(a)
[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]

1. append(): Adds an element at the end of the list.Example:
# Adding a sublist  a = [[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20]]a.append([5, 10, 15, 20, 25])print(a)
[[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20], [5, 10, 15, 20, 25]]

2. extend(): Add the elements of a list (or any iterable), to the end of the current list.
# Extending a sublist   a = [[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20]]a[0].extend([12, 14, 16, 18])print(a)
[[2, 4, 6, 8, 10, 12, 14, 16, 18], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20]]

3. reverse(): Reverses the order of the list.
# Reversing a sublist   a = [[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20]]a[2].reverse()print(a)
[[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [20, 16, 12, 8, 4]]

Picked
Python list-programs
python-list
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Convert integer to string in Python
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
p5.js | mouseWheel() Function

29 Jan, 2020
The mouseWheel() function is invoked whenever a mouse or touchpad scroll causes a vertical mouse wheel event. This event can be accessed to determine the properties of the scroll. The delta property returns the amount of the scroll that took place. This value can be positive or negative depending on the direction of the scroll.
The callback function may have to end with the “return false;” statement to prevent any default behaviors that may be associated with scrolling on different browsers.
Syntax:
mouseWheel( event )
Parameters: This function accepts a single parameter as mentioned above and described below:
event: This is an optional WheelEvent callback argument, that can be used to access scroll details.
Below examples illustrate the mouseWheel() function in p5.js:
Example 1: Using the scroll event to change the color when scrolled
let red = 0;   function setup() {    createCanvas(750, 300);    textSize(24);}   function draw() {    clear();       // Apply fill based on the    // red component    fill(red, 0, 0)       text("Scroll the mouse wheel to "            + "change the red component"            + " of the color", 20, 20);          circle(150, 150, 200);}   function mouseWheel(event) {        // Change the red value according    // to the scroll delta value  red += event.delta;}
Output:
Example 2: Displaying the scroll properties
let scrollDelta = 0;   function setup() {    createCanvas(500, 200);    textSize(24);    text("Scroll the mouse to see the"        + " scroll details.", 10, 20);}   function mouseWheel(event) {    scrollDelta = event.delta;       clear();    deltaString = "Current mouse delta is: "                    + scrollDelta;        text(deltaString, 10, 20);       if (scrollDelta > 0) {        text("You are scrolling downwards", 10, 40);    }     else {        text("You are scrolling upwards", 10, 40);    }}
Output:
Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/mouseWheel
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
How to append HTML code to a div using JavaScript ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
pandas.merge_asof() function in Python

14 Aug, 2020
This method is used to perform an asof merge. This is similar to a left-join except that we match on nearest key rather than equal keys. Both DataFrames must be sorted by the key.
Syntax : pandas.merge_asof(left, right, on=None, left_on=None, right_on=None, left_index=False, right_index=False, by=None, left_by=None, right_by=None, suffixes=(‘_x’, ‘_y’), tolerance=None, allow_exact_matches=True, direction=’backward’, )
Parameters :
left, right : DataFrame
on : label, Field name to join on. Must be found in both DataFrames.
left_on : label, Field name to join on in left DataFrame.
right_on : label, Field name to join on in right DataFrame.
left_index : boolean, Use the index of the left DataFrame as the join key.
right_index : boolean, Use the index of the right DataFrame as the join key.
Below is the implementation of the above method with some examples :
Example 1 :
Python3
# importing packageimport pandas  # creating dataleft = pandas.DataFrame({'a': [1, 5, 10],                          'left_val': ['a', 'b', 'c']})  right = pandas.DataFrame({'a': [1, 2, 3, 6, 7],                          'right_val': [1, 2, 3, 6, 7]})  # view dataprint(left)print(right)  # applying merge_asof on dataprint(pandas.merge_asof(left, right, on='a'))print(pandas.merge_asof(left, right, on='a',                         allow_exact_matches=False))
Output:
Example 2 :
Python3
# importing packageimport pandas  # creating dataleft = pandas.DataFrame({'a': [1, 5, 10],                          'left_val': ['a', 'b', 'c']})  right = pandas.DataFrame({'a': [1, 2, 3, 6, 7],                          'right_val': [1, 2, 3, 6, 7]})  # view dataprint(left)print(right)  # applying merge_asof on dataprint(pandas.merge_asof(left, right, on='a',                         direction='forward'))print(pandas.merge_asof(left, right, on='a',                        direction='nearest'))
Output :
Example 3 :
Python3
# importing packageimport pandas  # creating dataleft = pandas.DataFrame({'left_val': ['a', 'b', 'c']},                         index=[1, 5, 10])  right = pandas.DataFrame({'right_val': [1, 2, 3, 6, 7]},                          index=[1, 2, 3, 6, 7])  # view dataprint(left)print(right)  # applying merge_asof on dataprint(pandas.merge_asof(left, right, left_index=True,                         right_index=True))
Output:
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to draw a dashed line on a Tkinter canvas?

To draw a dashed line on a Tkinter canvas, we can use the dash parameter of create_line() method.
Import the tkinter library and create an instance of tkinter frame.
Import the tkinter library and create an instance of tkinter frame.
Set the size of the frame using geometry method.
Set the size of the frame using geometry method.
Create a Canvas widget and set its height and width.
Create a Canvas widget and set its height and width.
Next, use the create_line function and pass the coordinates of the line (x1, y1) and (x2, y2).
Next, use the create_line function and pass the coordinates of the line (x1, y1) and (x2, y2).
To get a dashed line, use the dash parameter dash=(5,1) for 5px dash followed by 1px space.
To get a dashed line, use the dash parameter dash=(5,1) for 5px dash followed by 1px space.
You can set the color and width of the dashed lines using the fill and width parameters.
You can set the color and width of the dashed lines using the fill and width parameters.
Finally, run the mainloop of the application window.
Finally, run the mainloop of the application window.
# Import the library
from tkinter import *

# Create an instance of window
win = Tk()

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

C1 = Canvas(win, width=600, height=400)

# Coordinates of the line
coordinates = 100,150,550,150

# Draw a dashed vertical line, 5px dash and 1px space
C1.create_line(coordinates, dash=(5,1))
C1.pack()

win.mainloop()
It will produce the following output −
Note: Dash patterns are system-dependent. You may get different outputs on Windows and Linux based systems. Windows doesn't support the same dash patterns as Linux.
Convert an Object into a Matrix in R Programming - as.matrix() Function - GeeksforGeeks

27 Oct, 2021
as.matrix() function in R Programming Language is used to convert an object into a Matrix.
Syntax: as.matrix(x)
Parameters: 
x: Object to be converted
R
# R program to convert an object to matrix # Creating a vectorx <- c(1:9) # Calling as.matrix() Functionas.matrix(x)
Output: 
      [, 1]
 [1, ]    1
 [2, ]    2
 [3, ]    3
 [4, ]    4
 [5, ]    5
 [6, ]    6
 [7, ]    7
 [8, ]    8
 [9, ]    9
R
# R program to convert an object to matrix # Calling pre-defined data setBOD # Calling as.matrix() Functionas.matrix(BOD)
Output: 
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
     Time demand
[1, ]    1    8.3
[2, ]    2   10.3
[3, ]    3   19.0
[4, ]    4   16.0
[5, ]    5   15.6
[6, ]    7   19.8
kumar_satyam
R Matrix-Function
R Object-Function
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
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
How to import an Excel File into R ?
Replace Specific Characters in String in R
R - if statement
Time Series Analysis in R
Raw string literal in C++ program

In this article, we will be discussing the raw string literal in C++, its meaning, and examples.
There are escape characters in C++ like “\n” or “\t”. When we try to print the escape characters, it will not display on the output. To show the escape characters on the output screen we use a raw string literal by using R”(String with escape characters)”. After using R in the front of the string the escape character will be displayed on the output.
Let’s understand this with the help of an example
 Live Demo
#include <iostream>
using namespace std;
int main(){
   string str = "tutorials\npoint\n" ;
   // A Raw string
   string str_R = R"(tutorials\npoint\n)";
   cout <<"String is: "<<str << endl;
   cout <<"Raw String is: "<<str_R;
   return 0;
}
If we run the above code it will generate the following output −
String is: tutorials
point
Raw String is: tutorials\npoint\n
 Live Demo
#include <iostream>
using namespace std;
int main(){
   string str = "tutorials\ttoint\t" ;
   // A Raw string
   string str_R = R"(tutorials\tpoint\t)";
   cout <<"String is: "<<str << endl;
   cout <<"Raw String is: "<<str_R;
   return 0;
}
If we run the above code it will generate the following output −
String is: tutorials toint
Raw String is: tutorials\tpoint\t
SVG polygon Element - GeeksforGeeks

31 Mar, 2022
SVG stands for Scalable Vector Graphic. It can be used to make graphics and animations like in HTML canvas. The <polygon> element of SVG is used to make any type of polygon on the SVG and defines a closed shape consisting of a set of connected straight line segments.
Syntax:
<polygon  points="Pair of points required to draw the shape"
      stroke="stroke color"
      fill="fill color for colored closed shapes">
Attributes:
points: Pair of points required to draw the shape
pathLength: It tells the total length of the path.
Few examples are given below for a better understanding of the <polygon> SVG element.
Example 1:
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta name="viewport"         content="width=device-width,                 initial-scale=1.0">  <title>Document</title></head><body>  <svg width="400px" height="400px">  <!-- try different pairs and make different shapes-->    <polygon points="0, 100 100, 100 100, 100 100, -20000"              fill="green">  </svg></body></html>
Output:
Example 2:
<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <meta name="viewport"         content="width=device-width,                 initial-scale=1.0">  <title>Document</title></head><style>  svg{    background-color: black;  }</style><body>  <svg width="200px" height="200px">  <!-- try different pairs and make different shapes-->    <polygon points="100, 100 15, 205 150, 7 20, 0"              fill="green" stroke="yellow">  </svg></body></html>
Output:
Browsers supported: Below given are the browsers supported by this svg element.
Chrome
Edge
Opera
Internet explorer
Safari
Firefox
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-SVG
SVG-Element
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
HTML Cheat Sheet - A Basic Guide to HTML
Design a web page using HTML and CSS
Form validation using jQuery
Angular File Upload
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