code-rag-bench/online-tutorials huggingface dataset:
amixer command in Linux with Examples - GeeksforGeeks

15 Apr, 2019
amixer is a command-line mixer for ALSA(Advanced Linux Sound Architecture) sound-card driver. amixer can support multiple soundcards. amixer with no arguments will display the current mixer settings for the default soundcard as well as the device. This is a good way to see a list of the simple mixer controls that you can use.
Syntax:
amixer [-option] [command]
Commands and Options:
-h or –help : Displays help and then exits.
–info : Displays the info and then exits.
–scontols : Displays a complete list of simple controls and then exits.
–scontents : Shows a complete list of simple mixer controls and their contents as well.
set or sset : Sets the contents of the simple mixer.
get or sget : Shows the control contents of the simple mixer.
controls : Displays a complete list of the card controls.
contents : Displays a complete list of the card controls with their contents as well.
cset : Is used to set the card controls.
cget : It shows the card control contents. The identifier has the same syntax as for the cset command.
-c : Selects the card number that needs to be controlled.
-D : Selects the device name that needs to be controlled.
-s or –stdin : Read from stdin and execute each command sequentially.
-q : Does not display the result of the changes.
-R : Uses the raw value for evaluating the percentage representation which is also the default mode.
-M : Uses the mapped volume for evaluating the percentage representation like alsamixer, to be more natural for the human ear.
-v : Displays the version.
linux-command
Linux-misc-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Thread functions in C/C++
Array Basics in Shell Scripting | Set 1
scp command in Linux with Examples
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
mv command in Linux with examples
SED command in Linux | Set 2
Basic Operators in Shell Scripting
Start/Stop/Restart Services Using Systemctl in Linux
Animate CSS margin-left property

To implement animation on margin-left property in CSS, you can try to run the following code
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            background-color: gray;
            animation: myanim 3s infinite;
            color: white;
         }
         @keyframes myanim {
            30% {
               margin-left: 20px;
            }
         }
      </style>
   </head>
   <body>
      <h2>Heading One</h2>
      <div>
         This is demo text.
      </div>
   </body>
</html>
MS SQL Server - Assign Permissions

Permissions refer to the rules governing the levels of access that principals have to securables. You can grant, revoke and deny permissions in MS SQL Server.
To assign permissions either of the following two methods can be used.
Use <database name>
Grant <permission name> on <object name> to <username\principle>

To assign select permission to a user called 'TestUser' on object called 'TestTable' in 'TestDB' database, run the following query.
USE TestDB
GO
Grant select on TestTable to TestUser

Step 1 − Connect to instance and expand folders as shown in the following snapshot.
Step 2 − Right-click on TestUser and click Properties. The following screen appears.
Step 3 Click Search and select specific options. Click Object types, select tables and click browse. Select 'TestTable' and click OK. The following screen appears.
Step 4 Select checkbox for Grant column under Select permission and click OK as shown in the above snapshot.
Step 5 Select permission on 'TestTable' of TestDB database granted to 'TestUser'. Click OK.

    32 Lectures 
     2.5 hours 

 Pavan Lalwani

    18 Lectures 
     1.5 hours 

 Dr. Saatya Prasad

    102 Lectures 
     10 hours 

 Pavan Lalwani

    52 Lectures 
     4 hours 

 Pavan Lalwani

    239 Lectures 
     33 hours 

 Gowthami Swarna

    53 Lectures 
     5 hours 

 Akshay Magre
 Print
 Add Notes
 Bookmark this page
Bootstrap 4 .justify-content-*-around class

Use the justify-content-*-around class in Bootstrap to align flex items around on different screen sizes −
justify-content-sm-around : Justify content on small screen size
justify-content-md-around : Justify content on medium screen size
justify-content-lg-around : Justify content on large screen size
For an example, let us see how to align flex items for medium screen device (justify-content-md-around) −
<div class="d-flex justify-content-md-around bg-warning mb-5">
  <div class="p-2 bg-danger">RANK 1</div>
  <div class="p-2 bg-info">RANK 2</div>
  <div class="p-2 bg-secondary">RANK 3</div>
</div>
You can try to run the following code to implement the justify-content-* −
Live Demo
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Bootstrap Example</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  </head>

<body>

  <div class="container mt-3">
    <div class="d-flex justify-content-around bg-warning mb-5">
      <div class="p-2 bg-danger">RANK 1</div>
      <div class="p-2 bg-info">RANK 2</div>
      <div class="p-2 bg-secondary">RANK 3</div>
    </div>
    <div class="d-flex justify-content-sm-around bg-warning mb-5">
      <div class="p-2 bg-danger">RANK 1</div>
      <div class="p-2 bg-info">RANK 2</div>
      <div class="p-2 bg-secondary">RANK 3</div>
    </div>
    <div class="d-flex justify-content-md-around bg-warning mb-5">
      <div class="p-2 bg-danger">RANK 1</div>
      <div class="p-2 bg-info">RANK 2</div>
      <div class="p-2 bg-secondary">RANK 3</div>
    </div>
    <div class="d-flex justify-content-lg-around bg-warning mb-5">
      <div class="p-2 bg-danger">RANK 1</div>
      <div class="p-2 bg-info">RANK 2</div>
      <div class="p-2 bg-secondary">RANK 3</div>
    </div>
  </div>

</body>
</html>
Calendar in Python Program

Python has a built-in module called calendar to work with calendars. We are going to learn about the calendar module in this article.
The week in the calendar modules starts on Monday and ends on Sunday. The module calendar follows the Gregorian calendar. Let's see some useful methods of the calendar module.
If you have to get the calendar of the specific year, then create the instance of the class calendar.calendar(year) and print it. Let's see one example.
 Live Demo
# importing the calendar module
import calendar
# initializing the year
year = 2019
# printing the calendar
print(calendar.calendar(2019))
If you run the above code, you will get the following results.
We can get different types of outputs using the calendar.calendar(year) instance. Try to learn those methods using the dir().
If you have to get the calendar of the specific month, then use the method calendar.month(year, month_number) and print it. Let's see one example.
 Live Demo
# importing the calendar module
import calendar
# initializing the yearn and month number
year = 2000
month = 1
# getting the calendar of the month
print(calendar.month(year, month))
If you run the above program, you will get the following results.
January 2000
Mo Tu We Th Fr Sa Su
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
If you are having any trouble following the tutorial, comment below.
Multi-selection of Checkboxes on button click in jQuery?

For this, use jQuery() with id property. Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/4.7.0/css/font-awesome.min.css">
<style>
   .changeColor {
      color: red
   };
</style>
</head>
<body>
<input type="button" id="selectDemo" value="Want To Select All
Values" />
<table>
<tr>
<td>
<input type="checkbox" id="CheckBoxId1"
class="isSelected" /> Javascript
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="CheckBoxId2"
class="isSelected" /> MySQL
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="CheckBoxId3"
class="isSelected" /> MongoDB
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="CheckBoxId4"
class="isSelected" /> Python
</td>
</tr>
</table>
<script>
   jQuery("#selectDemo").click(function () {
      jQuery(this).toggleClass("changeColor");
      if (jQuery(this).hasClass("changeColor")) {
         jQuery(".isSelected").prop("checked", true);
         jQuery(this).val("Want To UnSelect All Values");
      } else {
         jQuery(this).removeClass("changeColor");
         jQuery(".isSelected").prop("checked", false);
         jQuery(this).val("Want To Select All Values");
      }
   });
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the
file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output −
Now I am going to click the above button “Want To Select All Values” −
Click the above button “Want To UnSelect All Values” −
How to rearrange MySQL columns?

To rearrange the MySQL columns, check the column arrangement with the help of show create command. The syntax is as follows −
show create table yourTableName;
The syntax to rearrange the MySQL columns is as follows −
alter table yourTableName change column yourColumnName yourColumnName dataType first
For the same purpose, you can use the after keyword. The syntax is as follows −
alter table yourTableName change column yourColumnName yourColumnName dataType after yourSpecificColumnName;
Let us first check the column arrangement for the already created table “AddColumn” −
mysql> show create table AddColumn;
The following is the output −
+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table     | Create Table                                                                                                                                                                    |
+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| AddColumn | CREATE TABLE `addcolumn` (`StudentId` varchar(50) DEFAULT NULL, `StudentName` varchar(300) DEFAULT NULL ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci|
+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Now you can rearrange the StudentName column before StudentId. The query is as follows −
mysql> alter table AddColumn change StudentName StudentName varchar(300) first;
Query OK, 0 rows affected (1.28 sec)
Records: 0 Duplicates: 0 Warnings: 0
Here is the query that can be used to check the StudentName is first column or not −
mysql> desc AddColumn;
The following is the output displaying that the columns are successfully rearranged −
+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| StudentName | varchar(300) | YES  |     | NULL    |       |
| StudentId   | varchar(50)  | YES  |     | NULL    |       |
+-------------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
Tryit Editor v3.7

Tryit: Responsive image
How to perform back and refresh in a browser in Selenium with python?

We can perform back and refresh in the browser in Selenium.
For performing back operation in the browser, the back method is to be used.
For refreshing the browser, refresh method is to be used.
Both these methods can be used for testing browser navigations and reloading of web pages.
Code Implementation
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then #invoke actual browser
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/index.htm")
# to print the page title in console
print(driver.title)
# to print the current URL in console
print(driver.current_url)
#get method to launch another URL
driver.get("https://www.tutorialspoint.com/questions/index.php")
# to go back to the previous URL
driver.back()
#to refresh the browser
driver.refresh()
#to close the browser
driver.close()
Python | numpy.copyto() function - GeeksforGeeks

12 Apr, 2019
With the help of Numpy numpy.copyto() method, we can make a copy of all the data elements that is present in numpy array. If we change any data element in the copy, it will not affect the original numpy array.
Syntax : numpy.copyto(destination, source)
Return : Return copy of an array
Example #1 :In this example we can see that with the help of numpy.copyto() method we are making the copy of an elements in a destination array.
# import the important module in pythonimport numpy as np         # make an array with numpygfg = np.array([1, 2, 3])geeks = [4, 5, 6]         # applying numpy.copyto() methodnp.copyto(gfg, geeks)   print(gfg)
[4 5 6]

Example #2 :
# import the important module in pythonimport numpy as np         # make an array with numpygfg = np.array([[1, 2, 3], [4, 5, 6]])geeks = [[4, 5, 6], [7, 8, 9]]         # applying numpy.copyto() methodnp.copyto(gfg, geeks)   print(gfg)
[[4 5 6]
 [7 8 9]]

Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
turtle.dot() function in Python - GeeksforGeeks

21 Jul, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This function is used to draw a circular dot with a particular size, with some color. If the size is not given, the maximum of pensize+4 and 2*pensize is used.
Syntax :
turtle.dot(size=None, *color)

Parameters:
Below is the implementation of the above method with some examples :
Example 1 :
Python3
# import packageimport turtle    # motionturtle.forward(100)  # dot with# 60 diameter# yellow colorturtle.dot(60, color="yellow")
Output :
Example 2 :
Python3
# import packageimport turtle    # delay the turtle work speed# for better understandingsturtle.delay(500)  # hide the turtleturtle.ht()  # some dots with diameter and colorturtle.dot(200, color="red")turtle.dot(180, color="orange")turtle.dot(160, color="yellow")turtle.dot(140, color="green")turtle.dot(120, color="blue")turtle.dot(100, color="indigo")turtle.dot(80, color="violet")turtle.dot(60, color="white")  # write textturtle.write("GFG", align="center",             font=('Verdana', 12, 'bold'))
Output :
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
C++ Program for Leaders in an array - GeeksforGeeks

13 Dec, 2021
Write a program to print all the LEADERS in the array. An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. For example int the array {16, 17, 4, 3, 5, 2}, leaders are 17, 5 and 2. Let the input array be arr[] and size of the array be size. 
Method 1 (Simple) Use two loops. The outer loop runs from 0 to size – 1 and one by one picks all elements from left to right. The inner loop compares the picked element to all the elements to its right side. If the picked element is greater than all the elements to its right side, then the picked element is the leader.  
C++
#include<iostream>using namespace std;  /*C++ Function to print leaders in an array */void printLeaders(int arr[], int size){    for (int i = 0; i < size; i++)    {        int j;        for (j = i+1; j < size; j++)        {            if (arr[i] <=arr[j])                break;        }            if (j == size) // the loop didn't break            cout << arr[i] << " ";  }}  /* Driver program to test above function */int main(){    int arr[] = {16, 17, 4, 3, 5, 2};    int n = sizeof(arr)/sizeof(arr[0]);    printLeaders(arr, n);    return 0;}
Output: 
17 5 2
Time Complexity: O(n*n)Method 2 (Scan from right) Scan all the elements from right to left in an array and keep track of maximum till now. When maximum changes its value, print it.Below image is a dry run of the above approach: 
Below is the implementation of the above approach: 
C++
#include <iostream>using namespace std;  /* C++ Function to print leaders in an array */void printLeaders(int arr[], int size){    int max_from_right =  arr[size-1];      /* Rightmost element is always leader */    cout << max_from_right << " ";          for (int i = size-2; i >= 0; i--)    {        if (max_from_right < arr[i])         {                       max_from_right = arr[i];            cout << max_from_right << " ";        }    }    }  /* Driver program to test above function*/int main(){    int arr[] = {16, 17, 4, 3, 5, 2};    int n = sizeof(arr)/sizeof(arr[0]);    printLeaders(arr, n);    return 0;}    
Output:
2 5 17
Time Complexity: O(n) 
Please refer complete article on Leaders in an array for more details!
Amazon
Payu
Arrays
C++
C++ Programs
Amazon
Payu
Arrays
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Count pairs with given sum
Chocolate Distribution Problem
Window Sliding Technique
Reversal algorithm for array rotation
Next Greater Element
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Inheritance in C++
Map in C++ Standard Template Library (STL)
std::sort() in C++ STL
Wand flip() function - Python - GeeksforGeeks

19 May, 2021
The flip() function is an inbuilt function in the Python Wand ImageMagick library which is used to create a vertical mirror image by reflecting the pixels around the central x-axis.
Syntax: 
flip()
Parameters: This function does not accept any parameters.Return Value: This function returns the Wand ImageMagick object.
Original Image: 
Example 1: 
Python3
# Import library from Imagefrom wand.image import Image # Import the imagewith Image(filename ='../geeksforgeeks.png') as image:    # Clone the image in order to process    with image.clone() as flip:        # Invoke flip function        flip.flip()        # Save the image        flip.save(filename ='flip1.jpg')
Output: 
Example 2: 
Python3
# Import libraries from the wand from wand.image import Imagefrom wand.drawing import Drawingfrom wand.color import Color with Drawing() as draw:    # Set Stroke color the circle to black    draw.stroke_color = Color('black')    # Set Width of the circle to 2    draw.stroke_width = 1    # Set the fill color to 'White (# FFFFFF)'    draw.fill_color = Color('white')     # Invoke Circle function with center at 50, 50 and radius 25    draw.circle((200, 200), # Center point                (100, 100)) # Perimeter point    # Set the font style    draw.font = '../Helvetica.ttf'    # Set the font size    draw.font_size = 30         with Image(width = 400, height = 400, background = Color('# 45ff33')) as pic:        # Set the text and its location        draw.text(int(pic.width / 3), int(pic.height / 2), 'GeeksForGeeks !')        # Draw the picture        draw(pic)        # Invoke flip() function        pic.flip()        # Save the image        pic.save(filename ='flip2.jpg')
Output: 
 
sweetyty
Image-Processing
Python-wand
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Summarize Multiple Columns of data.table by Group in R

23 Sep, 2021
In this article, we will discuss how to summarize multiple columns of data.table by Group in R Programming Language.
R
# load data.table packagelibrary("data.table")  # create data table with 3 columns# items# weight and #costdata <- data.table( items= c("chocos","milk","drinks","drinks",                             "milk","milk","chocos","milk",                             "honey","honey"),                                            weight= c(10,20,34,23,12,45,23,                             12,34,34),                                        cost=  c(120,345,567,324,112,345,                            678,100,45,67))  # displaydata
Output:
By finding average
By finding sum
By finding the minimum value
By finding the maximum value
we can do this by using lapply() function
Syntax: datatable[, lapply(.SD, summarizing_function), by = column]
where
datatable is the input data table
lpply() is used to hold two parameters
first parameter is .SD is standard R object
second parameter is an summarizing function that takes summarizing functions to summarize the datatable
by is the name of the column in which data is grouped based on this column
R
# load data.table packagelibrary("data.table")  # create data table with 3 columns# items# weight and #costdata <- data.table( items= c("chocos","milk","drinks","drinks",                             "milk","milk","chocos","milk",                             "honey","honey"),                                            weight= c(10,20,34,23,12,45,23,                             12,34,34),                                        cost=  c(120,345,567,324,112,345,                            678,100,45,67))    # group by sum with items columnprint(data[, lapply(.SD, sum), by = items])  # group by average with items columnprint(data[, lapply(.SD, mean), by = items])
Output:
R
# load data.table packagelibrary("data.table")  # create data table with 3 columns# items weight and #costdata <- data.table( items= c("chocos","milk","drinks","drinks",                             "milk","milk","chocos","milk",                             "honey","honey"),                                            weight= c(10,20,34,23,12,45,23,                             12,34,34),                                        cost=  c(120,345,567,324,112,345,                            678,100,45,67))  # group by minimum  with items columnprint(data[, lapply(.SD, min), by = items])  # group by maximum with items columnprint(data[, lapply(.SD, max), by = items])
Output:
Picked
R DataTable
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Subscript Dictionary

22 Jun, 2020
Sometimes, while working with data in Python, we can have a problem in which we need to use subscripted version of numbers rather than normal ones. For this, having a dictionary which maps the number with its subscript version has good utility. Let’s discuss certain ways in which this task can be performed.
Input : test_str = “012345”Output : {‘0’: ‘?’, ‘1’: ‘?’, ‘2’: ‘?’, ‘3’: ‘?’, ‘4’: ‘?’, ‘5’: ‘?’}
Input : test_str = “0”Output : {‘0’: ‘?’}
Method #1 : Using loop + ord()This is brute force way in which we perform this task. In this, we iterate through the numbers that we require to subscript and construct subscript value using ord() and its binary value. Works in Python 3.7 +.
# Python3 code to demonstrate working of # Subscript Dictionary# Using loop + ord()  # initializing stringtest_str = "0123456789"  # printing original stringprint("The original string is : " + test_str)  # initializing Subscript number valueK = u'\u2080'  # Subscript Dictionary# Using loop + ord()res = {}for ele in test_str:    res[ele] = K    K = chr(ord(K) + 1)  # printing result print("The split string is : " + str(res)) 
The original string is : 0123456789The split string is : {‘7’: ‘?’, ‘4’: ‘?’, ‘2’: ‘?’, ‘3’: ‘?’, ‘5’: ‘?’, ‘8’: ‘?’, ‘1’: ‘?’, ‘6’: ‘?’, ‘0’: ‘?’, ‘9’: ‘?’}
 
Method #2 : Using dictionary comprehensionThis is yet another way in which this task can be performed. In this, we perform a similar task as above, just employ in one-liner using comprehension. Works in Python 3.7 +.
# Python3 code to demonstrate working of # Subscript Dictionary# Using Dictionary comprehension  # initializing stringtest_str = "0123456789"  # printing original stringprint("The original string is : " + test_str)  # initializing Subscript number valueK = u'\u2080'  # Subscript Dictionary# Using Dictionary comprehensionres = {ele : chr(ord(K) + 1) for ele in test_str}  # printing result print("The split string is : " + str(res)) 
The original string is : 0123456789The split string is : {‘7’: ‘?’, ‘4’: ‘?’, ‘2’: ‘?’, ‘3’: ‘?’, ‘5’: ‘?’, ‘8’: ‘?’, ‘1’: ‘?’, ‘6’: ‘?’, ‘0’: ‘?’, ‘9’: ‘?’}
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python unittest – assertTrue() function

30 Oct, 2020
assertTrue() in Python is a unittest library function that is used in unit testing to compare test value with true. This function will take two parameters as input and return a boolean value depending upon the assert condition. If test value is true then assertTrue() will return true else return false.
Syntax: assertTrue(testValue, message) 
Parameters: assertTrue() accepts two parameters which are listed below with explanation:
testValue:  variable of boolean type which is used in the comparison by function
message: a string sentence as a message which got displayed when the test case got failed.
Listed below are two different examples illustrating the positive and negative test case for given assert function:
Example 1: Negative Test case
Python3
# unit test caseimport unittest class TestStringMethods(unittest.TestCase):    # test function    def test_negative(self):        testValue = False        # error message in case if test case got failed        message = "Test value is not true."        # assertTrue() to check true of test value        self.assertTrue( testValue, message) if __name__ == '__main__':    unittest.main()
Output:
F
======================================================================
FAIL: test_negative (__main__.TestStringMethods)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "p1.py", line 11, in test_negative
    self.assertTrue( testValue, message)
AssertionError: False is not true : Test value is not true.

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (failures=1)







Example 2: Positive Test case
Python3
# unit test caseimport unittest class TestStringMethods(unittest.TestCase):    # test function    def test_positive(self):        testValue = True        # error message in case if test case got failed        message = "Test value is not true."        # assertTrue() to check true of test value        self.assertTrue( testValue, message) if __name__ == '__main__':    unittest.main()
Output:
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK







Reference: https://docs.python.org/3/library/unittest.html
kumar_satyam
Python unittest-library
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
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Introduction To PYTHON
Scala Iterator seq() method with example

28 May, 2019
The seq() method belongs to the concrete value members of the class Iterable. It is helpful in visualizing the sequential view of the stated collection. It has a time complexity of O(1).
Method Definition:def seq: Iterator[A]

def seq: Iterator[A]

Return Type:It returns a sequential view of the iterator.
Example :
// Scala program of seq()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Declaring an iterator        val iter = Iterator(3, 4, 5, 6, 7)                  // Applying seq method in         // for loop        for(n<-iter.seq)        {                          // Displays output            println(n)          }    }}
3
4
5
6
7

Here, a sequential view of the stated iterator is returned by the seq method of Scala.Example :
// Scala program of seq()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Declaring an iterator        val iter = Iterator(8, 9, 10, 11)                  // Applying seq method        val result = iter.seq                      // Displays output        println(result)      }}
non-empty iterator

Here, a non-empty iterator is returned.
Scala
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Print all odd nodes of Binary Search Tree in C++

In this problem, we are given a binary search tree and we have to print all the nodes that have odd values.
The binary search tree is a special type of tree that possess the following properties −
The left subtree always has values smaller than the root node.
The left subtree always has values smaller than the root node.
The right subtree always has values larger than the root node.
The right subtree always has values larger than the root node.
Both the left and right subtree should also follow the above two properties.
Both the left and right subtree should also follow the above two properties.
Let’s take an example to understand the problem −
Output − 1 3 9
To solve this problem, a simple approach would be traversing the tree. On traversal, we will check the value of each node of the tree. If the node is odd print it otherwise more to the next node of the tree.
The complexity of the program will depend on the number of nodes. Time complexity: O(n).
The below program shows the implementation of our solution −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
struct Node {
   int key;
   struct Node *left, *right;
};
Node* newNode(int item){
   Node* temp = new Node;
   temp->key = item;
   temp->left = temp->right = NULL;
   return temp;
}
Node* insertNode(Node* node, int key){
   if (node == NULL)
      return newNode(key);
   if (key < node->key)
      node->left = insertNode(node->left, key);
   else
      node->right = insertNode(node->right, key);
   return node;
}
void printOddNodes(Node* root){
   if (root != NULL) {
      printOddNodes(root->left);
      if (root->key % 2 != 0)
         cout<<root->key<<"\t";
      printOddNodes(root->right);
   }
}
int main(){
   Node* root = NULL;
   root = insertNode(root, 6);
   root = insertNode(root, 3);
   root = insertNode(root, 1);
   root = insertNode(root, 4);
   root = insertNode(root, 9);
   root = insertNode(root, 8);
   root = insertNode(root, 10);
   cout<<"Nodes with odd values are :\n";
   printOddNodes(root);
   return 0;
}
Nodes with odd values are −
1 3 9
How to convert a Double array to a String array in java?

You can convert a double array to a string using the toString() method. To convert a double array to a string array, convert each element of it to string and populate the String array with them.
Live Demo
import java.util.Arrays;

public class DoubleArrayToString {
   public static void main(String args[]) {
      Double[] arr = {12.4, 35.2, 25.6, 98.7, 56.4};
      int size = arr.length;
      String[] str = new String[size];
   
      for(int i=0; i<size; i++) {
         str[i] = arr[i].toString();
         System.out.println(str[i]);
      }
   }
}
12.4
35.2
25.6
98.7
56.4
Print current day and time using HTML and JavaScript - GeeksforGeeks

16 Apr, 2019
The task is to print the system’s current day and time in the following format(Time in hours, minutes and milliseconds).
Use getDay() function to create an array of days in a week. It returns a number of day like 0 for Sunday, 1 for Monday and so on). Convert it into AM or PM using ternary operator.
Use getHours() method to get the hour value between 0 to 23. It returns an integer value.
Minutes and milliseconds were printed using getMinutes() and getMilliseconds() functions respectively.
Example:
<!DOCTYPE html><html>  <head>    <title>        print current day and time    </title></head>  <body>    <script type="text/javascript">        var myDate = new Date();        var myDay = myDate.getDay();                // Array of days.        var weekday = ['Sunday', 'Monday', 'Tuesday',            'Wednesday', 'Thursday', 'Friday', 'Saturday'        ];        document.write("Today is : " + weekday[myDay]);        document.write("<br/>");                // get hour value.        var hours = myDate.getHours();        var ampm = hours >= 12 ? 'PM' : 'AM';        hours = hours % 12;        hours = hours ? hours : 12;        var minutes = myDate.getMinutes();        minutes = minutes < 10 ? '0' + minutes : minutes;        var myTime = hours + " " + ampm + " : " + minutes +             " : " + myDate.getMilliseconds();        document.write("\tCurrent time is : " + myTime);    </script></body>  </html>
HTML-Methods
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
REST API (Introduction)
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
File uploading in React.js
Java parameterized constructor

Yes! it is supported. A constructor with arguments is called the parameterized constructor. It is used to initialize an object with given values. 
Live Demo
public class Tester {
 
   private String message;
 
   public Tester(String message){
      this.message = message;
   }
 
   public String getMessage(){
      return message ;
   }
 
   public void setMessage(String message){
      this.message = message;
   }
 
   public static void main(String[] args) {  
      Tester tester = new Tester("Welcome");
      System.out.println(tester.getMessage());  
   }
}   
Welcome
Tryit Editor v3.6 - Show Python

username = raw_input("Enter username:")
print("Username is: " + username)
Program to remove duplicate characters from a given string in Python

Suppose we have a string s. We have to remove all duplicate characters that have already appeared before. The final string will have same ordering of characters like the actual one.
We can solve this by using ordered dictionary to maintain the insertion order of the characters. The value will be the frequency of those characters, however the frequency values are not important here. After forming the dictionary, we can simply take the keys and join them to get the string.
So, if the input is like s = "bbabcaaccdbaabababc", then the output will be "bacd".
d := a dictionary where keys are stored in order by their insertion order
for each character c in s, doif c is not present in d, thend[c] := 0d[c] := d[c] + 1
if c is not present in d, thend[c] := 0
d[c] := 0
d[c] := d[c] + 1
join the keys one after another in proper order to make the output string and return.
Let us see the following implementation to get better understanding −
from collections import OrderedDict
def solve(s):
   d = OrderedDict()
   for c in s:
      if c not in d:
         d[c] = 0
      d[c] += 1

   return ''.join(d.keys())

s = "bbabcaaccdbaabababc"
print(solve(s))
"bbabcaaccdbaabababc"

"bacd"
React Native - ScrollView

In this chapter, we will show you how to work with the ScrollView element.
We will again create ScrollViewExample.js and import it in Home.
import React from 'react';
import ScrollViewExample from './scroll_view.js';

const App = () => {
   return (
      <ScrollViewExample />
   )
}export default App
Scrollview will render a list of names. We will create it in state.
import React, { Component } from 'react';
import { Text, Image, View, StyleSheet, ScrollView } from 'react-native';

class ScrollViewExample extends Component {
   state = {
      names: [
         {'name': 'Ben', 'id': 1},
         {'name': 'Susan', 'id': 2},
         {'name': 'Robert', 'id': 3},
         {'name': 'Mary', 'id': 4},
         {'name': 'Daniel', 'id': 5},
         {'name': 'Laura', 'id': 6},
         {'name': 'John', 'id': 7},
         {'name': 'Debra', 'id': 8},
         {'name': 'Aron', 'id': 9},
         {'name': 'Ann', 'id': 10},
         {'name': 'Steve', 'id': 11},
         {'name': 'Olivia', 'id': 12}
      ]
   }
   render() {
      return (
         <View>
            <ScrollView>
               {
                  this.state.names.map((item, index) => (
                     <View key = {item.id} style = {styles.item}>
                        <Text>{item.name}</Text>
                     </View>
                  ))
               }
            </ScrollView>
         </View>
      )
   }
}
export default ScrollViewExample

const styles = StyleSheet.create ({
   item: {
      flexDirection: 'row',
      justifyContent: 'space-between',
      alignItems: 'center',
      padding: 30,
      margin: 2,
      borderColor: '#2a4944',
      borderWidth: 1,
      backgroundColor: '#d2f7f1'
   }
})
When we run the app, we will see the scrollable list of names.

    20 Lectures 
     1.5 hours 

 Anadi Sharma

    61 Lectures 
     6.5 hours 

 A To Z Mentor

    40 Lectures 
     4.5 hours 

 Eduonix Learning Solutions

    56 Lectures 
     12.5 hours 

 Eduonix Learning Solutions

    62 Lectures 
     4.5 hours 

 Senol Atac

    67 Lectures 
     4.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
Embedding an online compiler into a website

09 Dec, 2020
How to add a JDoodle compiler into a website?
Using the JDoodle compiler we can write our code in C, C++, Java, and in many more programming languages, and then we can embed and easily run that program in our webpage by giving standard inputs, and we can give command line arguments also.
Steps to follow:
Step 1: Open the website JDoodle.com and sign in, if you don’t have an account then you must register first.
Step 2: Select any one programming language and write your code and save it. Click on editable share and copy the embed URL.
Step 3: On your website page insert the div and script tags as follows:
The below code will create a division and embed the compiler into a website page.      
<div data-pym-src="paste copied URL here."></div>
The below code will include the JavaScript code from the JDoodle. Include the below code at the bottom of the website page.
<script src=”https://www.jdoodle.com/assets/jdoodle-pym.min.js” type=”text/javascript”></script>
Example: Following is an example of embedding a C++ compiler.
HTML
<!DOCTYPE html><html>  <head>    <title>        Embedding an online compiler         into a website    </title></head>  <body>    <!-- It will create a division for         compiler and embed that into         web page-->    <div data-pym-src="https://www.jdoodle.com/embed/v0/2IhG?stdin=1&arg=0">    </div>      <!-- This script tag contains the         javascript code in the written URL -->    <script src="https://www.jdoodle.com/assets/jdoodle-pym.min.js"        type="text/javascript">    </script></body>  </html>
Output:
Note: We can also hide the stdin inputs and command-line arguments by putting ?stdin=0&arg=0 at the end of the URL in the <div> tag. Here, stdin=0 is to hide stdin inputs and arg=0 to hide command line arguments. In order to enable it, just change ‘0’ by ‘1’.
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | os.path.samefile() method

18 Jun, 2019
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.path module is sub module of OS module in Python used for common path name manipulation.
os.path.samefile() method in Python is used to check whether the given two pathnames refer to the same file or directory or not. This is determined by comparing device number and i-node number of the given paths.This method make use of os.stat() method to get device number and i-node number of the given paths. So, an exception will be raised if somehow an os.stat() call fails on either pathname.
Syntax: os.path.samefile(path1, path2)
Parameter:path1: A path-like object representing the first file system path.path2: A path-like object representing the second file system path.
A path-like object is either a string or bytes object representing a path.
Return Type: This method returns a Boolean value of class bool. This method returns True if both path refer to the same file otherwise returns False.
Code : Use of os.path.samefile() method to check whether given paths refer to same file or directory.
# Python program to explain os.path.samefile() method     # importing os module import os  # Pathpath1 = "/home / ihritik / Documents / file(original).txt"  # Create a symbolic link sym_link = "/home / ihritik / Desktop / file(shortcut).txt"os.symlink(path1, sym_link)  # Check whether the given# paths refer to the same# file or directory or notareSame = os.path.samefile(path1, sym_link)  # Print the resultprint(areSame)  # In above example, sym_link is # a symbolic link which refers# to path1, so os.path.samefile() method# will return True as both refer # to same file    # First Pathpath2 = "/home / ihritik / GeeksForGeeks"  # Second path# consider the current working directory# is "/home / ihritik"path3 = os.path.join(os.getcwd(), "GeeksForGeeks")  # Check whether the given# paths refer to the same# file or directory or notareSame = os.path.samefile(path2, path3)  # Print the resultprint(areSame)
True
True

Reference: https://docs.python.org/3/library/os.path.html
Python OS-path-module
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Python | math.gcd() function

20 Mar, 2019
In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.gcd() function compute the greatest common divisor of 2 numbers mentioned in its arguments.
Syntax: math.gcd(x, y)
Parameter:x : Non-negative integer whose gcd has to be computed.y : Non-negative integer whose gcd has to be computed.
Returns: An absolute/positive integer value after calculating the GCD of given parameters x and y.
Exceptions : When Both x and y are 0, function returns 0, If any number is a character, Type error is raised.
Code #1:
# Python code to demonstrate the working of gcd()    # importing "math" for mathematical operations import math     # prints 12 print ("The gcd of 60 and 48 is : ", end ="") print (math.gcd(60, 48)) 
The gcd of 60 and 48 is : 12

 Code #2:
# Python code to demonstrate the working of gcd()  # importing "math" for mathematical operations import math   # prints gcd of x, yprint ("math.gcd(44, 12) : ", math.gcd(44, 12))print ("math.gcd(69, 23) : ", math.gcd(65, 45))
math.gcd(44, 12) :  4
math.gcd(69, 23) :  5

Code #3: Explaining Exception.
# Python code to demonstrate gcd() # method exceptions import math     # prints 0 print ("The gcd of 0 and 0 is : ", end ="") print (math.gcd(0, 0))     # Produces error print ("\nThe gcd of a and 13 is : ", end ="") print (math.gcd('a', 13)) 
Output:
The gcd of 0 and 0 is : 0

The gcd of a and 13 is : 
TypeError: 'str' object cannot be interpreted as an integer
Python math-library-functions
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
Python OOPs Concepts
Convert integer to string in Python
Introduction To PYTHON
How to declare a global variable in PHP?

31 Jul, 2021
Global variables refer to any variable that is defined outside of the function. Global variables can be accessed from any part of the script i.e. inside and outside of the function. So, a global variable can be declared just like other variable but it must be declared outside of function definition.
Syntax:
$variable_name = data;
Below programs illustrate how to declare global variable.
Example 1:
<?php// Demonstrate how to declare global variable  // Declaring global variable$x = "Geeks";$y = "for";$z = "Geeks";  // Display value// Concatenating Stringecho $x.$y.$z;  ?>
GeeksforGeeks

Accessing global variable inside function: The ways to access the global variable inside functions are:
Using global keyword
Using array GLOBALS[var_name]: It stores all global variables in an array called $GLOBALS[var_name]. Var_name is the name of the variable. This array is also accessible from within functions and can be used to perform operations on global variables directly.
Example 2:
<?php// Demonstrate how to declare// global variable  // Declaring global variable$x = "Geeks";$y = "for";$z = "Geeks";$a = 5;$b = 10;  function concatenate() {    // Using global keyword    global $x, $y, $z;    return $x.$y.$z;}  function add() {    // Using GLOBALS['var_name']    $GLOBALS['b'] = $GLOBALS['a'] + $GLOBALS['b'];}  // Print resultecho concatenate();echo"\n";add();echo $b;?>
GeeksforGeeks
15

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
Web Technologies
Web technologies Questions
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to convert array to string in PHP ?
PHP | Converting string to Date and DateTime
Comparing two dates in PHP
Split a comma delimited string into an array in PHP
How to get parameters from a URL string in PHP?
How to convert array to string in PHP ?
Comparing two dates in PHP
Split a comma delimited string into an array in PHP
How to get parameters from a URL string in PHP?
How to fetch data from localserver database and display on HTML table using PHP ?