code-rag-bench/online-tutorials huggingface dataset:
How to add new keys to a dictionary in Python?

Dictionary is an unordered collection of key-value pairs. Each element is not identified by positional index. Moreover, the fact that key can’t be repeated, we simply use a new key and assign a value to it so that a new pair will be added to dictionary.
>>> D1 = {1: 'a', 2: 'b', 3: 'c', 'x': 1, 'y': 2, 'z': 3}
>>> D1[10] = 'z'
>>> D1
{1: 'a', 2: 'b', 3: 'c', 'x': 1, 'y': 2, 'z': 3, 10: 'z'}
Addition and Blending of images using OpenCv in Python

We know that when we solve any image related problem, we have to take a matrix. The matrix content will vary depending upon the image type - either it would be a binary image(0, 1), gray scale image(0-255) or RGB image(255 255 255). So if we want to add of two images then that means very simple we have to add respective two matrices.
In OpenCV library, we have a function cv2.add() to add the images. But for image addition the size of the two images should be same.
import cv2
# Readingour Image1
my_firstpic = cv2.imread('C:/Users/TP/Pictures/west bengal/bishnupur/mqdefaultILPT6GSR.jpg', 1)
cv2.imshow('image', my_firstpic)
# Readingour Image2
my_secpic = cv2.imread('C:/Users/Satyajit/Pictures/west bengal/bishnupur/pp.jpg', 1)
img = cv2.add(my_firstpic,my_secpic)
cv2.waitKey(0)
cv2.distroyAllWindows()
cv2.addWeighted() function is used for blending of two images.
import cv2
# Read our Image1
My_first = cv2.imread('C:/Users/TP/Pictures/west bengal/bishnupur/mqdefaultILPT6GSR.jpg', 1)
# Reading ourImage2
My_second = cv2.imread('C:/Users/TP/Pictures/west bengal/bishnupur/pp.jpg', 1)
# Blending the images with 0.3 and 0.7
My_img = cv2.addWeighted(My_first, 0.3, My_second, 0.7, 0)
# Show the image
cv2.imshow('image', My_img)
# Wait for a key
cv2.waitKey(0)
# Destroy all the window open
cv2.distroyAllWindows()
DAX Information - LOOKUPVALUE function

Returns the value in result_columnName for the row that meets all criteria specified by search_columnName and search_value.
LOOKUPVALUE (
   <result_columnName>, <search_columnName>, <search_value>, 
   [<search_columnName>, <search_value>] ...
)

result_columnName
The fully qualified name of a column that contains the value you want to return.
It cannot be an expression.
search_columnName
The fully qualified name of a column, in the same table as result_columnName, or in a related table, over which the lookup is performed.
It cannot be an expression.
search_value
A scalar expression that does not refer to any column in the same table being searched.
The value of result_column at the row where all pairs of search_column and search_value have a match.
The value of result_column at the row where all pairs of search_column and search_value have a match.
If there is no match that satisfies all the search values, a BLANK is returned. In other words, the function will not return a lookup value if only some of the criteria match.
If there is no match that satisfies all the search values, a BLANK is returned. In other words, the function will not return a lookup value if only some of the criteria match.
If multiple rows match the search values and in all cases result_column values are identical then that value is returned. However, if result_column returns different values an error is returned.
If multiple rows match the search values and in all cases result_column values are identical then that value is returned. However, if result_column returns different values an error is returned.
= LOOKUPVALUE([Sport], [EventID],"E962") 
This DAX formula returns the Sport corresponding to the EventID – E962.

    53 Lectures 
     5.5 hours 

 Abhay Gadiya

    24 Lectures 
     2 hours 

 Randy Minder

    26 Lectures 
     4.5 hours 

 Randy Minder
 Print
 Add Notes
 Bookmark this page
How to perform arithmetic across columns of a MySQL table using Python?

The arithmetic operations as the name suggests are used to perform the operations such as additon, subtraction,division, multiplication or modulus.
The arithmetic operations are operated on the numeric data in your table.
To perform addition
SELECT op1+op2 FROM table_name
Here, the op1 and op2 are the column names or the numeric values. If the op1 and op2 are the numeric values, then FROM clause are not required.
The + in the above syntax can be replaced by -,*,%,/ to perform other arithmetic operations.
import MySQL connector
import MySQL connector
establish connection with the connector using connect()
establish connection with the connector using connect()
create the cursor object using cursor() method
create the cursor object using cursor() method
create a query using the appropriate mysql statements
create a query using the appropriate mysql statements
execute the SQL query using execute() method
execute the SQL query using execute() method
close the connection
close the connection
Suppose we have the following table named “Sales”
+------------+---------+
| sale_price |    tax  |
+------------+---------+
|    1000    | 200     |
|    500     | 100     |
|    50      | 50      |
|    180     | 180     |
+------------+---------+
We need to calculate amount adding both the column values including sale_price and the tax.
import mysql.connector
db=mysql.connector.connect(host="your host", user="your username", password="your
password",database="database_name")

cursor=db.cursor()

query="SELECT sale_price,tax, concat(sale_price+tax) AS amount FROM Sales"
cursor.execute(query)

rows=cursor.fetchall()

for row in rows:
   print(row)

db.close()
( ‘sale_price’ , ‘tax’ , ‘amount’ )
(1000,200,1200)
(500,100,600)
(100,50,150)
(700,180,880)
The arithmetic addition is operated on the two columns in the table. Similarly, other arithmetic operations can be performed based on need.
How can I change root username in MySQL?

To change the root username in MySQL, you need to use UPDATE and SET command. The syntax is as follows −
UPDATE user set user = ’yourNewUserName’ WHERE user = ’root’;
To understand the above syntax, let us switch the database to MySQL using USE command.
The query is as follows to switch the database.
mysql> use mysql;
Database changed
Now list all the users from MySQL.user table. The query is as follows −
mysql> select user from MySQL.user;
The following is the output −
+------------------+
| user             |
+------------------+
| Manish           |
| User2            |
| mysql.infoschema |
| mysql.session    |
| mysql.sys        |
| root             |
| Adam Smith       |
| User1            |
| am               |
+------------------+
9 rows in set (0.04 sec)
Look at the sample output, we have username ‘root’. Change the username root to some other name using UPDATE command.
Let us change the username ‘root’ to ‘myRoot’. The query is as follows −
mysql> update user set user = 'myRoot' where user = 'root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
List all users from MySQL.user table to see the username ‘root’ have been changed to ‘myRoot’. The query is as follows to list all users from MySQL.user table.
mysql> select user from MySQL.user;
The following is the output −
+------------------+
| user             |
+------------------+
| Manish           |
| User2            |
| myRoot           |
| mysql.infoschema |
| mysql.session    |
| mysql.sys        |
| Adam Smith       |
| User1            |
| am               |
+------------------+
9 rows in set (0.00 sec)
Look at the above table, ‘root’ username has been changed to ‘myRoot’.
C program to find if the given number is perfect number or not

Perfect number is the number; whose sum of factors is equal to 2*number.
An algorithm is explained below −
START
Step 1: declare int variables and initialized result=0.
Step 2: read number at runtime.
Step 3: for loop i=1;i<=number;i++
Condition satisfies
   i. if(number%i==0)
   ii. result=result+i;
Step 4: checking the sum of factors.
   i. if(result==2*number)
   ii. print perfect number
   iii. else print not perfect number
STOP
Following is the C program to find if the given number is perfect number or not −
 Live Demo
#include<stdio.h>
int main(){
   int number,i,result=0;//declare variables and initialize result to 0
   printf("enter the number:");
   scanf("%d",&number);
   for(i=1;i<=number;i++){
      if(number%i==0)
         result=result+i;
   }
   if(result==2*number) //checking the sum of factors==2*number
      printf("perfect number");
   else
      printf("not perfect number");
}
The output is given below −
enter the number:28
perfect number
enter the number:46
not perfect number
How to use “window.print()” function to print a page?

To print a page in JavaScript, use the window.print() method. It opens up the standard dialog box, through which you can easily set the printing options like which printer to select for printing.
You can try to run the following code to learn how to print a page −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <button onclick="display()">Click to Print</button>
      <script>
         function display() {
            window.print();
         }
      </script>
   </body>
</html>
HTML5 Semantics

The HTML5 Semantics refers to the semantic tags that provide meaning to an HTML page. In HTML5 the tags are divided into two categories - semantic and non-semantic. HTML5 brings several new semantic tags to the HTML.
Some HTML5 Semantic tags are −
Let us see an example of HTML5 Semantics −
 Live Demo
<!DOCTYPE html>
<html>
<style>
   * {
      box-sizing: border-box;
   }
   body {
      color: #000;
      background-color: #8BC6EC;
      background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
      text-align: center;
   }
   header {
      background-color: #000;
      padding: 20px;
      text-align: center;
      color: white;
   }
   nav {
      float: left;
      width: 20%;
      height: 200px;
      background: #282828;
      padding: 60px 10px;
   }
   nav ul {
      list-style-type: none;
      padding: 0;
   }
   nav ul li a {
      text-decoration: none;
      color: #fff;
   }
   article {
      float: left;
      padding: 80px 10px;
      width: 80%;
      background-color: #fff;
      height: 200px;
      text-align: center;
   }
   section:after {
      content: "";
      display: table;
      clear: both;
   }
   footer {
      background-color: #000;
      padding: 20px;
      text-align: center;
      color: white;
   }
</style>
<body>
<h1>HTML Semantics Demo</h1>
<header>This is Header</header>
<section>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<article>This is an article element.</article>
</section>
<footer>This is Footer</footer>
</body>
</html>
How to set a minimum and maximum value for an input element in HTML5 ? - GeeksforGeeks

17 Mar, 2021
In this article, we are going to learn how to set a minimum and maximum value for an input element by using the HTML <input> min and max attribute. This prevents the input element from accepting values that are lower than the minimum value or higher than the maximum.
Approach: This can be implemented by using the min and max attributes:
min: This attribute accepts a minimum value for the input element.
max: This attribute accepts a minimum value for the input element.
These parameters together can be used to specify a range of numbers that can be accepted as input. Note that these attributes only work on the input type of number and date.
Syntax:
<input type="number" min="min_value" max="max_value">
Example: In this example, we have used two inputs with different input types, one is a number type and the other is the date type. The minimum and maximum range of the number is from 1 to 100 and the dates are from 01-01-2020 to 01-01-2021.
HTML
<html><head>  <style type="text/css">    label {      font: 18px;    }      input {      margin: 7px;      padding: 2px    }  </style></head><body>  <h1 style="color: green">    GeeksforGeeks  </h1>  <h3>Set a minimum and maximum value</h3>  <form>    <label for="Number">      Enter Number (between 1 and 100):    </label>    <input type="number" id="Number"            name="Number" min="1" max="100">    <br>    <label for="datemin">Enter a date after      01-01-2020 and before 01-01-2021:    </label>    <input type="date" id="datemin" name="datemin"           min="2020-01-01" max="2021-01-01">    <br>    <input type="submit">  </form></body></html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Questions
HTML5
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Angular File Upload
Form validation using jQuery
How to auto-resize an image to fit a div container using CSS?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
How to create Custom Cursor using CSS

We can create a custom cursor image with extensions like .cur (for Internet Explorer), .gif and .png (for Chrome, Firefox, Safari) and apply it to an element using the CSS cursor property and setting it to a url and in addition a generic cursor value such as auto,default, pointer, etc.
Selector {
   cursor: url("/*path to custom cursor file*/"), generic cursor;
}
Let’s see how to create custom cursor with an example −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Custom Cursor Using CSS</title>
<style>
form {
   width:70%;
   margin: 0 auto;
   text-align: center;
}
* {
   padding: 2px;
   margin:5px;
}
input[type="button"] {
   border-radius: 10px;
}
#tech1 {
   cursor: url("https://www.tutorialspoint.com/images/dbms.png"), auto;
}
#tech2 {
   cursor: url("https://www.tutorialspoint.com/images/Python.png"), auto;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Custom Cursor Using CSS</legend>
<h1>Learn</h1>
<input type="button" id="tech1" value="DBMS">
<input type="button" id="tech2" value="Python">
</fieldset>
</form>
</body></html>
Following is the output for the above code −
Hovering over ‘DBMS’ button −
Hovering over ‘Python’ button −
MySQL query to delete all rows older than 30 days?

To delete all rows older than 30 days, you need to use the DELETE with INTERVAL. Use < now() i.e. less than operator to get all the records before the current date.
Let us first create a table −
mysql> create table DemoTable
   -> (
   -> UserMessage text,
   -> UserMessageSentDate date
   -> );
Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Hi','2019-06-01');
Query OK, 1 row affected (0.11 sec)

mysql> insert into DemoTable values('Hello','2019-07-02');
Query OK, 1 row affected (0.14 sec)

mysql> insert into DemoTable values('Awesome','2019-05-04');
Query OK, 1 row affected (0.15 sec)

mysql> insert into DemoTable values('Good','2019-01-10');
Query OK, 1 row affected (0.35 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
+-------------+---------------------+
| UserMessage | UserMessageSentDate |
+-------------+---------------------+
| Hi          | 2019-06-01          |
| Hello       | 2019-07-02          |
| Awesome     | 2019-05-04          |
| Good        | 2019-01-10          |
+-------------+---------------------+
4 rows in set (0.00 sec)
Following is the query to delete all rows older than 30 days −
mysql> delete from DemoTable where UserMessageSentDate < now() - interval 30 DAY;
Query OK, 3 rows affected (0.11 sec)
Let us check table records once again −
mysql> select *from DemoTable;
+-------------+---------------------+
| UserMessage | UserMessageSentDate |
+-------------+---------------------+
| Hello       | 2019-07-02          |
+-------------+---------------------+
1 row in set (0.00 sec)
RENAME (ρ) Operation in Relational Algebra - GeeksforGeeks

05 Oct, 2020
Prerequisites – Introduction of Relational Algebra in DBMS, Basic Operators in Relational Algebra 
The RENAME operation is used to rename the output of a relation. 
Sometimes it is simple and suitable to break a complicated sequence of operations and rename it as a relation with different names. Reasons to rename a relation can be many, like –  
We may want to save the result of a relational algebra expression as a relation so that we can use it later. 
We may want to join a relation with itself, in that case, it becomes too confusing to specify which one of the tables we are talking about, in that case, we rename one of the tables and perform join operations on them. 
Notation: 
ρ X (R)

where the symbol ‘ρ’ is used to denote the RENAME operator and R is the result of the sequence of operation or expression which is saved with the name X.  
Example-1:  Query to rename the relation Student as Male Student and the attributes of Student – RollNo, SName as (Sno, Name).
ρ MaleStudent(Sno, Name) πRollNo, SName(σCondition(Student))

Example-2:  Query to rename the attributes Name, Age of table Department to A,B. 
ρ (A, B) (Department)

Example-3: Query to rename the table name Project to Pro and its attributes to P, Q, R. 
ρ Pro(P, Q, R) (Project)

Example-4: Query to rename the first attribute of the table Student with attributes A, B, C to P. 
ρ (P, B, C) (Student)
adarshpro43
DBMS-Relational Model
DBMS
GATE CS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between Clustered and Non-clustered index
SQL | Views
Difference between DDL and DML in DBMS
Third Normal Form (3NF)
Second Normal Form (2NF)
Layers of OSI Model
Types of Operating Systems
Page Replacement Algorithms in Operating Systems
TCP/IP Model
Differences between TCP and UDP
Angular Material 7 - SnackBar

The <MatSnackBar>, an Angular Directive, is used to show a notification bar to show on mobile devices as an alternative of dialogs/popups.
In this chapter, we will showcase the configuration required to show a snack bar using Angular Material.
Following is the content of the modified module descriptor app.module.ts.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {MatButtonModule,MatSnackBarModule} from '@angular/material'
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
@NgModule({
   declarations: [
      AppComponent
   ],
   imports: [
      BrowserModule,
      BrowserAnimationsModule,
      MatButtonModule,MatSnackBarModule,
      FormsModule,
      ReactiveFormsModule
   ],
   providers: [],
   bootstrap: [AppComponent]
})
export class AppModule { }
Following is the content of the modified HTML host file app.component.html.
<button mat-button (click)="openSnackBar('Party', 'act')">Show snack-bar</button>
Following is the content of the modified ts file app.component.ts.
import {Component, Injectable} from '@angular/core';
import { MatSnackBar } from "@angular/material";
@Component({
   selector: 'app-root',
   templateUrl: 'app.component.html',
   styleUrls: ['app.component.css']
})
export class AppComponent {
   constructor(public snackBar: MatSnackBar) {}
   openSnackBar(message: string, action: string) {
      this.snackBar.open(message, action, {
         duration: 2000,
      });
   } 
}   
Verify the result.
Here, we've created a button using mat-button on whose click we shows the snack bar.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
Python Set | difference_update() - GeeksforGeeks

30 Jun, 2021
The difference_update() method helps in an in-place way of differentiating the set. The previously discussed set difference() helps to find out the difference between two sets and returns a new set with the difference value, but the difference_update() updates the existing caller set.If A and B are two sets. The set difference() method will get the (A – B) and will return a new set. The set difference_update() method modifies the existing set. If (A – B) is performed, then A gets modified into (A – B), and if (B – A) is performed, then B gets modified into (B – A).Syntax:  
A.difference_update(B) for (A - B)
B.difference_update(A) for (B - A)
 
The function returns None and changes the value of the existing set. In this example, we will get the difference between two sets and show how the difference_update works. 
Python3
# Python code to get the difference between two sets# using difference_update() between set A and set B # Driver CodeA = {10, 20, 30, 40, 80}B = {100, 30, 80, 40, 60} # Modifies A and returns NoneA.difference_update(B) # Prints the modified setprint (A)
Output:  
{20, 10}
 
surindertarika1234
python-set
Python
python-set
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
Python Dictionary
Taking input in Python
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Count and Say in Python

Here we will see the Count and Say sequence. This is a sequence whose few terms are like below −
1
11
21
1211
111221
The string will be read like
1 (One)
11 (One 1) So read the previous 1, and say “One 1”
21 (Two 1) So read the previous 11, and say “Two 1”
1211 (One 2 one 1) So read the previous 21, and say “One 2 one 1”
111221 (One 1 one 2 two 1) So read the previous 1211, and say “One 1 one 2 two 1”
Suppose we have a number n, 1 <= n < = 30, then we have to generate nth term.
To solve this, we will follow this approach −
set s := “1”
if n = 1, then return s
for i := 2 to n + 1j := 0, temp := “”, curr = “” and count := 0while j < length of s, doif curr is “”, then curr := s[j], count := 1 and increase j by 1else if curr is s[j], then increase count and j by 1otherwise temp := temp + count as string + curr, curr = “”, count := 0temp := temp + count as string + curr
j := 0, temp := “”, curr = “” and count := 0
while j < length of s, doif curr is “”, then curr := s[j], count := 1 and increase j by 1else if curr is s[j], then increase count and j by 1otherwise temp := temp + count as string + curr, curr = “”, count := 0
if curr is “”, then curr := s[j], count := 1 and increase j by 1
else if curr is s[j], then increase count and j by 1
otherwise temp := temp + count as string + curr, curr = “”, count := 0
temp := temp + count as string + curr
return s
Let us see the following implementation to get better understanding −
 Live Demo
class Solution(object):
   def countAndSay(self, n):
      """
      :type n: int
      :rtype: str
      """
      s = "1"
      if n == 1:
         return s
      for i in range(2,n+1):
         j = 0
         temp = ""
         curr = ""
         count = 0
         while j<len(s):
            #print(curr,count)
            if curr =="":
               #print(curr)
               curr=s[j]
               count=1
               j+=1
            elif curr == s[j]:
               #print(curr)
               count+=1
               j+=1
            else:
               #print(count,curr)
               temp+= str(count) + curr
               curr=""
               count = 0
               #print(temp)
         temp+=str(count) + curr
         s=temp
      return s
ob1 = Solution()
print(ob1.countAndSay(6))
print(ob1.countAndSay(6))
312211
Firebase - Anonymous Authentication

In this chapter, we will authenticate users anonymously.
This is the same process as in our earlier chapters. You need to open the Firebase dashboard, click on Auth from the side menu and SIGN-IN-METHOD inside the tab bar. You need to enable anonymous authentication.
We can use signInAnonymously() method for this authentication.
Let us consider the following example.
firebase.auth().signInAnonymously()
.then(function() {
   console.log('Logged in as Anonymous!')
   
   }).catch(function(error) {
   var errorCode = error.code;
   var errorMessage = error.message;
   console.log(errorCode);
   console.log(errorMessage);
});

    60 Lectures 
     5 hours 

 University Code

    28 Lectures 
     2.5 hours 

 Appeteria

    85 Lectures 
     14.5 hours 

 Appeteria

    46 Lectures 
     2.5 hours 

 Gautham Vijayan

    13 Lectures 
     1.5 hours 

 Nishant Kumar

    85 Lectures 
     16.5 hours 

 Rahul Agarwal
 Print
 Add Notes
 Bookmark this page
Anonymous Union and Structure in C

Here we will see what is the anonymous union and structures in C. The anonymous unions and structures are unnamed unions and structures. As they have no names, so we cannot create direct objects of it. We use it as nested structures or unions.
These are the examples of anonymous union and structures.
struct {
   datatype variable;
   ...
};
union {
   datatype variable;
   ...
};
In this example we are making one structure, called point, it is holding an anonymous structure. This is holding two values x, y. We can access the anonymous structure or union members directly.
#include<stdio.h>
struct point {
   // Anonymous structure
   struct {
      int x;
      int y;
   };
};
main() {
   struct point pt;
   pt.x = 10;
   pt.y = 20;
   printf("Point (%d,%d)", pt.x, pt.y); //anonymus members can be accessed directly
}
Point (10,20)
Python – Create a new column in a Pandas dataframe

To create a new column, we will use the already created column. At first, let us create a DataFrame and read our CSV −
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\SalesRecords.csv")
Now, we will create a new column “New_Reg_Price” from the already created column “Reg_Price” and add 100 to each value, forming a new column −
dataFrame['New_Reg_Price'] = (dataFrame['Reg_Price'] + 100)
Following is the code −
import pandas as pd

# reading csv file
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\SalesRecords.csv")
print("DataFrame...\n",dataFrame)

# count the rows and columns in a DataFrame
print("\nNumber of rows and column in our DataFrame = ",dataFrame.shape)

dataFrame['New_Reg_Price'] = (dataFrame['Reg_Price'] + 100)

print("Updated DataFrame with a new column...\n",dataFrame)

print("\n[Updated] Number of rows and column in our DataFrame = ",dataFrame.shape)


This will produce the following output −
DataFrame...
           Car   Date_of_Purchase   Reg_Price
0          BMW         10/10/2020        1000
1        Lexus         10/12/2020         750
2         Audi         10/17/2020         750
3       Jaguar         10/16/2020        1500
4      Mustang         10/19/2020        1100
5  Lamborghini         10/22/2020        1000

Number of rows and column in our DataFrame = (6, 3)
Updated DataFrame with a new column ...
           Car   Date_of_Purchase   Reg_Price   New_Reg_Price
0          BMW         10/10/2020        1000            1100
1        Lexus         10/12/2020         750             850
2         Audi         10/17/2020         750             850
3       Jaguar         10/16/2020        1500            1600
4      Mustang         10/19/2020        1100            1200
5  Lamborghini         10/22/2020        1000            1100

(Updated)Number of rows and column in our DataFrame = (6, 4)
Git Staging Environment

One of the core functions of Git is the concepts of the Staging Environment, and the Commit.
As you are working, you may be adding, editing and removing files. But 
whenever you hit a milestone or finish a part of the work, you should add the 
files to a Staging Environment.
Staged files are files that are ready to be 
committed to the 
repository you are working on. You will learn more about 
commit shortly.
For now, we are done working with index.html. 
So we can add it to the Staging Environment:
git add index.html
The file should be Staged. Let's check the status::
git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached ..." to unstage)
    new file: index.html
Now the file has been added to the Staging Environment.
You can also stage more than one file at a time. Let's add 2 more files to our working folder. Use the text editor again.
A README.md file that describes the repository (recommended for all 
repositories):
A basic external style sheet (bluestyle.css):
And update index.html to include the stylesheet:
Now add all files in the current directory to the Staging Environment:
git add --all
Using --all instead of individual filenames 
will stage all changes (new, modified, and deleted) files.
git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached ..." to unstage)
        new file:   README.md
        new file:   bluestyle.css
        new file:   index.html
Now all 3 files are added to the Staging Environment, and we are ready to do 
our first commit.
Note: The shorthand command for 
  git add --all is git add -A
Add index.html to the Stating Environment:
git  index.html


Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
Bootstrap btn-toolbar class

Set Button Toolbar in Bootstrap using the btn-toolbar class.
You can try to run the following code to implement the btn-toolbar class −
 Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <script src="/scripts/jquery.min.js"></script>
      <script src="/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "btn-toolbar" role = "toolbar">
         <div class = "btn-group">
            <button type = "button" class = "btn btn-default">MCA</button>
            <button type = "button" class = "btn btn-default">BCA</button>
         </div>
         <div class = "btn-group">
            <button type = "button" class = "btn btn-default">MBA</button>
            <button type = "button" class = "btn btn-default">MS</button>
         </div>
      </div>
   </body>
</html>
Get object at the top of the Stack in C#

To get object at the top of the Stack, the code is as follows −
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      Stack<string> stack = new Stack<string>();
      stack.Push("A");
      stack.Push("B");
      stack.Push("C");
      stack.Push("D");
      stack.Push("E");
      stack.Push("F");
      stack.Push("G");
      stack.Push("H");
      stack.Push("I");
      stack.Push("J");
      Console.WriteLine("Count of elements = "+stack.Count);
      Console.WriteLine("Element at the top of stack = " + stack.Peek());
   }
}
This will produce the following output −
Count of elements = 10
Element at the top of stack = J

Count of elements = 10
Let us see another example −
 Live Demo
using System;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      Stack<int> stack = new Stack<int>();
      stack.Push(10);
      stack.Push(20);
      stack.Push(30);
      stack.Push(40);
      stack.Push(50);
      stack.Push(60);
      stack.Push(70);
      stack.Push(80);
      stack.Push(90);
      stack.Push(100);
      Console.WriteLine("Count of elements = "+stack.Count);
      Console.WriteLine("Element at the top of stack = " + stack.Peek());
      Console.WriteLine("Element at the top of stack = " + stack.Peek());
   }
}
This will produce the following output −
Count of elements = 10
Element at the top of stack = 100
Element at the top of stack = 100
Maximum width of a binary tree in C++

Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum of widths of all levels.
Consider below tree −
      10
     / \
    7   4
   / \   \
  9   2   1
         / \
        2   5
1. Width at level 1: 1
2. Width at level 2: 2
3. Width at level 3: 3
4. Width at level 4: 2
For above tree answer is 3.
1. Use level order traversal to find the answer
#include <bits/stdc++.h>
using namespace std;
struct node {
   public:
      int data;
      node* left;
      node* right;
};
int getWidth(node* root, int level);
int height(node* node);
node* newNode(int data);
int getMaxWidth(node* root){
   int maxWidth = 0;
   int width;
   int h = height(root);
   int i;
   for (i = 1; i <= h; ++i) {
      width = getWidth(root, i);
      if (width > maxWidth) {
         maxWidth = width;
      }
   }
   return maxWidth;
}
int getWidth(node* root, int level){
   if (root == NULL) {
      return 0;
   }
   if (level == 1) {
      return 1;
   }
   else if (level > 1) {
      return getWidth(root->left, level - 1) + getWidth(root->right, level - 1);
   }
}
int height(node* node){
   if (node == NULL) {
      return 0;
   }
   int lHeight = height(node->left);
   int rHeight = height(node->right);
   return (lHeight > rHeight)? (lHeight + 1): (rHeight + 1);
}
node* newNode(int data){
   node* Node = new node();
   Node->data = data;
   Node->left = NULL;
   Node->right = NULL;
   return(Node);
}
int main(){
   node *root = newNode(10);
   root->left = newNode(7);
   root->right = newNode(4);
   root->left->left = newNode(9);
   root->left->right = newNode(2);
   root->right->right = newNode(1);
   root->right->right->left = newNode(2);
   root->right->right->right = newNode(5);
   cout<<"Maximum width = " << getMaxWidth(root) << endl;
   return 0;
}
When you compile and execute the above program. It generates the following output −
Maximum width = 3
Get repetition of a string in Julia - repeat() Method - GeeksforGeeks

26 Mar, 2020
The repeat() is an inbuilt function in julia which is used to return a string which is the repetition of specified string with specified number of times.
Syntax:repeat(String::AbstractString, r::Integer)
Parameters:
String: Specified string or character
r::Integer: Specified number of times
Returns: It returns a string which is the repetition of specified string with specified number of times.
Example 1:
# Julia program to illustrate # the use of String repeat() method  # Create a repetition of string "gfg"# with 3 times of repetition.println(repeat("gfg", 3))  # Create a repetition of character "a"# with 4 times of repetition.println(repeat("a", 4))  # Create a repetition of string "Geeks"# with 2 times of repetition.println(repeat("Geeks", 2))  # Create a repetition of string "@#"# with 3 times of repetition.println(repeat("@#", 3))
Output:
gfggfggfg
aaaa
GeeksGeeks
@#@#@#
Example 2:
# Julia program to illustrate # the use of String repeat() method   # Create a repetition of string "123"# with 3 times of repetition.println(repeat("123", 3))   # Create a repetition of string "22"# with 4 times of repetition.println(repeat("22", 4))   # Create a repetition of string "03210"# with 2 times of repetitionprintln(repeat("03210", 2))
Output:
123123123
22222222
0321003210
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Get array dimensions and size of a dimension in Julia - size() Method
Decision Making in Julia (if, if-else, Nested-if, if-elseif-else ladder)
Searching in Array for a given element in Julia
Reverse array elements in Julia - reverse(), reverse!() and reverseind() Methods
Exception handling in Julia
Get number of elements of array in Julia - length() Method
Find maximum element along with its index in Julia - findmax() Method
Working with Date and Time in Julia
Working with Excel Files in Julia
Getting last element of an array in Julia - last() Method
How to change header background color of a table in Java

To change header background color, at first get the header background −
JTableHeader tableHeader = table.getTableHeader();
Now, set the background color using set Background() −
tableHeader.setBackground(Color.black);
Above, we have used the Color class to set the color.
The following is an example to change the header background color of a JTable −
package my;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.JTableHeader;
public class SwingDemo {
   public static void main(String[] argv) throws Exception {
      Integer[][] marks = {
         { 70, 66, 76, 89, 67, 98 },
         { 67, 89, 64, 78, 59, 78 },
         { 68, 87, 71, 65, 87, 86 },
         { 80, 56, 89, 98, 59, 56 },
         { 75, 95, 90, 73, 57, 79 },
         { 69, 49, 56, 78, 76, 77 }
      };
      String col[] = { "S1", "S2", "S3", "S4", "S5", "S6"};
      JTable table = new JTable(marks, col);
      Font font = new Font("Verdana", Font.PLAIN, 12);
      table.setFont(font);
      table.setRowHeight(30);
      table.setBackground(Color.blue);
      table.setForeground(Color.white);
      JTableHeader tableHeader = table.getTableHeader();
      tableHeader.setBackground(Color.black);
      tableHeader.setForeground(Color.white);
      JFrame frame = new JFrame();
      frame.setSize(600, 400);
      frame.add(new JScrollPane(table));
      frame.setVisible(true);
   }
}
The output is as follows. Here, we have changed the header background color to BLACK −
Turtle graphics using Python

Turtle is a Python library to draw graphics. After we import Turtle we can give commands like forward, backward, right, left etc. This commands will draw different shapes when we. When We combine Search commands we can create many nice graphics in the below example we will see some simple scenarios and then some Complex ones where nice graphics is created.
forward(10)  It moves the turtle (arrow) forward by 10 pixels.
forward(10)  It moves the turtle (arrow) forward by 10 pixels.
backward(5)  It moves the turtle (arrow) backward by 5 pixels
backward(5)  It moves the turtle (arrow) backward by 5 pixels
 right(35)  It moves the turtle (arrow) clockwise by an angle of 35 degrees.
 right(35)  It moves the turtle (arrow) clockwise by an angle of 35 degrees.
left(55)  It moves the turtle (arrow) counter-clockwise by an angle of 55 degrees
left(55)  It moves the turtle (arrow) counter-clockwise by an angle of 55 degrees
 goto(x,y)  It moves the turtle (arrow) to the position x, y
 goto(x,y)  It moves the turtle (arrow) to the position x, y
 dot() It creates a dot in the current position.
 dot() It creates a dot in the current position.
 shape(‘circle’) It draws a circle shape.
 shape(‘circle’) It draws a circle shape.
Let’s see some drawings using some simple commands.
In the below program we draw a start. We choose appropriate steps to move the cursor forward and then right continuously to get this result.
import turtle
star = turtle.Turtle()
for i in range(100):
   star.forward(100)
   star.right(144)
   turtle.done()
Running the above code gives us the following result
We follow a similar approach where the turtle moves in all four directions to create the English alphabet E.
import turtle
t=turtle.Turtle()
t.penup()
t.setpos(-20,40)
t.pendown()
t.pensize(10)
t.pencolor("pink")
t.forward(100)
t.backward(100)
t.right(90)
t.forward(100)
t.left(90)
t.forward(100)
t.backward(100)
t.right(90)
t.forward(100)
t.left(90)
t.forward(100)
turtle.done()
Running the above code gives us the following result
In the next example we see the drawing of multiple squares all starting from a common point. We sue the usual simple commands to go forward, backward and then turn 90 degrees.
import turtle
mult_square=turtle.Turtle()
def Multiple_Squares(length, colour):
mult_square.pencolor(colour)
mult_square.pensize(2)
mult_square.forward(length)
mult_square.right(90)
mult_square.forward(length)
mult_square.right(90)
mult_square.forward(length)
mult_square.right(90)
mult_square.forward(length)
mult_square.right(90)
mult_square.setheading(360)
for i in range(60,120,15):
   Multiple_Squares(i,"blue")
   turtle.done
Running the above code gives us the following result
This is a very interesting example where we use turtle to create a spiral structure. The final shape is a hexagon and there are various colours used in producing the sides of the hexagon.
import turtle
colors = [ "pink","yellow","blue","green","white","red"]
sketch = turtle.Pen()
turtle.bgcolor("black")
for i in range(200):
   sketch.pencolor(colors[i % 6])
   sketch.width(i/100 + 1)
   sketch.forward(i)
   sketch.left(59)
Running the above code gives us the following result
How can I add a new column which counts the number of rows as serial number in MySQL?

To add a new column that counts the number of rows as serial number, you can use the global variable in select statement.
Let us create a table. The query to create a table is as follows:
mysql> create table addColumnToCountAsSerialNumber
   -> (
   -> Id int,
   -> Name varchar(20),
   -> Age int,
   -> Salary int
   -> );
Query OK, 0 rows affected (0.80 sec)
Insert some records in the table using insert command. The query is as follows:
mysql> insert into addColumnToCountAsSerialNumber values(10,'John',23,8576);
Query OK, 1 row affected (0.10 sec)
mysql> insert into addColumnToCountAsSerialNumber values(12,'Carol',21,4686);
Query OK, 1 row affected (0.14 sec)
mysql> insert into addColumnToCountAsSerialNumber values(9,'Mike',22,38585);
Query OK, 1 row affected (0.11 sec)
mysql> insert into addColumnToCountAsSerialNumber values(15,'Sam',25,38586);
Query OK, 1 row affected (0.16 sec)
mysql> insert into addColumnToCountAsSerialNumber values(20,'Bob',26,43544);
Query OK, 1 row affected (0.17 sec)
mysql> insert into addColumnToCountAsSerialNumber values(39,'Larry',29,485886);
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from addColumnToCountAsSerialNumber ;
The following is the output:
+------+-------+------+--------+
| Id   | Name  | Age  | Salary |
+------+-------+------+--------+
|   10 | John  |  23 |    8576 |
|   12 | Carol |  21 |    4686 |
|    9 | Mike  |  22 |   38585 |
|   15 | Sam   |  25 |   38586 |
|   20 | Bob   |  26 |   43544 |
|   39 | Larry |  29 |  485886 |
+------+-------+------+--------+
6 rows in set (0.00 sec)
The following is the query to count each row as a serial number:
mysql> select @globalVar:=@globalVar+1 RowCount,tblColumns.*
   -> from (select @globalVar:=0) initializeGlobalVariable,addColumnToCountAsSerialNumber tblColumns;
The following is the output displaying the count in a new column “RowCount”:
+----------+------+-------+------+--------+
| RowCount | Id   | Name  | Age  | Salary |
+----------+------+-------+------+--------+
|        1 |   10 | John  |   23 |   8576 |
|        2 |   12 | Carol |   21 |   4686 |
|        3 |    9 | Mike  |   22 |  38585 |
|        4 |   15 | Sam   |   25 |  38586 |
|        5 |   20 | Bob   |   26 |  43544 |
|        6 |   39 | Larry | 29   | 485886 |
+----------+------+-------+------+--------+
6 rows in set (0.06 sec)
Latin Square in Python

The Latin square is a matrix that has a special pattern. Let's see different examples to examine the pattern.
1 2
2 1

1 2 3
3 1 2
2 3 1

1 2 3 4
4 1 2 3
3 4 1 2
2 3 4 1


The Latin square that you get will be of different size as you notice in the above examples. But, if you carefully observe the above matrices' pattern, you will find out that the last number of the previous row comes as the first element of the next row.
That's the pattern hidden in Latin square. We have to write the program that generates the above matrix for the input n.
Initialise the n with any number you like.
Initialise a number with the value n + 1 call it as first_half_end.
Write a loop that iterates from 1 to n both inclusive.Assign the value of first_half_end to a variable called first_half_start.Write a loop until first_half_start reaches to the value n.Print the iterating variable i.e.., first_half_start.Write a loop that iterates from 1 to first_half_end.Print the iterating variable.Decrement the value of first_half_end by 1.Move the next row.
Assign the value of first_half_end to a variable called first_half_start.
Write a loop until first_half_start reaches to the value n.Print the iterating variable i.e.., first_half_start.
Print the iterating variable i.e.., first_half_start.
Write a loop that iterates from 1 to first_half_end.Print the iterating variable.
Print the iterating variable.
Decrement the value of first_half_end by 1.
Move the next row.
Following is the implementation of the above algorithm in Python
def generateLatinSquare(n):
   first_half_end = n + 1

   for i in range(1, n + 1):
      first_half_start = first_half_end
      while (first_half_start <= n):
         print(first_half_start, end=" ")
         first_half_start += 1

      for second_half_start in range(1, first_half_end):
         print(second_half_start, end=" ")
      first_half_end -= 1
      print()
   print()

if __name__ == "__main__":
   generateLatinSquare(2)
   generateLatinSquare(3)
   generateLatinSquare(4)
If you run the above code, then you will get the following result.
1 2
2 1

1 2 3
3 1 2
2 3 1

1 2 3 4
4 1 2 3
3 4 1 2
2 3 4 1
Python | Convert location coordinates to tuple - GeeksforGeeks

29 Apr, 2022
Sometimes, while working with locations, we need a lot of data which has location points in form of latitudes and longitudes. These can be in form of a string and we desire to get tuple versions of same. Let’s discuss certain ways in which this task can be performed. 
Method #1 : 
Using tuple() + float() + split() + map() The combination of above functions can be used to perform this task. In this, we first split the two parts of coordinates into a list, apply float function to each of them using float() and map() and lastly it is converted to tuple using tuple(). 
Python3
# Python3 code to demonstrate working of# Convert location coordinates to tuple# Using tuple() + float() + split() + map() # Initializing stringtest_str = "44.6463, -49.583" # printing original stringprint("The original string is : " + str(test_str)) # Convert location coordinates to tuple# Using tuple() + float() + split() + map()res = tuple(map(float, test_str.split(', '))) # printing resultprint("The coordinates after conversion to tuple are : " + str(res))
The original string is : 44.6463, -49.583
The coordinates after conversion to tuple are : (44.6463, -49.583)
  Method #2 : 
Using eval() This is the one-liner and recommended method to perform this particular task. In this, the eval(), internally detects the string and converts to floating point number separated as tuple elements. 
Python3
# Python3 code to demonstrate working of# Convert location coordinates to tuple# Using eval() # Initializing stringtest_str = "44.6463, -49.583" # printing original stringprint("The original string is : " + str(test_str)) # Convert location coordinates to tuple# Using eval()res = eval(test_str) # printing resultprint("The coordinates after conversion to tuple are : " + str(res))
The original string is : 44.6463, -49.583
The coordinates after conversion to tuple are : (44.6463, -49.583)
rkbhola5
Python tuple-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?