code-rag-bench/online-tutorials huggingface dataset:
Selenium Webdriver - Headless Execution

Selenium supports headless execution. In the Chrome browser, the headless execution can be implemented with the help of the ChromeOptions class. We have to create an object of this class and apply the add_arguments method on it. Finally, pass the parameter --headless to this method.
Let us obtain the title - About Careers at Tutorials Point - Tutorialspoint of the page launched in a headless mode −
The code implementation for the headless execution is as follows −
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
#object of Options class
c = Options()
#passing headless parameter
c.add_argument("--headless")
#adding headless parameter to webdriver object
driver = webdriver.Chrome(executable_path='../drivers/chromedriver', options=c)
# implicit wait time
driver.implicitly_wait(5)
# url launch
driver.get("https://www.tutorialspoint.com/about/about_careers.htm")
print('Page title: ' + driver.title)
# driver quit
driver.quit()
The output shows the message - Process with exit code 0 meaning that the above Python code executed successfully. Also, the page title of the application(obtained from the driver.title method) - About Careers at Tutorials Point - Tutorialspoint gets printed in the console.

    46 Lectures 
     5.5 hours 

 Aditya Dua

    296 Lectures 
     146 hours 

 Arun Motoori

    411 Lectures 
     38.5 hours 

 In28Minutes Official

    22 Lectures 
     7 hours 

 Arun Motoori

    118 Lectures 
     17 hours 

 Arun Motoori

    278 Lectures 
     38.5 hours 

 Lets Kode It
 Print
 Add Notes
 Bookmark this page
Prim’s Algorithm (Simple Implementation for Adjacency Matrix Representation) in C++

Prim’s Algorithm is a greedy method that is used to find minimum spanning tree for a given weighted undirected graph.
Weighted graph is a graph that has all edges with weight values.
Undirected graph is a special type of graph in which all edges are bidirectional.
Minimum spanning tree is a subset that contains all edges and vertices but no cycle and has the least possible total edge weight.
In this article, we will learn about prim’s algorithm to find minimum spanning tree. Usually, the algorithm uses two arrays but in this solution, we will use only one.
Program to show the implementation of prim’s algorithm.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
#define V 5
bool createsMST(int u, int v, vector<bool> inMST){
   if (u == v)
      return false;
   if (inMST[u] == false && inMST[v] == false)
      return false;
   else if (inMST[u] == true && inMST[v] == true)
      return false;
   return true;
}
void printMinSpanningTree(int cost[][V]){
   vector<bool> inMST(V, false);
   inMST[0] = true;
   int edgeNo = 0, MSTcost = 0;
   while (edgeNo < V - 1) {
      int min = INT_MAX, a = -1, b = -1;
      for (int i = 0; i < V; i++) {
         for (int j = 0; j < V; j++) {
            if (cost[i][j] < min) {
               if (createsMST(i, j, inMST)) {
                  min = cost[i][j];
                  a = i;
                  b = j;
               }
            }
         }
      }
      if (a != -1 && b != -1) {
         cout<<"Edge "<<edgeNo++<<" : ("<<a<<" , "<<b<<" ) : cost = "<<min<<endl;
         MSTcost += min;
         inMST[b] = inMST[a] = true;
      }
   }
   cout<<"Cost of Minimum spanning tree ="<<MSTcost;
}
int main() {
   int cost[][V] = {
      { INT_MAX, 12, INT_MAX, 25, INT_MAX },
      { 12, INT_MAX, 11, 8, 12 },
      { INT_MAX, 11, INT_MAX, INT_MAX, 17 },
      { 25, 8, INT_MAX, INT_MAX, 15 },
      { INT_MAX, 12, 17, 15, INT_MAX },
   };
   cout<<"The Minimum spanning tree for the given tree is :\n";
   printMinSpanningTree(cost);
   return 0;
}
The Minimum spanning tree for the given tree is :
Edge 0 : (0 , 1 ) : cost = 12
Edge 1 : (1 , 3 ) : cost = 8
Edge 2 : (1 , 2 ) : cost = 11
Edge 3 : (1 , 4 ) : cost = 12
Cost of Minimum spanning tree =43
Python | Find frequency of largest element in list - GeeksforGeeks

20 Jul, 2021
Given a list, the task is to find the number of occurrences of the largest element of the list.Examples: 
Input : [1, 2, 8, 5, 8, 7, 8]
Output :3


Input : [2, 9, 1, 3, 4, 5]
Output :1
Method 1: The naive approach is to find the largest element present in the list using max(list) function, then iterating through the list using a for loop and find the frequency of the largest element in the list. Below is the implementation. 
Python3
# Python program to find the# frequency of largest element  L = [1, 2, 8, 5, 8, 7, 8] # print the  frequency of largest elementfrequency = print(L.count(max(L)))           
Output:  
3
Method 2: Using collections.Counter() Once initialized, counters are accessed just like dictionaries. Also, it does not raise the KeyValue error (if key is not present) instead the value’s count is shown as 0. 
Python3
# Python program to find the# frequency of largest element import collections L = [1, 2, 8, 5, 8, 7, 8] # find the largest elementlargest = max(L) # Storing the occurrences of each# element of list in resres = collections.Counter(L) print(res[largest])
Output:  
3
Method 3: Using the dictionary In this approach, the number of occurrences of each element is stored in a dictionary as a key-value pair, where key is the element and value is the frequency. 
Python3
# Python program to find the# frequency of largest element  L = [1, 2, 8, 5, 8, 7, 8]d= {} # find the largest elementlargest = max(L) for i in L:    if i in d:        d[i] += 1    else:        d[i] = 1         print(d[largest])
Output:  
3
 
goshivank
akshaysingh98088
Python list-programs
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
Read a file line by line in Python
Defaultdict in Python
Different ways to create Pandas Dataframe
sum() function in Python
How to Install PIP on Windows ?
Deque in Python
Python String | replace()
Convert integer to string in Python
java.time.LocalDateTime.atZone() Method Example

The java.time.LocalDateTime.atZone(ZoneId zone) method combines this date-time with a time-zone to create a ZonedDateTime..
Following is the declaration for java.time.LocalDateTime.atZone(ZoneId zone) method.
public ZonedDateTime atZone(ZoneId zone)

zone − the time-zone to use, not null.
the zoned date-time formed from this date-time, not null.
The following example shows the usage of java.time.LocalDateTime.atZone(ZoneId zone) method.
package com.tutorialspoint;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;

public class LocalDateTimeDemo {
   public static void main(String[] args) {
      
      LocalDateTime date = LocalDateTime.parse("2017-02-03T12:30:30");
      System.out.println(date);  
      ZonedDateTime date1 = date.atZone(ZoneId.systemDefault());
      System.out.println(date1);  
   }
}
Let us compile and run the above program, this will produce the following result −
2017-02-03T12:30:30
2017-02-03T12:30:30+05:30[Asia/Calcutta]

 Print
 Add Notes
 Bookmark this page
How to use the sleep method in C#?

The sleep method of the thread is used to pause the thread for a specific period.
If you want to set sleep for some seconds, then use it like the following code snippet −
int sleepfor = 2000;
Thread.Sleep(sleepfor);
You can try to run the following code to implement the sleep method of the thread −
 Live Demo
using System;
using System.Threading;

namespace MyApplication {
   class ThreadCreationProgram {
      public static void CallToChildThread() {
         Console.WriteLine("Child thread starts");

         int sleepfor = 2000;

         Console.WriteLine("Child Thread Paused for {0} seconds", sleepfor / 1000);
         Thread.Sleep(sleepfor);
         Console.WriteLine("Child thread resumes");
      }

      static void Main(string[] args) {
         ThreadStart childref = new ThreadStart(CallToChildThread);
         Console.WriteLine("In Main: Creating the Child thread");

         Thread childThread = new Thread(childref);
         childThread.Start();
         Console.ReadKey();
      }
   }
}
In Main: Creating the Child thread
Child thread starts
Child Thread Paused for 2 seconds
Child thread resumes
HTML | <button> type Attribute - GeeksforGeeks

18 May, 2019
The <button> type attribute is used to specify the type of button. It specifies the type attribute of <button> element. The default types of <button> element can vary from browser to browser.
Syntax:
<button type="button|submit|reset">
Attribute Values:
submit: It defines a submit button. It has a default value for all browser except Internet Explorer.
button: It defines a clickable button. It has a default value for Internet Explorer.
reset: It defines a reset button which is used to change the previous data from the form.
Example:
<!DOCTYPE html> <html>     <head>         <title>            HTML button type Attribute        </title>     </head>           <body>        <h1>GeeksforGeeks</h1>                   <h3>HTML button type Attribute</h3>                   <form action="#" method="get">            Username: <input type="text" name="uname">                          <br><br>                          Password: <input type="password" name="pwd">                          <br><br>                          <button type="submit" value="submit">                Submit            </button>                          <button type="reset" value="reset">                Reset            </button>        </form>    </body> </html>                                             
Output:
Supported Browsers: The browser supported by HTML <button> type attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
HTML
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)
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Python – Common list elements and dictionary values

17 Jun, 2021
Given list and dictionary, extract common elements of List and Dictionary Values.
Input : test_list = [“Gfg”, “is”, “Best”, “For”], subs_dict = {4 : “Gfg”, 8 : “Geeks”, 9 : ” Good”, } Output : [‘Gfg’] Explanation : “Gfg” is common in both list and dictionary value.Input : test_list = [“Gfg”, “is”, “Best”, “For”, “Geeks”], subs_dict = {4 : “Gfg”, 8 : “Geeks”, 9 : ” Best”, } Output : [‘Gfg’, “Geeks”, “Best”] Explanation : 3 common values are extracted.  
Method #1 : Using list comprehension + values()
 The combination of above functionalities provide a way in which this task can be performed in a single line. In this, we  extract values of dictionaries using values() and list comprehension is used to perform iteration and intersection checks.
Python3
# Python3 code to demonstrate working of# List elements and dictionary values intersection# Using list comprehension + values() # initializing listtest_list = ["Gfg", "is", "Best", "For", "Geeks"] # printing original listprint("The original list : " + str(test_list)) # initializing subs. Dictionarysubs_dict = {4 : "Gfg", 8 : "Geeks", 9 : " Good", } # Intersection of elements, using "in" for checking presenceres = [ele for ele in test_list if ele in subs_dict.values()]         # printing resultprint("Intersection elements : " + str(res))
The original list : ['Gfg', 'is', 'Best', 'For', 'Geeks']
Intersection elements : ['Gfg', 'Geeks']
Method #2 :  Using set() + intersection()
In this approach both list and dictionary values are converted to set() and then intersection is performed to get common elements.
Python3
# Python3 code to demonstrate working of# Common list elements and dictionary values# Using set() and intersection() # initializing listtest_list = ["Gfg", "is", "Best", "For", "Geeks"] # printing original listprint("The original list : " + str(test_list)) # initializing subs. Dictionarysubs_dict = {4 : "Gfg", 8 : "Geeks", 9 : " Good", } # Intersection of elements, using set() to convert# intersection() for common elementsres = list(set(test_list).intersection(list(subs_dict.values())))         # printing resultprint("Intersection elements : " + str(res))
The original list : ['Gfg', 'is', 'Best', 'For', 'Geeks']
Intersection elements : ['Geeks', 'Gfg']
rajeev0719singh
Python dictionary-programs
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Material UI Container

19 Feb, 2021
Material-UI is a user interface framework that provides pre-defined and customizable React components for faster and easy web development, these Material-UI components are based on top of Material Design by Google. In this article let’s discuss the Typography component in the Material-UI library.
Container:
It is the basic Material-UI component that centers the content horizontally. It manages the layout of its children.
There are two types of styling and adjusting properties that can be used with the container.
Fluid: The Fluid container wraps the content in it with maxWidth value which is provided as a prop, and this value will be the default value of the container.
maxWidth value defines the width of the screen that we are targeting.
xl: 1920px(extra large)
lg: 1280px(large)
md: 960px(medium)
sm: 600px(small)
xs: 0px(extra small)
Fixed: If you prefer to design for a fixed set of sizes instead of trying to accommodate a fully fluid viewport, you can set the fixed property. The max-width matches the min-width of the current breakpoint.
Syntax:
<Container maxwidth="lg">
   <h1>This is Container</h1>
</Container>
Installing React App:
Step1: Create a React app using the following command.
npx create-react-app container-example
Step 2: Get into the project directory.
cd container-example
Installing Material-UI: 
npm install @material-ui/core
// OR
yarn add @material-ui/core
Import Container:
import Container from '@material-ui/core/Container';
Example:
App.js
import Container from '@material-ui/core/Container';import React, { Component }  from 'react';    export default function SimpleContainer() {  return (    <>      <Container maxWidth="lg">        <h1  style={{ backgroundColor: '#cfe8fc'}}>          Container Of maxWidth = lg          </h1>      </Container>      <Container maxWidth="md">        <h1  style={{ backgroundColor: '#cfe8fc'}}>          Container Of maxWidth = md          </h1>      </Container>      <Container maxWidth="sm">        <h1  style={{ backgroundColor: '#cfe8fc'}}>          Container Of maxWidth = sm        </h1>      </Container>      <Container maxWidth="xs">        <h1  style={{ backgroundColor: '#cfe8fc'}}>          Container Of maxWidth = xs         </h1>      </Container>      <Container fixed>        <h1  style={{ backgroundColor: '#cfe8fc'}}>          Container with fixed prop         </h1>      </Container>    </>  );}
Output:
Material-UI
Picked
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How set default timezone in Node.js for Windows ?

21 Dec, 2021
NodeJS is primarily used for non-blocking, event-driven servers, due to its single-threaded nature. It’s used for traditional websites and back-end API services but was designed with real-time, push-based architectures in mind.
In this article we will see how to set default timezone in Node.js for windows. You can learn how to install Nodejs from here.
Installing module: Install the express module using the following command.
npm install express
Project structure: Our project structure will look like this.
There are many methods we can try to set default timezone in Nodejs for Windows.
1. Set in code using process.env.tz sample below –
process.env.TZ = "Asia/Calcutta";
console.log(new Date().toString());
2. Set the variable using newDate.
const nDate = new Date().toLocaleString('en-US', {
timeZone: 'Asia/Calcutta'
});
3. We can config global timezone with the library tzdata in our code:
npm install tzdata -yN
Now in app.js set the value of TZ.
TZ = 'Asia/Calcutta'
console.log(new Date().toString());
Example 1:
app.js
var express = require('express'),app = express();  // Method 1const nDate = new Date().toLocaleString('en-US', {  timeZone: 'Asia/Calcutta'});  console.log(nDate);  app.listen(3000,function(){    console.log("Express Started on Port 3000");});
 
Run app.js file using below command:
node app.js
Output:
Example 2:
app.js
var express = require('express'),app = express();  // Method 2process.env.TZ = "Asia/Calcutta";console.log(new Date().toString());    app.listen(3000,function(){    console.log("Express Started on Port 3000");});
Run app.js file using below command:
node app.js
Output:
Example 3:
app.js
var express = require('express'),  app = express();  // Method 3TZ = 'Asia/Calcutta'console.log(new Date().toString());  app.listen(3000,function(){    console.log("Express Started on Port 3000");});
Run app.js file using below command:
node app.js
Output:
prachisoda1234
Express.js
NodeJS-Questions
Picked
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Installation of Node.js on Windows
JWT Authentication with Node.js
Difference between dependencies, devDependencies and peerDependencies
Mongoose Populate() Method
Mongoose find() Function
Top 10 Projects For Beginners To Practice HTML and CSS Skills
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 ?
Differences between Functional Components and Class Components in React
How to extend Interfaces in Java

An interface contains variables and methods like a class but the methods in an interface are abstract by default unlike a class. An interface extends another interface like a class implements an interface in interface inheritance.
A program that demonstrates extending interfaces in Java is given as follows:
 Live Demo
interface A {
   void funcA();
}
interface B extends A {
   void funcB();
}
class C implements B {
   public void funcA() {
      System.out.println("This is funcA");
   }
   public void funcB() {
      System.out.println("This is funcB");
   }
}
public class Demo {
   public static void main(String args[]) {
      C obj = new C();
      obj.funcA();
      obj.funcB();
   }
}
This is funcA
This is funcB
Now let us understand the above program.
The interface A has an abstract method funcA(). The interface B extends the interface A and has an abstract method funcB(). The class C implements the interface B. A code snippet which demonstrates this is as follows:
interface A {
   void funcA();
}
interface B extends A {
   void funcB();
}
class C implements B {
   public void funcA() {
      System.out.println("This is funcA");
   }
   public void funcB() {
      System.out.println("This is funcB");
   }
}
In the method main() in class Demo, an object obj of class C is created. Then the methods funcA() and funcB() are called. A code snippet which demonstrates this is as follows:
public class Demo {
   public static void main(String args[]) {
      C obj = new C();
      obj.funcA();
      obj.funcB();
   }
}
Python Membership and Identity Operators - GeeksforGeeks

09 Dec, 2021
In this article, we are going to Python Membership and Identity Operators.
Membership operators are operators used to validate the membership of a value. It tests for membership in a sequence, such as strings, lists, or tuples. 
in operator: The ‘in’ operator is used to check if a value exists in a sequence or not. Evaluate to true if it finds a variable in the specified sequence and false otherwise.
Python3
# Python program to illustrate# Finding common member in list# using 'in' operatorlist1=[1,2,3,4,5]list2=[6,7,8,9]for item in list1:    if item in list2:        print("overlapping")     else:    print("not overlapping")
Output:
not overlapping
The same example without using in operator:
Python3
# Python program to illustrate# Finding common member in list# without  using 'in' operator #  Define a function() that takes two listsdef overlapping(list1,list2):     c=0    d=0    for i in list1:        c+=1    for i in list2:        d+=1    for i in range(0,c):        for j in range(0,d):            if(list1[i]==list2[j]):                return 1    return 0list1=[1,2,3,4,5]list2=[6,7,8,9]if(overlapping(list1,list2)):    print("overlapping")else:    print("not overlapping")
Output:
not overlapping
‘not in’ operator- Evaluates to true if it does not finds a variable in the specified sequence and false otherwise.
Python3
# Python program to illustrate# not 'in' operatorx = 24y = 20list = [10, 20, 30, 40, 50 ]; if ( x not in list ):   print("x is NOT present in given list")else:   print("x is  present in given list") if ( y in list ):   print("y is present in given list")else:   print("y is NOT present in given list")
Output:
x is NOT present in given list
y is present in given list
In Python identity operators are used to determine whether a value is of a certain class or type. They are usually used to determine the type of data a certain variable contains. There are different identity operators such as 
‘is’ operator – Evaluates to true if the variables on either side of the operator point to the same object and false otherwise.
Python3
# Python program to illustrate the use# of 'is' identity operatorx = 5if (type(x) is int):    print("true")else:    print("false")
Output: 
true
‘is not’ operator – Evaluates to false if the variables on either side of the operator point to the same object and true otherwise.
Python3
# Python program to illustrate the# use of 'is not' identity operatorx = 5.2if (type(x) is not int):    print("true")else:    print("false")
Output:
true
ismav_nurav
AlexArze
nandavardhan153
sandipranjanjan02
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
How to set font for Text in Tkinter?

Tkinter has many inbuilt methods and functions which are used to provide different features in the widgets. We can customize the font-property of text widget in a tkinter application using the font(‘font-family’,font-size, ‘style’) attribute. The tuple can be declared inside the Text constructor.
Let us have a look at the following example where we will create a text widget with a customized font property.
#Import tkinter library
from tkinter import *
from tkinter import ttk
#Create an instance of tkinter frame or window
win= Tk()
#Set the geometry of tkinter frame
win.geometry("750x250")
#Define a text widget with font-property
text= Text(win, height=15, font=('Times New Roman',17,'bold'))
text.insert(INSERT, "Hey Folks!, Welcome to TutorialsPoint!")
text.pack()
win.mainloop()
Running the above code will display a window that contains a text widget. The text written inside the text widget can be customized using the font property.
RxJava - Conditional Operators

Following are the operators which evaluates one or multiple Observables or items emitted.
All
Evaluates all items emitted to meet given criteria.
Amb
Emits all items from the first Observable only given multiple Observables.
Contains
Checks if an Observable emits a particular item or not.
DefaultIfEmpty
Emits default item if Observable do not emit anything.
SequenceEqual
Checks if two Observables emit the same sequence of items.
SkipUntil
Discards items emitted by first Observable until a second Observable emits an item.
SkipWhile
Discard items emitted by an Observable until a given condition becomes false.
TakeUntil
Discards items emitted by an Observable after a second Observable emits an item or terminates.
TakeWhile
Discard items emitted by an Observable after a specified condition becomes false.
Create the following Java program using any editor of your choice in, say, C:\> RxJava.
import io.reactivex.Observable;
//Using defaultIfEmpty operator to operate on an Observable
public class ObservableTester  {
   public static void main(String[] args) {    
      final StringBuilder result = new StringBuilder();
      Observable.empty()
      .defaultIfEmpty("No Data")
      .subscribe(s -> result.append(s));
      System.out.println(result);
      String[] letters = {"a", "b", "c", "d", "e", "f", "g"};
      final StringBuilder result1 = new StringBuilder();
      Observable.fromArray(letters)
      .firstElement()
      .defaultIfEmpty("No data")   
      .subscribe(s -> result1.append(s));
      System.out.println(result1);
   }
}
Compile the class using javac compiler as follows −
C:\RxJava>javac ObservableTester.java

Now run the ObservableTester as follows −
C:\RxJava>java ObservableTester

It should produce the following output −
No Data
a

 Print
 Add Notes
 Bookmark this page
Print alternate elements of an array | Practice | GeeksforGeeks

You are given an array A of size N. You need to print elements of A in alternate order (starting from index 0).
Example 1:
Input:
N = 4
A[] = {1, 2, 3, 4}
â€‹Output:
1 3

Example 2:
Input:
N = 5
A[] = {1, 2, 3, 4, 5}
â€‹Output:
1 3 5

Your Task:
Since this is a function problem, you just need to complete the provided function void print(int ar[],int n)
Constraints:
1 <= N <= 105
1 <= Ai <= 105
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(1)
0
sumittripathi16 hours ago
class GfG{   public static void print(int arr[], int n)   {       // your code here       for(int i=0;i<n;i=i+2)       {           System.out.print(arr[i]+" ");       }   }}
0
sharmahariom342884 days ago
C Solution:
 
void print(int ar[], int n)
{
    int x;
    for (x = 0; x < n; x = x + 2)
    {
        printf("%d ", ar[x]);
    }
}
0
tanmeetsinghreel1 week ago
//Python3
def printAl(arr,n):   for i in range(0,n,2):       print(arr[i],end=" ")
0
mugadahemanth2 weeks ago
for(int i=0;i<n;i+=2)   {       printf("%d ",ar[i]);   }
+1
payalchaudhary4422 weeks ago
//JAVA CODE :
 public static void print(int arr[], int n)  {
      for(int i=0; i<arr.length; i+=2){     System.out.print(arr[i] +" ");       }
}}
 
0
jaideepkaur00112 weeks ago
#include<iostream>using namespace std;
int main()   {       int i,n;       //    int arr[i];       cout<<"Enter size of an array: ";       cin>>n;       int arr[n];       for(i=0;i<n;i++)           {               cout<<"Enter elements of an array "<<i<<" :";               cin>>arr[i];           }       cout<<"Alternate elements of an array";       for(i=0;i<n;i+=2)           {               cout<<arr[i]<<"\n";           }       return 0;   } 
0
sakshi69192 weeks ago
int n = arr.length;              for(int i=0; i<n; i+=2)       {           System.out.print(arr[i]);
}
0
tusharbadakh1892 weeks ago
for(int i=0;i<arr.length ;i++) { if(i%2==0)  System.out.print(arr[i]+" ");}
+1
rsbly7300952 weeks ago
class Solution { print(arr,n){   let arr1 = [];   for(let i = 0;i<n; i+=2) {       arr1.push(arr[i]);          }   console.log(arr1.join(' ')); }}
0
pradhanprasanta792 weeks ago
C#int[] array = { 1, 4, 5, -1, 6, -4, -5, 13, 10 };        for(int i=0;i<=array.Length;i+=2){            Console.WriteLine( array[i]);        }
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
Batch Script - SHUTDOWN

This batch command shuts down a computer, or logs off the current user.
shutdown

@echo off 
shutdown
If the user executing the batch files has the relevant rights, the computer will be shutdown.
 Print
 Add Notes
 Bookmark this page
Gerrit - Prepare Push Change Set to Gerrit

You need to review the changes in Gerrit before merging them into the master. The changes can be synchronized that have occurred in the master. Use the following command within the branch that you have been working on.
$ git pull --rebase origin master

The above command will fetch the changes or commits from the remote branch and rebase the commits on top of the master.
The above command will fetch the changes or commits from the remote branch and rebase the commits on top of the master.
When you are done with the changes and rebased the commits, you can push your change set to Gerrit for review.
When you are done with the changes and rebased the commits, you can push your change set to Gerrit for review.
Git pull --rebase is often used when changes do not deserve a separate branch.
Git pull --rebase is often used when changes do not deserve a separate branch.
Git pull is a combination of git fetch and git merge; where as git pull --rebase is a combination of git fetch and git rebase.
Git pull is a combination of git fetch and git merge; where as git pull --rebase is a combination of git fetch and git rebase.
First, run the command as git pull origin master as shown in the following screenshot.
Now use the command as git rebase master to rebase the commits as shown in the following screenshot.
 Print
 Add Notes
 Bookmark this page
BigDecimal stripTrailingZeros() Method in Java - GeeksforGeeks

04 Dec, 2018
The java.math.BigDecimal.stripTrailingZeros() is an inbuilt method in Java that returns a BigDecimal which is numerically equal to this one but with any trailing zeros removed from the representation. So basically the function trims off the trailing zero from the BigDecimal value.
Syntax:
public BigDecimal stripTrailingZeros()

Parameter: This method does not accepts any parameter.
Return value: This method returns a numerical value equal to the BigDecimal with all the trailing zeros being removed.
Examples:
Input: 785.000
Output: 785

Input: 125500000
Output: 1.255E+8
Below programs illustrate the working of the above mentioned method:Program 1:
// Program to demonstrate stripTrailingZeros() method of BigDecimal   import java.math.*;  public class Gfg {      public static void main(String[] args)    {          BigDecimal b1 = new BigDecimal("785.000");        BigDecimal b2 = new BigDecimal("125500");          // Assigning the result of stripTrailingZeros method        // to BigDecimal objects b3, b4        BigDecimal b3 = b1.stripTrailingZeros();        BigDecimal b4 = b2.stripTrailingZeros();          // print b3, b4 values        System.out.println(b1 + " after removing trailing zeros " + b3);        System.out.println(b2 + " after removing trailing zeros " + b4);    }}
785.000 after removing trailing zeros 785
125500 after removing trailing zeros 1.255E+5

Program 2:
// Program to demonstrate stripTrailingZeros() method of BigDecimal     import java.math.*;  public class gfg {      public static void main(String[] args)    {          BigDecimal b1 = new BigDecimal("785.00000");        BigDecimal b2 = new BigDecimal("125500000");          // Assigning the result of stripTrailingZeros method        // to BigDecimal objects b3, b4        BigDecimal b3 = b1.stripTrailingZeros();        BigDecimal b4 = b2.stripTrailingZeros();          // Printing b3, b4 values        System.out.println(b1 + " after removing trailing zeros " + b3);        System.out.println(b2 + " after removing trailing zeros " + b4);    }}
785.00000 after removing trailing zeros 785
125500000 after removing trailing zeros 1.255E+8

Reference: https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html#stripTrailingZeros()
Java-BigDecimal
Java-Functions
java-math
Java-math-package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Different ways of Reading a text file in Java
Constructors in Java
Stream In Java
Generics in Java
Exceptions in Java
Functional Interfaces in Java
Comparator Interface in Java with Examples
HashMap get() Method in Java
Strings in Java
StringBuilder Class in Java with Examples
How can I get the current Android SDK version programmatically?

This example demonstrates how do I get the current SDK version programmatically.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:padding="4dp"
   tools:context=".MainActivity">
   <TextView
      android:text=""
      android:id="@+id/textView"
      android:layout_marginTop="30dp"
      android:textStyle="bold"
      android:textSize="24sp"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"/>
</LinearLayout>
Step 3 − Add the following code to src/MainActivity.java
import android.os.Build;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
   TextView textView;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      textView = findViewById(R.id.textView);
      int versionAPI = Build.VERSION.SDK_INT;
      String versionRelease = Build.VERSION.RELEASE;
      textView.setText("API Version :" + versionAPI + "\n" + "Version Release : " + versionRelease);
   }
}

Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from the android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Click here to download the project code.
C# program to get the total number of cores on a computer

Use the Environment.ProcessorCount to get the total number of cores on a computer −
Environment.ProcessorCount
The following is the code that displays the total number of cores on a computer in C# −
Using System;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         Console.WriteLine(Environment.ProcessorCount);
      }
   }
}
Enumerate() in Python - GeeksforGeeks

11 Apr, 2022
Often, when dealing with iterators, we also get a need to keep a count of iterations. Python eases the programmers’ task by providing a built-in function enumerate() for this task. Enumerate() method adds a counter to an iterable and returns it in a form of enumerating object. This enumerated object can then be used directly for loops or converted into a list of tuples using the list() method. 
Syntax: 
enumerate(iterable, start=0)

Parameters:
Iterable: any object that supports iteration
Start: the index value from which the counter is 
              to be started, by default it is 0
 
Python3
# python# Python program to illustrate# enumerate functionl1 = ["eat", "sleep", "repeat"]s1 = "geek"  # creating enumerate objectsobj1 = enumerate(l1)obj2 = enumerate(s1)  print ("Return type:", type(obj1))print (list(enumerate(l1)))  # changing start index to 2 from 0print (list(enumerate(s1, 2)))
Return type: 
[(0, 'eat'), (1, 'sleep'), (2, 'repeat')]
[(2, 'g'), (3, 'e'), (4, 'e'), (5, 'k')]

Using Enumerate object in loops:
Python3
# Python program to illustrate# enumerate function in loopsl1 = ["eat", "sleep", "repeat"]  # printing the tuples in object directlyfor ele in enumerate(l1):    print (ele)  # changing index and printing separatelyfor count, ele in enumerate(l1, 100):    print (count, ele)  # getting desired output from tuplefor count, ele in enumerate(l1):    print(count)    print(ele)
(0, 'eat')
(1, 'sleep')
(2, 'repeat')
100 eat
101 sleep
102 repeat
0
eat
1
sleep
2
repeat

This article is contributed by Harshit Agrawal. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or have more information about the topic discussed above. 
Rounak_agarwal
yashsanghvi301
devpagare002
Python-Built-in-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python OOPs Concepts
Defaultdict in Python
Bar Plot in Matplotlib
How to Install PIP on Windows ?
Stack in Python
Deque in Python
Graph Plotting in Python | Set 1
Check if element exists in list in Python
Convert integer to string in Python
Python Classes and Objects
User-defined Exceptions in C# with Example

An exception is a problem that arises during the execution of a program. A C# exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero.
Define your own exception. User-defined exception classes are derived from the Exception class.
The following is an example −
using System;

namespace UserDefinedException {
   class TestFitness {
      static void Main(string[] args) {
         Fitness f = new Fitness();
         try {
            f.showResult();
         } catch(FitnessTestFailedException e) {
            Console.WriteLine("User defined exception: {0}", e.Message);
         }
         Console.ReadKey();
      }
   }
}

public class FitnessTestFailedException: Exception {
   public FitnessTestFailedException(string message): base(message) {
   }
}

public class Fitness {
   int points = 0;

   public void showResult() {
     
      if(points < 110) {
         throw (new FitnessTestFailedException("Player failed the fitness test!"));
      } else {
         Console.WriteLine("Player passed the fitness test!");
      }
   }
}
Above, we created a user-defined exception −
public class FitnessTestFailedException: Exception {
   public FitnessTestFailedException(string message): base(message) {
}
How to handle action event for JComboBox in Java?

The following is an example to handle action event for JComboBox in Java:
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
public class SwingDemo {
   public static void main(String[] args) throws Exception {
      JFrame frame = new JFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      JComboBox<String> combo = new JComboBox<>(new String[] { "One","Two", "Three","Four","Five", "Six" });
      JButton add = new JButton("Add");
      add.addActionListener(new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
            combo.addItem("New");
         }
      });
      frame.add(combo);
      frame.add(add, BorderLayout.NORTH);
      frame.setSize(500, 100);
      frame.setVisible(true);
   }
}
Now, we have the following items:
Now, click “Add” above to add a new item on runtime. After clicking, a new item would be visible in the bottom as shown in the following screenshot:
java.time.LocalTime.format() Method Example

The java.time.LocalTime.format(DateTimeFormatter formatter) method formats this time using the specified formatter.
Following is the declaration for java.time.LocalTime.format(DateTimeFormatter formatter) method.
public String format(DateTimeFormatter formatter)

formatter − the formatter to use, not null.
the formatted date string, not null.
DateTimeException − if an error occurs during printing.
The following example shows the usage of java.time.LocalTime.format(DateTimeFormatter formatter) method.
package com.tutorialspoint;

import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class LocalTimeDemo {
   public static void main(String[] args) {

      LocalTime time = LocalTime.parse("12:30:30");
      System.out.println(time);  
      DateTimeFormatter formatter = DateTimeFormatter.ISO_TIME;
      System.out.println(formatter.format(time));  
   }
}
Let us compile and run the above program, this will produce the following result −
12:30:30
12:30:30

 Print
 Add Notes
 Bookmark this page
What is the difference between int and integer in MySQL?

The int is the synonym of integer in MySQL 5.0. Here is the demo display both int and integer internally represents int(11).
Creating a table with int datatype
mysql> create table IntDemo
   -> (
   -> Id int
   -> );
Query OK, 0 rows affected (1.04 sec)
Here is description of the table. The query is as follows
mysql> desc IntDemo;
The following is the output
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| Id    | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
1 row in set (0.06 sec)
Look at the column type, which is int(11). Now it stores the same range as defined for integer. The query to insert record is as follows
mysql> insert into IntDemo values(2147483647);
Query OK, 1 row affected (0.20 sec)

mysql> insert into IntDemo values(-2147483648);
Query OK, 1 row affected (0.42 sec)
Display all records from the table using select statement. The query is as follows
mysql> select *from IntDemo;
The following is the output
+-------------+
| Id          |
+-------------+
| 2147483647  |
| -2147483648 |
+-------------+
2 rows in set (0.00 sec)
Creating a table with data type integer.
The query to create a table is as follows
mysql> create table IntegerDemo
   -> (
   -> Id integer
   -> );
Query OK, 0 rows affected (0.93 sec)
Check the description of the table using desc command.
mysql> desc IntegerDemo;
The following is the output
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| Id    | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)
Insert record in the table using insert command. The integer takes the same range as int. The query is as follows
mysql> insert into IntegerDemo values(2147483647);
Query OK, 1 row affected (0.11 sec)

mysql> insert into IntegerDemo values(-2147483648);
Query OK, 1 row affected (0.27 sec)
Display all records from the table using select statement. The query is as follows
mysql> select *from IntegerDemo;
The following is the output
+-------------+
| Id          |
+-------------+
| 2147483647  |
| -2147483648 |
+-------------+
2 rows in set (0.00 sec)
How to change Azure Subscription in PowerShell?

To change the azure subscription using PowerShell, we can use the Select-AZSubscription command. When you use this command, you can use either the subscription ID, Subscription Name, or the Tenant ID.
With Subscription Name,
Select-AzSubscription -SubscriptionName 'Visual Studio'
With TenantID,
Select-AzSubscription -Tenant 'XXXX-XXXXX-XXXXXXX-XXXX'
With Subscription ID,
Select-AzSubscription -SubscriptionId 'XXXX-XXXXX-XXXXXXX-XXXX'
Sometimes on console messages will appear that one or more subscriptions are active. In that case, you can switch the other subscription using the Set-AZContext command and you can use subscription ID or the Name for it.
Set-AzContext -SubscriptionId "xxxx-xxxx-xxxx-xxxx"

Or
Set-AzContext -SubscriptionName "Visual Studio"
Int64.GetHashCode Method in C# with Examples - GeeksforGeeks

04 Apr, 2019
Int64.GetHashCode method is used to get the HashCode for the current Int64 instance.
Syntax: public override int GetHashCode ();
Return Value: This method returns a 32-bit signed integer hash code.
Below programs illustrate the use of the above discussed-method:
Example 1:
// C# program to illustrate the// Int64.GetHashCode() Methodusing System;  class GFG {      // Main Method    public static void Main()    {          // Taking Int64 variable        // i.e. long data type        long s1 = 458732523;          // Getting the hash code for Int64        // using GetHashCode() method        int result = s1.GetHashCode();          // Display the HashCode         Console.WriteLine("HashCode for Int64 is: {0}",                                               result);    }}
HashCode for Int64 is: 458732523

Example 2:
// C# program to illustrate the// Int64.GetHashCode() Methodusing System;  class GFG {      // Main Method    public static void Main()    {        // using result() Method        result(Int64.MinValue);        result(Int64.MaxValue);    }      // result() method    public static void result(long val)    {          // using GetHashCode() method        int code = val.GetHashCode();          // Display the hashcode        Console.WriteLine("HashCode for {0} is {1}",                                        val, code);    }}
HashCode for -9223372036854775808 is -2147483648
HashCode for 9223372036854775807 is -2147483648

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.int64.gethashcode?view=netframework-4.7.2
CSharp-Int64-Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
Partial Classes in C#
C# | Inheritance
Convert String to Character Array in C#
Linked List Implementation in C#
C# | How to insert an element in an Array?
C# | List Class
Difference between Hashtable and Dictionary in C#