code-rag-bench/online-tutorials huggingface dataset:
Print contents of a file in C

Here is an example to print contents of a file in C language,
Let’s say we have “new.txt” file with the following content.
0,hell!o
1,hello!
2,gfdtrhtrhrt
3,demo
Now, let us see the example.
#include<stdio.h>
#include<conio.h>
void main() {
   FILE *f;
   char s;
   clrscr();
   f=fopen("new.txt","r");
   while((s=fgetc(f))!=EOF) {
      printf("%c",s);
   }
   fclose(f);
   getch();
}
0,hell!o
1,hello!
2,gfdtrhtrhrt
3,demo
In the above program, we have a text file “new.txt”. A file pointer is used to open and read the file. It is displaying the content of file.
FILE *f;
char s;
clrscr();
f=fopen("new.txt","r");
while((s=fgetc(f))!=EOF) {
   printf("%c",s);
}
Python | Pandas DataFrame.axes

20 Feb, 2019
Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). Arithmetic operations align on both row and column labels. It can be thought of as a dict-like container for Series objects. This is the primary data structure of the Pandas.
Pandas DataFrame.axes attribute access a group of rows and columns by label(s) or a boolean array in the given DataFrame.
Syntax: DataFrame.axes
Parameter : None
Returns : list
Example #1: Use DataFrame.axes attribute to return a list containing the axes labels of the dataframe.
# importing pandas as pdimport pandas as pd  # Creating the DataFramedf = pd.DataFrame({'Weight':[45, 88, 56, 15, 71],                   'Name':['Sam', 'Andrea', 'Alex', 'Robin', 'Kia'],                   'Age':[14, 25, 55, 8, 21]})  # Create the indexindex_ = ['Row_1', 'Row_2', 'Row_3', 'Row_4', 'Row_5']  # Set the indexdf.index = index_  # Print the DataFrameprint(df)
Output :
Now we will use DataFrame.axes attribute to return the axes labels of the dataframe.
# return the axes labels of the dataframeresult = df.axes  # Print the resultprint(result)
Output :As we can see in the output, the DataFrame.axes attribute has successfully returned a list containing the axes labels of the dataframe. Example #2: Use DataFrame.axes attribute to return a list containing the axes labels of the dataframe.
# importing pandas as pdimport pandas as pd  # Creating the DataFramedf = pd.DataFrame({"A":[12, 4, 5, None, 1],                    "B":[7, 2, 54, 3, None],                    "C":[20, 16, 11, 3, 8],                    "D":[14, 3, None, 2, 6]})   # Create the indexindex_ = ['Row_1', 'Row_2', 'Row_3', 'Row_4', 'Row_5']  # Set the indexdf.index = index_  # Print the DataFrameprint(df)
Output :
Now we will use DataFrame.axes attribute to return the axes labels of the dataframe.
# return the axes labels of the dataframeresult = df.axes  # Print the resultprint(result)
Output :As we can see in the output, the DataFrame.axes attribute has successfully returned a list containing the axes labels of the dataframe.
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Tkinter – Separator Widget

15 Oct, 2021
Tkinter supports a variety of widgets to make GUI more and more attractive and functional. The Separator widget is used to partition the tkinter widgets such as label, buttons etc. Using this widget we can make our design more attractive and intuitive. Now we will see how to implement this widget.
Syntax:
Separator(master, orient)
Parameters:
master: parent widget or main Tk() object
orient: vertical or horizontal
Vertical Orientation:
Python3
# Python program to# Illustrate Separator# widget  # Import required modulesfrom tkinter import *from tkinter import ttk  # Main tkinter windowx = Tk()x.geometry("400x300")  # Label Widgetb = Label(x, bg="#f5f5f5", bd=4, relief=RAISED, text="With Separator")b.place(relx=0.03, rely=0.1, relheight=0.8, relwidth=0.4)  # Separator objectseparator = ttk.Separator(x, orient='vertical')separator.place(relx=0.47, rely=0, relwidth=0.2, relheight=1)  # Label Widgeta = Label(x, bg="#f5f5f5", bd=4, relief=RAISED, text="With Separator")a.place(relx=0.5, rely=0.1, relheight=0.8, relwidth=0.4)  mainloop()
Output: 
 In the above program, the vertical without separator output will be generated only. However, a tkinter window without separator looks like this: 
 
Horizontal Orientation:
Python3
# Python program to# Illustrate Separator# widget  # Import required modulesfrom tkinter import *from tkinter import ttk  # Main tkinter windowx = Tk()x.geometry("400x300")  # Label Widgetb = Label(x, bg="#f5f5f5", bd=4, relief=RAISED, text="With Separator")b.place(relx=0.1, rely=0.05, relheight=0.4, relwidth=0.8)  # Separator objectseparator = ttk.Separator(x, orient='horizontal')separator.place(relx=0, rely=0.47, relwidth=1, relheight=1)  # Label Widgeta = Label(x, bg="#f5f5f5", bd=4, relief=RAISED, text="With Separator")a.place(relx=0.1, rely=0.5, relheight=0.4, relwidth=0.8)  mainloop()
 Output: 
 In the above program, the horizontal without separator output will be generated only. However, a tkinter window without a separator looks like this: 
 
anikakapoor
sweetyty
Python-tkinter
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
Java program to remove all duplicates words from a given sentence

To remove all duplicate words from a given sentence, the Java code is as follows −
 Live Demo
import java.util.Arrays;
import java.util.stream.Collectors;
public class Demo{
   public static void main(String[] args){
      String my_str = "This is a is sample a sample only.";
      my_str = Arrays.stream(my_str.split("\\s+")).distinct().collect(Collectors.joining(" "));
      System.out.println(my_str);
   }
}
This is a sample only.
A class named Demo contains the main function. In this function, a String object is defined. It is split based on the spaces and only distinct words of the string are joined together using space as a separator and displayed on the console.
How to display paragraph elements as inline using CSS ? - GeeksforGeeks

05 Nov, 2020
The purpose of this article is to display paragraph elements as inline elements using CSS. The display property in CSS is used for placing the components (“div”, “hyperlink”, “heading”, etc) on the web page. The display property is set to inline. It has the default property of “anchor” tags. It is used to place the “div” inline i.e. in a horizontal manner. The inline option of display property ignores the “width” and “height” set by the user.
Syntax:
display: inline; 
Example:
HTML
<!DOCTYPE html><html>  <head>    <style>        #main {            height: 200px;            width: 200px;            background: teal;            display: inline;        }          #main1 {            height: 200px;            width: 200px;            background: cyan;            display: inline;        }          #main2 {            height: 200px;            width: 200px;            background: green;            display: inline;        }          .gfg {            margin-left: 20px;            font-size: 42px;            font-weight: bold;            color: #009900;        }          .geeks {            font-size: 25px;            margin-left: 30px;        }          .main {            margin: 50px;        }    </style></head>  <body>    <div class="gfg">GeeksforGeeks</div>    <h2>        How to display paragraph elements         as inline elements using CSS?    </h2>          <p class="main">    <p id="main"> BLOCK 1 </p>    <p id="main1"> BLOCK 2</p>    <p id="main2">BLOCK 3 </p>    </p></body>  </html> 
Output:
Supported browsers are listed below:
Google ChromeInternet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Launching parallel tasks in Python

If a Python program can be broken into subprograms who is processing do not depend on each other, then each of the subprogram can be run in parallel when the overall program is being run. This concept is known as parallel processing in Python.
This module can be used to create many child processes of a main process which can run in parallel. In the below program we initialize a process and then use the run method to run the multiple sub-processes. We can see different sub processes in the print statement by using the process id. We also use the sleep method to see print the statements with a small delay one after another.
 Live Demo
import multiprocessing
import time

class Process(multiprocessing.Process):
   def __init__(self, id):
      super(Process, self).__init__()
      self.id = id

   def run(self):
      time.sleep(1)
      print("Running process id: {}".format(self.id))

if __name__ == '__main__':
   p = Process("a")
   p.start()
   p.join()
   p = Process("b")
   p.start()
   p.join()
   p = Process("c")
   p.start()
   p.join()
Running the above code gives us the following result −
Running process id: a
Running process id: b
Running process id: c
Java Program to Add Two Numbers

public class MyFirstJavaProgram {

   /* This is my first java program.
    * This will add two numbers
    */

   public static void main(String []args) {
      int a = 3, b = 4;
      Int sum = a + b;
      System.out.println(sum); // prints 7
   }
}
Age Testing

It is a testing technique that evaluates a system's ability to perform in the future and usually carried out by test teams. As the system gets older, how significantly the performance might drop is what is being measured in Age Testing.
Let us also understand the concept of Defect Age. It is measured in terms of two parameters:
1. Phases
2. Time 
Defect age in phases is defined as the difference between defect injection phase and defect detection phase.
1. 'defect injection phase' is the phase of the software development life cycle when the defect was introduced.
2. 'defect detection phase' is the phase of the software development life cycle when the defect was pinpointed.
Defect Age in Phase = Defect Detection Phase - Defect Injection Phase
Consider, the SDLC Methodology that we have adopted has the following phases: 
1. Requirements Development
2. Design
3. Coding
4. Unit Testing
5. Integration Testing
6. System Testing
7. Acceptance Testing, and if a defect is identified in Unit Testing (4) and the defect was introduced in Design stage (2) of the Development, then Defect Age is (4)-(2) = 2.
Defect age is defined as the time difference between defect detected date and the current date, provided the defect is still said to be open.
1. Defects are in "Open" and "Assigned" Status and NOT just in "New" Status.
2. Defects that are in "Closed" due to "non-reproducible" or "duplicate" are NOT considered.
3. Difference in days or hours is calculated, from the defect open date and current date.
Defect Age in Time = Defect Fix Date (OR) Current Date - Defect Detection Date
If a defect was detected on 05/05/2013 11:30:00 AM and closed on 23/05/2013 12:00:00 PM, the Defect Age would be calculated as follows.
Defect Age in Days = 05/05/2013 11:30:00 AM - 23/05/2013 12:00:00 PM
Defect Age in Days = 19 days
For assessing the effectiveness of each phase and any review/testing activities, lesser the defect age, better the effectiveness.

    80 Lectures 
     7.5 hours 

 Arnab Chakraborty

    10 Lectures 
     1 hours 

 Zach Miller

    17 Lectures 
     1.5 hours 

 Zach Miller

    60 Lectures 
     5 hours 

 John Shea

    99 Lectures 
     10 hours 

 Daniel IT

    62 Lectures 
     5 hours 

 GlobalETraining
 Print
 Add Notes
 Bookmark this page
Bulma Size - GeeksforGeeks

08 Dec, 2021
Bulma size is used to set your website’s content font size, there are 7 different sizes class in Bulma. You can use any of them to define the size of your context.
Size classes:
is-size-1: The size of this class is pre defined which is font-size of 3rem.
is-size-2: The size of this class is pre defined which is font-size of 2.5rem.
is-size-3: The size of this class is pre defined which is font-size of 2rem.
is-size-4: The size of this class is pre defined which is font-size of 1.5rem.
is-size-5: The size of this class is pre defined which is font-size of 1.25rem.
is-size-6: The size of this class is pre defined which is font-size of 1.0rem.
is-size-7: The size of this class is pre defined which is font-size of 0.75rem.
Example: Below example illustrate the size class in Bulma.
HTML
<!DOCTYPE html><html>  <head>    <title>Bulma Typography</title>    <link rel='stylesheet'          href='https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css'></head>  <body class="has-text-centered">    <h1 class="is-size-2 has-text-success">        GeeksforGeeks    </h1>    <b>Bulma Size</b>    <br>    <div class="container">        <p class="is-size-1">GeeksforGeeks</p>          <p class="is-size-2">GeeksforGeeks</p>          <p class="is-size-3">GeeksforGeeks</p>          <p class="is-size-4">GeeksforGeeks</p>          <p class="is-size-5">GeeksforGeeks</p>          <p class="is-size-6">GeeksforGeeks</p>          <p class="is-size-7">GeeksforGeeks</p>      </div></body></html>
Output:
Size
Reference: https://bulma.io/documentation/helpers/typography-helpers/#size
Bulma
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
How to update Node.js and NPM to next version ?
Types of CSS (Cascading Style Sheet)
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
What is a Stream and what are the types of Streams and classes in Java?

Java provides I/O Streams to read and write data where, a Stream represents an input source or an output destination which could be a file, i/o devise, other program etc.
In general, a Stream will be an input stream or, an output stream.
InputStream − This is used to read data from a source.
OutputStream − This is used to write data to a destination.
Based on the data they handle there are two types of streams −
Byte Streams − These handle data in bytes (8 bits) i.e., the byte stream classes read/write data of 8 bits. Using these you can store characters, videos, audios, images etc.
Character Streams − These handle data in 16 bit Unicode. Using these you can read and write text data only.
Following diagram illustrates all the input and output Streams (classes) in Java.
In addition to above mentioned classes Java provides 3 standard streams representing the input and, output devices.
Standard Input − This is used to read data from user through input devices. keyboard is used as standard input stream and represented as System.in.
Standard Output − This is used to project data (results) to the user through output devices. A computer screen is used for standard output stream and represented as System.out.
Standard Error − This is used to output the error data produced by the user's program and usually a computer screen is used for standard error stream and represented as System.err.
Following Java program reads the data from user using BufferedInputStream and writes it into a file using BufferedOutputStream.
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class BufferedInputStreamExample {
   public static void main(String args[]) throws IOException {
      //Creating an BufferedInputStream object
      BufferedInputStream inputStream = new BufferedInputStream(System.in);
      byte bytes[] = new byte[1024];
      System.out.println("Enter your data ");
      //Reading data from key-board
      inputStream.read(bytes);
      //Creating BufferedOutputStream object
      FileOutputStream out= new FileOutputStream("D:/myFile.txt");
      BufferedOutputStream outputStream = new BufferedOutputStream(out);
      //Writing data to the file
      outputStream.write(bytes);
      outputStream.flush();
      System.out.println("Data successfully written in the specified file");
   }
}
Enter your data
Hi welcome to Tutorialspoint ....
Data successfully written in the specified file
Finding and returning uncommon characters between two strings in JavaScript

We are required to write a JavaScript function that takes in two strings. Our function should return a new string of characters which is not common to both the strings.
Following is the code −
 Live Demo
const str1 = "xyab";
const str2 = "xzca";
const findUncommon = (str1 = '', str2 = '') => {
   const res = [];
   for (let i = 0; i < str1.length; i++){
      if (!(str2.includes(str1[i]))){
         res.push(str1[i])
      }
   }
   for (let i = 0; i < str2.length; i++){
      if (!(str1.includes(str2[i]))){
         res.push(str2[i])
      }
   }
   return res.join("");
};
console.log(findUncommon(str1, str2));
ybzc
Filter query by current date in MySQL

Let us first create a table −
mysql> create table DemoTable(DueDate datetime);
Query OK, 0 rows affected (0.94 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-07-10 04:20:00');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('2019-07-10 05:10:40');
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable values('2019-07-10 09:00:20');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable values('2019-07-10 10:01:04');
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable values('2019-07-10 12:11:10');
Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+---------------------+
| DueDate             |
+---------------------+
| 2019-07-10 04:20:00 |
| 2019-07-10 05:10:40 |
| 2019-07-10 09:00:20 |
| 2019-07-10 10:01:04 |
| 2019-07-10 12:11:10 |
+---------------------+
5 rows in set (0.00 sec)
Following is the query to filter by current date −
mysql> select *from DemoTable where date(DueDate)=curdate()
   and time(DueDate) > '04:00:00'
   and time(DueDate) < '10:00:00';
This will produce the following output −
+---------------------+
| DueDate             |
+---------------------+
| 2019-07-10 04:20:00 |
| 2019-07-10 05:10:40 |
| 2019-07-10 09:00:20 |
+---------------------+
3 rows in set (0.00 sec)
Python Design Patterns - Command

Command Pattern adds a level of abstraction between actions and includes an object, which invokes these actions.
In this design pattern, client creates a command object that includes a list of commands to be executed. The command object created implements a specific interface.
Following is the basic architecture of the command pattern −
We will now see how to implement the design pattern.
def demo(a,b,c):
   print 'a:',a
   print 'b:',b
   print 'c:',c

class Command:
   def __init__(self, cmd, *args):
      self._cmd=cmd
      self._args=args

   def __call__(self, *args):
      return apply(self._cmd, self._args+args)
cmd = Command(dir,__builtins__)
print cmd()

cmd = Command(demo,1,2)
cmd(3)
The above program generates the following output −
The output implements all the commands and keywords listed in Python language. It prints the necessary values of the variables.

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Find first repeating character using JavaScript

We have an array of string / number literals that may/may not contain repeating characters.
Our job is to write a function that takes in the array and returns the index of the first repeating
character. If the array contains no repeating characters, we should return -1.
So, let’s write the code for this function. We will iterate over the array using a for loop and use a
map to store distinct characters as key and their index as value, if during iteration we encounter
a repeating key we return its index otherwise at the end of the loop we return -1.
The code for this will be −
const arr = [12,4365,76,43,76,98,5,31,4];
const secondArr = [6,8,9,32,1,76,98,0,65,878,90];
const findRepeatingIndex = (arr) => {
   const map = {};
   for(let i = 0; i < arr.length; i++){
      if(map[arr[i]]){
         return map[arr[i]];
      }else{
         map[arr[i]] = i;
      }
   }
   return -1;
};
console.log(findRepeatingIndex(arr));
console.log(findRepeatingIndex(secondArr));
The output in the console will be −
2
-1
Check if a given key exists in Java HashMap

Use the containsKey() method and check if a given key exists in the HashMap or not.
Let us first create HashMap and add some elements −
// Create a hash map
HashMap hm = new HashMap();
// Put elements to the map
hm.put("Bag", new Integer(1100));
hm.put("Sunglasses", new Integer(2000));
hm.put("Frames", new Integer(800));
hm.put("Wallet", new Integer(700));
hm.put("Belt", new Integer(600));
Now, let’s say we need to check whether the key “Bag” exists or not, For that, use the containsKey() method like this −
hm.containsKey("Bag")
The following is an example to check if a given key exists in HashMap −
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String args[]) {
      // Create a hash map
      HashMap hm = new HashMap();
      // Put elements to the map
      hm.put("Bag", new Integer(1100));
      hm.put("Sunglasses", new Integer(2000));
      hm.put("Frames", new Integer(800));
      hm.put("Wallet", new Integer(700));
      hm.put("Belt", new Integer(600));
      // Get a set of the entries
      Set set = hm.entrySet();
      System.out.println("Elements in HashMap...");
      // Get an iterator
      Iterator i = set.iterator();
      // Display elements
      while(i.hasNext()) {
         Map.Entry me = (Map.Entry)i.next();
         System.out.print(me.getKey() + ": ");
         System.out.println(me.getValue());
      }
      System.out.println();
      System.out.println("Does Bag exist in the HashMap = "+hm.containsKey("Bag"));
   }
}
Elements in HashMap...
Frames: 800
Belt: 600
Wallet: 700
Bag: 1100
Sunglasses: 2000
Does Bag exist in the HashMap = true
How do we take password input in HTML forms?

To take password input in HTML form, use the <input> tag with type attribute as a password. This is also a single-line text input but it masks the character as soon as a user enters it.
You can try to run the following code to take password input in HTML forms −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <head>
         <title>HTML Forms</title>
      </head>
      <p>Add your details:</p>
      <form>
         Student Username:<br> <input type="text" name="name">
         <br>
         Password:<br> <input type="password" name="password">
         <br>
      </form>
   </body>
</html>
What is evaluation order of function parameters in C?

We pass different arguments into some functions. Now one questions may come in our mind, that what the order of evaluation of the function parameters. Is it left to right, or right to left?
To check the evaluation order we will use a simple program. Here some parameters are passing. From the output we can find how they are evaluated.
#include<stdio.h>
void test_function(int x, int y, int z) {
   printf("The value of x: %d\n", x);
   printf("The value of y: %d\n", y);
   printf("The value of z: %d\n", z);
}
main() {
   int a = 10;
   test_function(a++, a++, a++);
}
The value of x: 12
The value of y: 11
The value of z: 10
From this output we can easily understand the evaluation sequence. At first the z is taken, so it is holding 10, then y is taken, so it is 11, and finally x is taken. So the value is 12.
How to Save Output of Command in a File in Linux? - GeeksforGeeks

17 Mar, 2021

When we run a command on a terminal on Linux it generates some output of that command. Sometimes we need the output result of the commands. Today we are going to see how to save the output of the command.
We can use the redirections operators to save the output of commands into files. Redirection operators redirect the output of a command to the file instead of the output terminal. 
There are two main redirection operators in Linux:
>
>>
Example 1:
The first operator is “>” which is used to redirect the output of a command to the file, but this operator erases all existing data in that file and overwrites the command output, 
Let’s see one example of > redirection operator:
In the above image, we can see that the previous content of the output.txt file gets erased and the output of the ls command is written into the file.
Example 2:
Now let’s see about the second redirection operator is >>. Using this operator we can append the output of the command to the file. It does not erase any previous content of the file. 
Let’s see the example of >> operator
In the above image, we can see that the output of the command is appended to the output.txt file without erasing the content stored in that file.
If the file mentioned after the Redirection operator in not exist then it will create automatically.
When we use the redirection operator the output is going to the file only the redirection operator does not print it on the terminal. To see the output on the terminal and also save it into the file we can use the tee command. It sends the output of the file as well as to the terminal.
First, let’s see how to use the tee operator using the pipeline. Following is the syntax of using the tee operator:
command | tee outfile.txt
Now let’s see one example of the tee command:
We can see in the above image the output is redirected to the terminal as well as the output.txt file.
To append the output of the command to the file use the –a option with the tee command. Here is the syntax of the command:
command | tee outfile.txt
Now Let’s see one example of this command
In this image, we can see that the output of cowsay command is stored in the output.txt file without erasing the existing data of the file.

linux-command


How To


Linux-Unix

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
How to Install Selenium on MacOS?
How to Set Java Path in Windows and Linux?
How to Create and Setup Spring Boot Project in Eclipse IDE?
AWK command in Unix/Linux with examples
Sed Command in Linux/Unix with examples
grep command in Unix/Linux
cut command in Linux with examples
TCP Server-Client implementation in C
How to Install Lightgbm on Windows? - GeeksforGeeks

26 Oct, 2021
In this article, we will learn how to install Lightgbm in Python on Windows .
LightGBM is a gradient boosting framework that uses tree based learning algorithms. It is designed to be distributed and efficient with the following advantages:
Faster training speed and higher efficiency.
Lower memory usage.
Better accuracy.
Support of parallel, distributed, and GPU learning.
Capable of handling large-scale data.
Follow the below steps to install the Lightgbm package on Windows using pip:
Step 1: Install the latest Python3 in Windows
Step 2: Check if pip and python are correctly installed.
python --version
pip --version
Step 3: Upgrade your pip to avoid errors during installation.
pip install --upgrade pip
Step 4: Enter the following command to install Lightgbm using pip.
pip install lightgbm 
Follow the below steps to install the Lightgbm on Windows using the setup.py file:
Step 1: Download the latest source package of Lightgbm for python3 from here.
curl https://files.pythonhosted.org/packages/fe/a2/cf319c151fe2cd863c57bca972c837ea5bf2aa01fd2313aa39ee478a46e5/lightgbm-3.3.0.tar.gz > lightgbm-3.3.0.tar.gz
Step 2: Extract the downloaded package using the following command.
tar -xzvf lightgbm-3.3.0.tar.gz
Step 3: Go inside the folder and Enter the following command to install the package.
cd lightgbm-3.3.0
python setup.py install
Make the following import in your python terminal to verify if the installation has been done properly:
import lightgbm 
If there is any error while importing the module then is not installed properly.
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install FFmpeg on Windows?
How to Set Git Username and Password in GitBash?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
How to Create and Setup Spring Boot Project in Eclipse IDE?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
Print a String in wave pattern in C++

In this problem, we are given a string and an integer n. Our task is to print the given string in a wave pattern of n lines.
Let’s take an example to understand the problem,
Input: Tutorial n = 3
Output:
T             r
   U       o       i       s
      t                l
Wave patterns are printed by printing each character of the string one by one in the next line and tab space away from the next element till the nth line. And the printing tab spaces to the upper line till the first line and follow the same pattern until the string has characters.
The below code gives the implementation of our solution,
 Live Demo
#include<bits/stdc++.h>
using namespace std;
void printWavePattern(string s, int n) {
   if (n==1) {
      cout<<s;
      return;
   }
   int len=s.length();
   char a[len][len]={ };
   int row=0;
   bool down;
   for (int i=0; i<len; i++) {
      a[row][i]=s[i];
      if (row==n-1)
         down=false;
      else if (row==0)
         down=true;
         (down)?(row++):(row--);
   }
   for (int i=0; i<n; i++) {
      for (int j=0; j<len; j++) {
         cout<<a[i][j]<<" ";
      }
      cout<<endl;
   }
}
int main() {
   string str = "TutorialsPoint";
   int n = 4;
   cout<<n<<" Line wave pattern '"<<str<<"' is:\n";
   printWavePattern(str, n);
}
4 Line wave pattern 'TutorialsPoint' is −
T    a    n
u   i l    i t
t    r    s o
   o    P
Gulp - Watch

The Watch method is used to monitor your source files. When any changes to the source file is made, the watch will run an appropriate task. You can use the ‘default’ task to watch for changes to HTML, CSS, and JavaScript files.
In the previous chapter you have learnt how to gulp combining tasks using default task. We used gulp-minify-css, gulp-autoprefixer and gulp-concatplugins, and created styles task to minify CSS files.
To watch CSS file, we need to update the ‘default’ task as shown in the following code:
gulp.task('default', ['styles'], function() {
   // watch for CSS changes
   gulp.watch('src/styles/*.css', function() {
      // run styles upon changes
      gulp.run('styles');
   });
});
All the CSS files under work/src/styles/ folder will be watched and upon changes made to these files, the styles task will be executed.
Run the ‘default’ task using the following command.
gulp

After executing the above command, you will receive the following output.
C:\work>gulp
[17:11:28] Using gulpfile C:\work\gulpfile.js
[17:11:28] Starting 'styles'...
[17:11:28] Finished 'styles' after 22 ms
[17:11:28] Starting 'default'...
[17:11:28] Finished 'default' after 21 ms
Whenever any changes are made to CSS files, you will receive the following output.
C:\work>gulp
[17:11:28] Using gulpfile C:\work\gulpfile.js
[17:11:28] Starting 'styles'...
[17:11:28] Finished 'styles' after 22 ms
[17:11:28] Starting 'default'...
[17:11:28] Finished 'default' after 21 ms
gulp.run() has been deprecated. Use task dependencies or gulp.watch task 
   triggering instead.
[17:18:46] Starting 'styles'...
[17:18:46] Finished 'styles' after 5.1 ms
The Watch process will remain active and respond to your changes. You can press Ctrl+Cto terminate the monitoring process and return to the command line.
 Print
 Add Notes
 Bookmark this page
Java Program to find all angles of a triangle

To find the angles of a triangle we can use sin/cosine rules according to cosine rule −
cos A = (b^2 + c^2 - a^2)/2bc
where A, B , C are the vertices and a, b, c are the sides of the given triangle then, angles of the triangle when the sides a, b, c given are −
angleAtA = acos((b^2 + c^2 - a^2)/(2bc))
angleAtB = acos((a^2 + c^2 - b^2)/(2ac))
angleAtC = acos((a^2 + b^2 - c^2)/(2ab))
C++ Bidirectional Iterators

The iterators that have the privilege to access the sequence of elements of a range from both the directions that are from the end and from the beginning are known as bidirectional iterators. iterators can work on data types like list map and sets.
Bidirectional iterators have the same properties as forwarding iterators, with the only difference that they can also be decremented −
Where X is a bidirectional iterator, a and b are objects of this iterator type, and t is an object of the type pointed by the iterator type (or some other type that can be assigned to the lvalue returned by dereferencing an object of type X).
The concept of Bidirectional iterators in C++.
The bidirectional iterators support all of the features of forwarding iterators, and also prefix and postfix decrement operators.
The bidirectional iterators support all of the features of forwarding iterators, and also prefix and postfix decrement operators.
This type of iterator can access elements in both directions, like towards the end and towards the beginning.
This type of iterator can access elements in both directions, like towards the end and towards the beginning.
The random access iterator is also a type of bidirectional iterator.
The random access iterator is also a type of bidirectional iterator.
Bidirectional iterators have features of forwarding iterator, but the only difference is this iterator can also be decremented.
Bidirectional iterators have features of forwarding iterator, but the only difference is this iterator can also be decremented.
Input: 1 2 3 4 5 6 7 8 9 10
Output: 10 9 8 7 6 5 4 3 2 1
#include <iostream>
#include<iterator>
#include<vector>
using namespace std;
int main() {
   vector<int> vec{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
   vector<int> ::iterator it;
   vector<int> :: reverse_iterator rev_it;
   for(it = vec.begin(); it != vec.end(); it++)
      cout<<*it<<" ";
      cout<< endl;
   for(rev_it = vec.rbegin(); rev_it!= vec.rend(); rev_it++)
      cout<<*rev_it<<" ";
}
1 2 3 4 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1
Ngx-Bootstrap - Environment Setup

In this chapter, you will learn in detail about setting up the working environment of ngx-bootstrap on your local computer. As ngx-bootstrap is primarily for angular projects, make sure you have Node.js and npm and angular installed on your system.
First create a angular project to test ngx-bootstrap components using following commands.
ng new ngxbootstrap

It will create an angular project named ngxbootstrap.
You can use the following command to install ngx-bootstrap in newly created project−
npm install ngx-bootstrap

You can observe the following output once ngx-bootstrap is successfully installed −
+ ngx-bootstrap@5.6.1
added 1 package from 1 contributor and audited 1454 packages in 16.743s

Now, to test if bootstrap works fine with Node.js, create the test component using following command −
ng g component test
CREATE src/app/test/test.component.html (19 bytes)
CREATE src/app/test/test.component.spec.ts (614 bytes)
CREATE src/app/test/test.component.ts (267 bytes)
CREATE src/app/test/test.component.css (0 bytes)
UPDATE src/app/app.module.ts (388 bytes)

Clear content of app.component.html and update it following contents.
app.component.html
<app-test></app-test>

Update content of app.module.ts to include ngx-bootstrap accordion module. We'll add other module in subsequent chapters. Update it following contents.
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { TestComponent } from './test/test.component';
import { AccordionModule } from 'ngx-bootstrap/accordion'
@NgModule({
   declarations: [
      AppComponent,
      TestComponent
   ],
   imports: [
      BrowserAnimationsModule,
      BrowserModule,
      AccordionModule.forRoot()
   ],
   providers: [],
   bootstrap: [AppComponent]
})
export class AppModule { }
Update content of index.html to include bootstrap.css. Update it following contents.
index.html
<!doctype html>
<html lang="en">
   <head>
      <meta charset="utf-8">
      <title>Ngxbootstrap</title>
      <base href="/">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="icon" type="image/x-icon" href="favicon.ico">
      <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
   </head>
   <body>
      <app-root></app-root>
   </body>
</html>
In next chapter, we'll update test component to use ngx-bootstrap components.
 Print
 Add Notes
 Bookmark this page
What is the search() function in Python?

In Python, search() is a method of the module re.
Syntax of search()
re.search(pattern, string):
It is similar to re.match() but it doesn’t limit us to find matches at the beginning of the string only. Unlike in re.match() method, here searching for pattern ‘Tutorials’ in the string ‘TP Tutorials Point TP’ will return a match.
import re
result = re.search(r'Tutorials', 'TP Tutorials Point TP')
print result.group(0)
Tutorials
Here you can see that, search() method is able to find a pattern from any position of the string but it only returns the first occurrence of the search pattern.
HTML <font> Tag

The <font> tag in HTML is used to set font color, font family and font size. Following is the attributes −
color: Set the color of the font.
face: Set the font face i.e. family.
size: Set the font size
Note − The <font> tag isn’t supported in HTML5.
Let us now see an example to implement the <font> tag in HTML −
 Live Demo
<!DOCTYPE html>
<html>
<body>
   <h2>Playing with Fonts</h2>
   <p>Displaying different fonts below:</p>
   <p><font face="arial" size="20" color="yellow">Demo Text!</font></p>
   <p><font size="10" color="gray">Demo Text!</font></p>
   <p><font size="15" face="verdana" color="magento">Demo Text!</font></p>
   <p><font size="8" face="calibri" color="magento">Demo Text!</font></p>
</body>
</html>
In the above example, we have set the font using the font tag attributes −
<font size="8" face="calibri" color="magento">
   Demo Text!
</font>
Above, we have set the font size with −
font size="8"
We have set the font face with face attribute −
font face="calibri"
The font color with color attribute −
font color="magento"
Program to find number of squares in a chessboard in C++

In this problem, we are given the size of a chessboard. Our task is to create a program to find number of squares in a chessboard in C++.
Problem Description − To find the number of squares in a chessboard. We will have to calculate all the combinations of the square that are inside the chessboard i.e. we will consider squares of side 1x1, 2x2, 3x3 ... nxn.
Let’s take an example to understand the problem,
Input: n = 4.
Output: 30
Squares of size 1x1 -> 16
Squares of size 2x2 -> 9
Squares of size 3x3 -> 4
Squares of size 4x4 -> 1
Total number of squares = 16+9+4+1 = 30
Solution Approach:
A simple approach is by using the sum formula for nxn grid.
Let’s deduct the general formula for the sum,
sum(1) = 1
sum(2) = 1 + 4 = 5
sum(3) = 1 + 4 + 9 = 14
sum(4) = 1 + 4 + 9 + 16 = 30
The sum is can be generalised as
sum = 12 + 22 + 32 + 42 + ... n2
sum = ( (n*(n+1)*((2*n) + 1))/6 )
#include <iostream>
using namespace std;
int calcSquaresCount(int n){
   int squareCount = ( (n * (n+1) * (2*n + 1))/6 );
   return squareCount;
}
int main() {
   int n = 6;
   cout<<"The total number of squares of size "<<n<<"X"<<n<<" is
   "<<calcSquaresCount(n);
}
The total number of squares of size 6X6 is 91
How to draw 2D Heatmap using Matplotlib in python? - GeeksforGeeks

26 Nov, 2020
A 2-D Heatmap is a data visualization tool that helps to represent the magnitude of the phenomenon in form of colors. In python, we can plot 2-D Heatmaps using Matplotlib package. There are different methods to plot 2-D Heatmaps, some of them are discussed below. 
Method 1: Using matplotlib.pyplot.imshow() Function
Syntax: matplotlib.pyplot.imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None,vmax=None, origin=None, extent=None, shape=<deprecated parameter>, filternorm=1, filterrad=4.0,imlim=<deprecated parameter>, resample=None, url=None, \*, data=None, \*\*kwargs) 
Python3
# Program to plot 2-D Heat map# using matplotlib.pyplot.imshow() methodimport numpy as npimport matplotlib.pyplot as plt  data = np.random.random(( 12 , 12 ))plt.imshow( data , cmap = 'autumn' , interpolation = 'nearest' )  plt.title( "2-D Heat Map" )plt.show()
Output:
Method 2: Using Seaborn Library
For this we use seaborn.heatmap() function
Syntax: seaborn.heatmap(data, *, vmin=None, vmax=None, cmap=None, center=None, robust=False,annot=None,fmt=’.2g’, annot_kws=None, linewidths=0, linecolor=’white’, cbar=True, cbar_kws=None, cbar_ax=None,square=False, xticklabels=’auto’, yticklabels=’auto’, mask=None, ax=None, **kwargs) 
Python3
# Program to plot 2-D Heat map# using seaborn.heatmap() methodimport numpy as npimport seaborn as snsimport matplotlib.pylab as plt  data_set = np.random.rand( 10 , 10 )ax = sns.heatmap( data_set , linewidth = 0.5 , cmap = 'coolwarm' )  plt.title( "2-D Heat Map" )plt.show()
Output:
Method 3: Using matplotlib.pyplot.pcolormesh() Function
Syntax: matplotlib.pyplot.pcolormesh(*args, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, shading=’flat’, antialiased=False, data=None, **kwargs) 
Python3
# Program to plot 2-D Heat map# using matplotlib.pyplot.pcolormesh() methodimport matplotlib.pyplot as pltimport numpy as np  Z = np.random.rand( 15 , 15 )  plt.pcolormesh( Z , cmap = 'summer' )  plt.title( '2-D Heat Map' )plt.show()
Output:
Python-matplotlib
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Python program to convert a list to string
Python String | replace()
Reading and Writing to text files in Python
sum() function in Python
Create a Pandas DataFrame from Lists
Logic functions and Minimization - GeeksforGeeks

19 Nov, 2018
= PQ + QR’ + PR’ 
= PQ(R+R’) + (P+P’)QR’ + P(Q+Q’)R’
= PQR + PQR’ +PQR’ +P’QR’ + PQR’ + PQ’R’ 
= PQR(m7) + PQR'(m6)+P’QR'(m2) +PQ’R'(m4) 
= m2 + m4 + m6 + m7 


A)   


B) 

C) 

D)  
A) m(4, 6)

B) m(4, 8)

C) m(6, 8)

D) m(4, 6, 8)
m(6,8)+m(1,6,15)
m(1,6,8,15)an
= (P + Q’)(PQ’ + PR)(P’R’ + Q’)
= (PPQ’ + PPR + PQ’Q’ + PQ’R) (P’R’ + Q’) 
= (PQ’ + PR + PQ’ + PQ’R) (P’R’ + Q’)
= (PP’Q’R’ + PP’R’R + PP’Q’R’ + PP’Q’RR’ + PQ’Q’ + PQ’R + PQ’Q’ + PQ’Q’R)
= (0 + 0 + 0 + 0 + PQ’ + PQ’R + PQ’ + PQ’R)
= PQ’ + PQ’R
= PQ'(1 + R)
= PQ’ 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Comments
Old Comments
Must Do Coding Questions for Product Based Companies
How to set background images in ReactJS ?
Microsoft Interview Experience for Internship (Via Engage)
Difference between var, let and const keywords in JavaScript
Array of Objects in C++ with Examples
How to Alter Multiple Columns at Once in SQL Server?
How to Convert Categorical Variable to Numeric in Pandas?
How to Replace Values in Column Based on Condition in Pandas?
How to Fix: SyntaxError: positional argument follows keyword argument in Python
C Program to read contents of Whole File
Python - Read csv file with Pandas without header?

To read CSV file without header, use the header parameter and set it to “None” in the read_csv() method.
Let’s say the following are the contents of our CSV file opened in Microsoft Excel −
At first, import the required library −
import pandas as pd
Load data from a CSV file into a Pandas DataFrame. This will display the headers as well −
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\SalesData.csv")
While loading, use the header parameter and set None to load the CSV without header −
pd.read_csv("C:\\Users\\amit_\\Desktop\\SalesData.csv", header=None)
Following is the code −
import pandas as pd

# Load data from a CSV file into a Pandas DataFrame
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\SalesData.csv")
print("\nReading the CSV file...\n",dataFrame)

# Load data from a CSV file and hide the header
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\SalesData.csv", header=None)
print("\nReading the CSV file (without header)...\n",dataFrame)
This will produce the following output −
Reading the CSV file...
       Car   Reg_Price   Units
0      BMW        2500     100
1    Lexus        3500      80
2     Audi        2500     120
3   Jaguar        2000      70
4  Mustang        2500     110

Reading the CSV file (without header)...
0 1 2
0      Car   Reg_Price Units
1      BMW        2500 100
2    Lexus        3500 80
3     Audi        2500 120
4   Jaguar        2000 70
5  Mustang        2500 110
What is a Tick in python?

The floating-point numbers in units of seconds for time interval are indicated by Tick in python. Particular instants in time are expressed in seconds since 12:00am, January 1, 1970(epoch). You can use the time module to use functions for working with times, and for converting between representations. For example, if you want to print the current time in ticks, you'd write:
import time
ticks = time.time()
print("Ticks since 12:00am, January 1, 1970: ", ticks)
This will give the output −
Ticks since 12:00 am, January 1, 1970:  1514482031.2905385
Redis - Server Flushdb Command

Redis FLUSHDB deletes all the keys of the currently selected DB. This command never fails.
String reply.
Following is the basic syntax of Redis FLUSHDB command.
redis 127.0.0.1:6379> FLUSHDB

redis 127.0.0.1:6379> FLUSHDB  
OK 


    22 Lectures 
     40 mins

 Skillbakerystudios
 Print
 Add Notes
 Bookmark this page