<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sahil</title>
    <description>The latest articles on DEV Community by Sahil (@dotslashbit).</description>
    <link>https://dev.to/dotslashbit</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F416698%2F1d1674e4-09f8-4523-a09d-ea775b44c5d3.png</url>
      <title>DEV Community: Sahil</title>
      <link>https://dev.to/dotslashbit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dotslashbit"/>
    <language>en</language>
    <item>
      <title>NumPy 101: Learn NumPy in 10 minutes</title>
      <dc:creator>Sahil</dc:creator>
      <pubDate>Sat, 01 Apr 2023 04:23:44 +0000</pubDate>
      <link>https://dev.to/dotslashbit/numpy-101-learn-numpy-in-10-minutes-2fm8</link>
      <guid>https://dev.to/dotslashbit/numpy-101-learn-numpy-in-10-minutes-2fm8</guid>
      <description>&lt;p&gt;Numpy is a popular Python library for scientific computing and data analysis. It provides a powerful array object, along with many useful functions and methods for manipulating and processing numerical data. In this blog post, I will share some of the essential numpy operations that can help you write faster and cleaner code. Whether you are a beginner or an expert, I hope you will find something useful in this numpy cheat sheet.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Installation&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;If you dont have numpy, then first you need to install it. You can install it in two days:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Using pip&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install numpy

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Using Conda&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;First, activate your anaconda environment and then use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;conda install -c anaconda numpy

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  &lt;strong&gt;The Basics&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Before doing any operations using numpy, we need to import it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Scalar&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Lets start from the very basic and learn how to create scalar values of numpy class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# int type

python_int = 2
numpy_int = np.int32(2)
print(type(python_int)) # ---&amp;gt; &amp;lt;class 'int'&amp;gt;
print(type(numpy_int)) # ---&amp;gt; &amp;lt;class 'numpy.int32'&amp;gt;

# float type

python_float = 2.5
numpy_float = np.float32(2.5)
print(type(python_float)) # ---&amp;gt; &amp;lt;class 'float'&amp;gt;
print(type(numpy_float)) # ---&amp;gt; &amp;lt;class 'numpy.float32'&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more detail, take a look at the documentation &lt;a href="https://numpy.org/doc/stable/reference/arrays.scalars.html#" rel="noopener noreferrer"&gt;https://numpy.org/doc/stable/reference/arrays.scalars.html#&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, its time to move on to Arrays or Lists.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;1-D Array&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Lets now create a 1-D array using numpys &lt;code&gt;array()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# creating an 1-D array of int type

one_d_array_int = np.array([1,2,3]) 
print(one_d_array_int) # ---&amp;gt; output : [1 2 3]

# creating an 1-D array of float type

one_d_array_float = np.array([1.5,2.5,3.5])
print(one_d_array_float) # ---&amp;gt; output : [1.5 2.5 3.5]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;2-D Array&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Lets now create a 2-D array using numpys &lt;code&gt;array()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# 2-D int array

two_d_array_int = np.array([
                [1,2,3],
                [4,5,6],
                [7,8,9]
               ])
print(two_d_array_int) # ---&amp;gt; [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

# 2-D float array

two_d_array_float= np.array([
                [1.1,2.1,3.0],
                [4.1,5.1,6.1],
                [7.1,8.1,9.1]
               ])
print(two_d_array_float) # ---&amp;gt; [[1.1, 2.1, 3.0], [4.1, 5.1, 6.1], [7.1, 8.1, 9.1]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Get The Dimension of an Array&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now, lets learn how do you get the dimension of the any array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# If the array is a 1-D array, then it'll return 1
print(one_d_array_int.ndim) # ---&amp;gt; output : 1

# If the array is a 2-D array, then it'l return 2
print(two_d_array_int.ndim) # ---&amp;gt; output : 2

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Get The Shape of an Array&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
print(one_d_array_int.shape) # ---&amp;gt; output : (3,)

print(two_d_array_int.shape) # ---&amp;gt; output : (3, 3)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As, the &lt;code&gt;one_d_array_int&lt;/code&gt; is basically a vector, it returns the shape of a vector, whereas &lt;code&gt;two_d_array_int&lt;/code&gt; is a matrix which has 3 rows and 3 columns and thats why it returns the shape as (3, 3).&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Get the Data Type of an Array&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(one_d_array_int.dtype) # ---&amp;gt; output : dtype('int32')

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By default, its &lt;code&gt;int32&lt;/code&gt; and there are different size of &lt;code&gt;int&lt;/code&gt; in numpy that you can use to optimise your space consumption.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Manipulating Elements of an Array&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Lets create a new array and then we will perform operations on this new array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = np.array([[1,2,3,4,5,6,7],[8,9,10,11,12,13,14]])
print(a) # ---&amp;gt; output : [[1 2 3 4 5 6 7]
# [8 9 10 11 12 13 14]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Access a Specific Element&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Lets say we want to access first rows third element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# accessing 1st row's 3rd element
print(a[0,2]) # ---&amp;gt; output : 3

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In numpy to access a specific element then, we first need to specify the &lt;strong&gt;row&lt;/strong&gt; and then the &lt;strong&gt;column&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Remember, numpy also follows the 0-based indexing and due to this if we want to get the first row, we need to write 0 and not 1 and same goes for the column value if we needed the third element, then well write 2 and not 3.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Access only a specific row or column&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# accessing only the first row
print(a[0,:]) # ---&amp;gt; output : [1 2 3 4 5 6 7]

# accessing only the second column
print(a[:,1]) # ---&amp;gt; output : [2 9]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Access elements with skip steps&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# [startindex:endindex:stepsize]
print(a[0, 1:-1:2]) # ---&amp;gt; output : [2 4 6]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you are accessing first rows columns from 2nd column to the last column by accessing every 2nd column.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Changing elements value&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a[0,2] = 99
print(a) # ---&amp;gt; output : [[1 2 99 4 5 6 7]
# [8 9 10 11 12 13 14]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you first assigned the value &lt;code&gt;99&lt;/code&gt; to the first rows third column.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Special Arrays in Numpy&lt;/strong&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Zero Matrix&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# creating a zero matrix of shape(2,3)

print(np.zeros((2,3))) # ---&amp;gt; output : [[0. 0. 0.]
 # [0. 0. 0.]
 # [0. 0. 0.]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;strong&gt;2&lt;/strong&gt; is the &lt;strong&gt;number of rows&lt;/strong&gt; and &lt;strong&gt;3&lt;/strong&gt; is the &lt;strong&gt;number of columns.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;One Matrix&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# All 1s matrix
print(np.ones((3,2,2))) # ---&amp;gt; output : [[[1. 1.]
# [1. 1.]]
#
# [[1. 1.]
# [1. 1.]]
#                                      
# [[1. 1.]
# [1. 1.]]]

# creating ones matrix int type
print(np.ones((3,2,2)), dtype='int32') # ---&amp;gt; output : [[[1 1]
# [1 1]]
#
# [[1 1]
# [1 1]]
#                                      
# [[1 1]
# [1 1]]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, you are creating a matrix of ones. If you dont specify any data type then itll by default generate float type elements.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Random Array&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to have an array having random values of a specific shape, then you can use &lt;code&gt;np.random.rand()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(np.random.rand(3,3)) # ---&amp;gt; output : [[0.10671372 0.31133182 0.56572354]
# [0.34792672 0.88867917 0.25310353]
# [0.70052117 0.53243035 0.67948057]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Random Array ( Only Integer Values )&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to have an array having random int values of a specific shape, then you can use &lt;code&gt;np.random.randint()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# np.random.randint(start_value,end_value,size)

print(np.random.randint(-1,5, size=(3,3))) # ---&amp;gt; output : [[0 -1 2]
# [4 2 1]
# [4 4 0]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;start_value&lt;/code&gt; is inclusive thats why -1 is there in the output array.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;end_value&lt;/code&gt; is exclusive thats why there is no 5 in the output array.&lt;/p&gt;

&lt;p&gt;If you dont mention the &lt;code&gt;start_value&lt;/code&gt;, then the default start value would be 0. You have to mention the &lt;code&gt;end_value&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Identity Matrix&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to create an Identiity matrix, then you can use &lt;code&gt;np.identity()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(np.identity(3)) # ---&amp;gt; output : [[1. 0. 0.]
# [0. 1. 0.]
# [0. 0. 1.]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have to mention the &lt;code&gt;number_of_dimensions&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Transposing Array&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = np.random.randint(-1,5, size = (2,3)) # creating a random int array
print(a) # output : [[2 -1 1]
                                          # [0 1 1]]

print(a.T) # output : [[2 0]
                                          # [-1 1]
                                          # [1 1]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Reshape Array&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to change the shape of the array you can use &lt;code&gt;reshape()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = np.random.randint(-1,5, size = (2,3)) # creating a random int array
print(a) # output : [[2 -1 1]
                                          # [0 1 1]]

print(a.reshape(3,2)) # output : [[2 0]
                                          # [-1 1]
                                          # [1 1]]

print(a.reshape(1,6)) # output : [[1 2 3 2 2 2]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Note : You cant reshape&lt;/em&gt; &lt;code&gt;(2,3)&lt;/code&gt; array to &lt;code&gt;(3,3)&lt;/code&gt; as the original array has &lt;code&gt;6&lt;/code&gt; cells while the new shape you want to have has &lt;code&gt;9&lt;/code&gt; cells.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Fill with Any Number&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to have an aray filled with a specific value, then you can use &lt;code&gt;np.full()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;print(np.full((3,3), 14)) # ---&amp;gt; output : [[14 14 14]
# [14 14 14]
# [14 14 14]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;Fill Like&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to have an array with a specific value and you want it to be of same shape as some other array, then you can use &lt;code&gt;np.full_like()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Any other number (full_like)
print(np.full_like(a, 4)) # ---&amp;gt; output : [[4 4 4 4 4 4 4]
# [4 4 4 4 4 4 4]]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method takes the shape of the mentioned array and a value, then it creates a new array of the same shape with the given value.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Copy Array&lt;/strong&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = [1,2,3] # created an array a
b = [10,20,30] # created an array b
print(a) # output : [1 2 3]
a = b # I'll explain it below
b[1] = 200 # changed b's 2nd element's value to 200
print(a) # output : [10 200 30] HOW??????

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lets first understand what happened here : &lt;code&gt;a = b&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here, the values of &lt;code&gt;b&lt;/code&gt; didnt get copied to &lt;code&gt;a&lt;/code&gt;, instead &lt;code&gt;a&lt;/code&gt; starts to point to &lt;code&gt;b&lt;/code&gt; which in-turn changes the values of a but the catch is that whenever youll change something in &lt;code&gt;b&lt;/code&gt; the same will reflect on &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Stacking Arrays&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to stack multiple arrays vertically or horizontally, you can use &lt;code&gt;vstack()&lt;/code&gt; method or &lt;code&gt;hstack()&lt;/code&gt; method respectively.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Vertically stacking vectors
v1 = np.array([1,2,3,4]) # created array v1
v2 = np.array([5,6,7,8]) # create array v2

np.vstack([v1,v2,v1,v2]) # output : [[1 2 3 4]
                                        # [5 6 7 8]
                                        # [1 2 3 4]
                                        # [5 6 7 8]]
print(np.hstack([v1,v2])) # output : [1 2 3 4 5 6 7 8]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  &lt;strong&gt;Aggregate Functions&lt;/strong&gt;
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = np.array([1, 2, 3])
print(a.sum()) # sum of all values of a
print(a.max()) # max of all elements of a
print(a.mean()) # return mean of a
print(np.median(a)) # return median of a
print(np.std(a)) # return standard deviation of a

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;This concludes our numpy cheatsheet blogpost. We hope you found it useful and learned some new tricks to work with arrays and matrices in Python. Numpy is a powerful and versatile library that can help you perform various numerical computations and data analysis tasks. If you want to learn more about numpy, you can check out the official documentation or some of the online tutorials and courses available. Thank you for reading and happy coding!&lt;/p&gt;

</description>
      <category>python</category>
      <category>numpy</category>
      <category>datascience</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>What's new in Python 3.9</title>
      <dc:creator>Sahil</dc:creator>
      <pubDate>Mon, 20 Jul 2020 14:46:56 +0000</pubDate>
      <link>https://dev.to/dotslashbit/what-s-new-in-python-3-9-2heg</link>
      <guid>https://dev.to/dotslashbit/what-s-new-in-python-3-9-2heg</guid>
      <description>&lt;p&gt;A new version of Python is coming! Soon, we'll be using it in our python projects. As of 20/07/2020 Python 3.9 is in beta version(3.9.0b4) and will release the full version of Python 3.9 pretty soon.&lt;/p&gt;

&lt;p&gt;Enough of introduction. Let's get started and learn about the new features.&lt;/p&gt;

&lt;h1&gt;
  
  
  New features in Python 3.9
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Dictionary merge and update operators
&lt;/h2&gt;

&lt;p&gt;Python 3.9 introduces merge(|) and update(|=) operators in the dict class. If you have two dictionaries a and b, you can now use these operators to do merge and update them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = {1: "Sam", 2: "Alex"}
b = {3: "Daniel", 4: "Tom", 5: "Jimmy"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use | to merge these both dictionaries.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;c = a|b
print(c)

**[Output]**: {1: "Sam", 2: "Alex", 3: "Daniel", 4: "Tom", 5: "Jimmy"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If both the dictionaries have a common key, then the output will display the second key-value pair.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = {1: "Sam", 2: "Alex", 3: "James"}
b = {3: "Daniel", 4: "Tom", 5: "Jimmy"}

c = a|b
print(c)

**[Output]**: {1: "Sam", 2: "Alex", 3: "Daniel", 4: "Tom", 5: "Jimmy"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For updating the dictionary, you can use the following operator.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = {1: "Sam", 2: "Alex"}
b = {2: "Daniel"}
a|=b
print(a)

**[Output]: {1: "Sam", 2: "Daniel"}**
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  removeprefix() and removesuffix() string methods
&lt;/h2&gt;

&lt;p&gt;In Python’s str class, the new update introduces new &lt;code&gt;removeprefix()&lt;/code&gt; and &lt;code&gt;removesuffix()&lt;/code&gt; methods.&lt;/p&gt;

&lt;p&gt;You can remove the prefix from any string using the &lt;code&gt;removeprefix()&lt;/code&gt; method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'HelloWorld'.removeprefix('Hello')
**[Ouput]: 'World' **
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the string doesn’t start with the input prefix, the copy of the original string will be returned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'BaseTestCase'.removeprefix('Test')
**[Ouput]: 'BaseTestCase' **
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the string ends with input suffix, the output will look like &lt;code&gt;string[:-len(suffix)]&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'MiscTests'.removesuffix('Tests')
'Misc'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the input suffix is empty or the string doesn’t end with it, the output will be a copy of the original string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'BadTestCase'.removesuffix('Tmp')
'BadTestCase'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  New parser
&lt;/h1&gt;

&lt;p&gt;Python 3.9 uses a new parser which is a PEG-based parser. Previously, Python used LL(1). PEG is more flexible than LL(1) when it comes to building new features in the language. The official documentation says that this flexibility will be seen in Python 3.10 and later.&lt;/p&gt;

&lt;h1&gt;
  
  
  Type hinting
&lt;/h1&gt;

&lt;p&gt;Python dynamically specifies datatypes to a variable. For static allocation of data types, type hinting is used. This was introduced in Python 3.5.&lt;br&gt;
You can now use built-in collection types (&lt;code&gt;list&lt;/code&gt; and &lt;code&gt;dict&lt;/code&gt; ) as generic types. Earlier, you had to import the capital types (&lt;code&gt;List&lt;/code&gt; or &lt;code&gt;Dict&lt;/code&gt;) from &lt;code&gt;typing&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def greet_all(names: list[str]) -&amp;gt; None:
    for name in names:
        print("Hello", name)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now there is no need to call &lt;code&gt;List&lt;/code&gt; from &lt;code&gt;typing.List&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>coding</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
