Thursday, June 30, 2022

What are boolean expressions?

The boolean expression is expression that can be True or False. There are multiple operators wich can be used to obtain boolean expression. First we are going to use "==" operator to see if two variables are equal or not. If they are equal the result will be True, and if they are not equal the result will be False.
Example 1 Test following expressions 4 == 40, 2 == 10, 4 == 4, 3 == 4, 5==5 and print the output.
Solution: Each expression will be tested inside print function. The form is to formulate string in form of "Is 5 = 5?" separated with comma and after that type the expression. The example of the print function formulation is shown for first expression (4 == 40).
print("Is 4 = 40?, 4 == 40)
Since 4 is not equal to 40 the result will be False. The other problems in this example are written in the same way. The entire code for this example is given below.
print("Is 4 = 40 ? ", 4==40)
print("Is 2 = 10 ? ", 2==10)
print("Is 4 = 4 ?", 4==4)
print("Is 3 = 4 ?", 3==4)
print("Is 5 = 5 ?", 5==5)
In this example we used the operator "==" which compares two operands and produces True if the two numbers are equal, and False if they are not equal. In first case we have two numbers 4 and 40. They are not equal so the output is False. In second line we have 2 and 10 and they are not equal so the output is false. In third line we compared two numbers 4 and 4 and the output is True. In fourth line of code the numbers are 3 and 4 and they are not equal so the output is False. In the last line of code we have two equal numbers (5 and 5) so the output is True. When the previous code is executed the obtained output is given below.
Is 4 = 40 ?  False
Is 2 = 10 ? False
Is 4 = 4 ? True
Is 3 = 4 ? False
Is 5 = 5 ? True
The True and False values are special values that belong to the type bool; they are not strings. To verify this we will use the type function and investigate the type of True and False.
print(type(True))
print(type(False))
The output is given below.
<type 'bool'>
<type 'bool'>
Besides the "==" operator there are other comparison operators and they are given in Table 1.
Table 1 - List of operators used to obtain boolean expressions
OperatorDescription
x == yx is equal to y
x != y x is not equal to y
x > yx is greater than y
x < yx is less than y
x >= yx is greater than or equal to y
x <= yx is less than or equal to y
x is yx is the same as y
x is not yx is not the same as y
Example 2 Test the following expressions and show the output using print function. The expression are:
  • 4 != 5,5 != 5
  • 2 < 6, 18 < 3
  • 14 > 12, 2 > 4
  • 12 >= 3, 4 >= 20
  • 14 <= 4, 2 <= 12
  • 30 is 20, 40 is 40
  • 20 is not 12, 12 is not 25
Solution: The output will be generated in the same way as it was generated in Example 1. The print function will consist of string and expression that are separated with comma.
print("4 != 5 is", 4 != 5)
print("5 != 5 is", 5 != 5)
print("2 < 6 is", 2 < 6)
print("18 < 3 is", 18 < 3)
print("14 > 12 is", 14 > 12)
print("2 > 4 is ", 2 > 4)
print("12 >= 3 is", 12 >= 3)
print("4 >= 20 is", 4 >= 20)
print("14 <= 4 is", 14 <= 4)
print("2 <= 12 is", 2 <= 12)
a = b = 30; c = 20
print("a = b =",a)
print("c =", c)
print("a is c? ", a is c)
print("a is b? ", a is b)
print("a is not b ", a is not b)
print("a is not c ", a is not c)
In the first code line print("4 != 5", 4 != 5) the Python will test the expression and see if 4 != 5. The operator != means not equal. In our case 4 is not equal to 5 so the output will be True. In the second code line print("5 != 5 is", 5 != 5). This expression will be Flase since 5 is equal to 5 and we are testing 5 != 5 (five not equal to 5). In third code line print("2 < 6 is ", 2 < 6) the Python will test if 2 < 6 or in words: if 2 is less than 6. Since 2 is less than 6 the return value will be True. In fourth code line print("18 < 3 is", 18 < 3) the Python will test if 18 < 3 or in words: if 18 is less than 3. Since 18 is greater than 3 the return value will be False. In fifth line print("14 > 12 is", 14 > 12) the Python will test and show the output of the expression 14 > 12 (is 14 greater than 12?). since 14 is greater than 12 the result will be True. In sixth code line print("2 > 4 is", 2 > 4) we want to see if 2 is greater than 4. Since 2 is less than 4 the return result will be False. In seventh code line print("12 >= 3 is", 12 >= 3) we want to see if 12 is greater then or equal to 3. Since 12 is greater than 3 the return result will be True. In eighth code line print("14 <= 4 is", 14 <= 4) we want to know is 14 less than or equal to 4. Since 14 is greater than 4 the reutrn result will be False. In ninth code line print("2 <= 12 is", 2 <= 12) we want to know if 2 is less then or equal to 12. Since 2 is less than 12 the expression is True.
To test the is and is not operators we have to define variables and assign values to those variables. The is operator is the identity operator thet checks whether both the operands refer to the same object or not. Two operands have to be present in the same memory location so that is value is Ture. In tenth line we have assigned one value (30) to two variables (a and b), and we have assinged a value of 20 to the variable c. In twelvth line we printed out the values of a and b, and in thirteenth code line we have created a code to show the output of variable c using print function. In fourtheenth line print("a is c?, a is c) we want to know if variable a is variable c. Since both variables are not stored in the same memory location the result of this test will be False. In fiftheenth line print("a is b?", a is b) we want to know if a is b. The result will be True since both a and b are stored in the same memory location. Finally in sixteenth and seventeenth code line we are testing the "is not" operator. This operator is inverse of is operator which means that if two variables are not stored at same memroy location the output will be True, and if the two values are stored at same location the result will false. In sixteenth line of code print("a is not b ", a is not b) will return "a is not b False" since a and b are stored at the same memory location. In the seventeenth line of code print("a is not c", a is not c) the result will be "a is not c True" since a and c are stored at different memory locations which confirms expression a is not c. The output is given below.
4 != 5 is True
5 != 5 is False
2 < 6 is True
18 < 3 is False
14 > 12 is True
2 > 4 is False
12 >= 3 is True
4 >= 20 is False
14 <= 4 is False
2 <= 12 is True
a = b = 30
c = 20
a is c? False
a is b? True
a is not b False
a is not c True

Monday, June 27, 2022

How to create variables in Python?

In this post we are going to explore what are variables, how to create them, how to assign values to variables, what values and types of values exists.

What Values and type of values exist in Python ?

The value is one of the basic things a program works with. Some values that you have seen in previous examples so far are: 3, 15, 4, 6 and "Hello World!", "This is my first Python program.". The previously given value examples belong to different types. The numbers 3, 15, 4, and 6 are integers. "Hello, World!", and "This is my first Python program." are strings. The strings are enclosed by quotation marks.
Example 1 Investigate a value type for following values 3, 15, 4, 6, "Hello World!", and "This is my first Python program."
Solution: To investigate value type the Python has built-in function "type" so we will use this function for each value.
print("type(3) = ", type(3))
print("type(15) = ", type(15))
print("type(3) = ", type(3))
print("type(6) = ", type(6))
print("""type("Hello World!") = """, type("Hello World!"))
print("""type("This is my first Python program.") = """, type("This is my first Python program."))
The previous lines code are pretty simple. All of them start with the built in function print followed by the command type() in string type and then actual type command. The only novelty in the previous code block is string with three ". The """ """ are usually used when we want to create multiline strings or there are another pair of " " inside the strings. Since in the string "type("Hello World!")" we have one pair of " " inside the string we have to use """ """. The output of the previous block of code is shown below.
type(3) =  <class 'int'>
type(15) = <class 'int'>
type(4) = <class 'int'>
type(6) = <class 'int'>
type("Hello World!") = <class 'str'>
type("This is my first Python program.") = <class 'str'>
As seen from previous output the four numbers 3, 15, 4 and 6 are integers (class 'int') while "Hello World!" and "This is my first Python program." are strings (class 'str'). On the other hand the numbers with decimal point are of float type. However, if we type '17' or '3.2' although they look like numbers they are strings.
Example 2 Investigate the value type of 3.5, 6.3, 13.8, '178.4', 30, and '30'.

Solution: As in previous example we will use built-in type function to investigate value type and print function the print the result.
print("type(3.5) = ",type(3.5))
print("type(6.3) = ",type(6.3))
print("type(13.8) = ",type(13.8))
print("""type('178.4') = """,type('178.4'))
print("type(30) = ", type(30))
print("""type('30') = """, type('30'))
The result of previous code is shown below.
type(3.5) =  <class 'float'>
type(6.3) = <class 'float'>
type(13.8) = <class 'float'>
type('178.4') = <class 'str'>
type(30) = <class 'int'>
type('30') = <class 'str'>
As seen from previous output the numbers 3.5, 6.3 and 13.8 are floats, the '178.4' and '30' are strings, and 30 is integer. The video showing solutions to Example 1 and 2 is given below.

How to define variables and assign values to them?

Variable manipulations are one of the most powerful features of any programming language. A variable is a name that refers to a value. An assignment statement creates new variables and gives them values. In general form the assignment statement can be written as:
variable_name = value
Example 3 Create new variables for following values: 56.124, "This is just an info.", 40, and 50. Display their values using print function and check the type of each variable.
a = 56.124
info = "This is just an info."
b = 40
c = 50
In this example we have created four assignments. In first assignment the float number 56.124 is assigned to variable name \(a\). In second assignment the string "This is just an info." is assigned to variable name \(info\). In the third assignment the integer number 40 is assigned to variable named \(b\). In the fourth and last assignment the integer number 50 is assigned to variable named \(c\). Each variable will be displayed using print function, so type in the following lines of code.
print("a = ", a)
print("info = ",info)
print("b = ",b)
print("c = ", c)
After runing the entire script the following ouput is obtained.
a =  56.124
info = This is just an info.
b = 40
c = 50
To find out the type of each variable we will use the type function and the print function.
print("type(a) = ",type(a))
print("type(info) = ",type(info))
print("type(b) = ",type(b))
print("type(c) = ",type(c))
The output of the previous block of code is given below.
type(a) =  <class 'float'>
type(info) = <class 'str'>
type(b) = <class 'int'>
type(c) = <class 'int'>
All previous information about variable definition is shown in following video.

How to perform multiple assignment?

In Python you can assign single value to a several variables simultaneously and you can assign multiple objects to multiple variables. The general form of assinging multiple variables to same value can be written as:
variable_name_1 = variable_name_2 = variable_name_3 = value
In this case all three variables i.e. variable_name_1, variable_name_2, and variable_name_3 all have same value value. The general form of assigning multiple variables to multiple values can be written as:
variable_name_1, variable_name_2, variable_name_3 = value_1, value_2, value_3
In this case the value_1 is assigned to variable_name_1 the value_2 is assigned to variable_name_2 and value_3 is assigned to variable_name_3.
Example 4 Assign value of 1 to variable \(a,b,c\) and asign values 50, 600, "This is the end" to variables \(d, g\), and \(h\).
Solution:
a = b = c = 1
d,g,h = 50, 600, "This is the end"
In first code line the integer object is created with the value of 1 and all three variables are assigned to the same memory location. In second line of code two integer objects with values 50 and 600 are asigned to the variables \(d\) and \(g\), and one string object with the value "This is the end" is assigned to the variable \(h\). To show the value of each variable we will use print function.
print("a = ",a)
print("b = ",b)
print("c = ",c)
print("d = ",d)
print("g = ",g)
print("h = ", h)
Output:
a =  1
b = 1
c = 1
d = 50
g = 600
h = This is the end.
The video on how to perform multiple variables assingment in Python is given below.

How to name variables in Python?

When naming variables you should choose names that are meaningful and document what the variable is used for. The name of the variable can be arbitrarly long, it can be created using uppercase letters, it can contain underscore character (_) , it can contain letters and numbers. However, the variable cannot start with a number.
Example 5 Create following variables 100miles, this@, and del and assign to them some values.
100miles = "Big Truck"
this@ = 47
del = "The Big Bang"
The problem with previous block of code that each line will generate SyntaxError: invalid syntax. The 100miles is illegal because the variable name should not begin with the number. The this@ is illegal since it contains character, and del is illegal since is one of Python's keywords. The Python interpreter uses keywords to recognize program structure so they cannot be used as a variable names. The Python 31 keywords that should not be used as variable names are given in Table 1.
and del from not while
as elif global or with
assert else if pass yield
break except import print class
exec in raise continue finally
is return def for lambda
try
The video tutorial on how to name variables in Python is shown below.

How to solve simple math problems in Python?

Python programming language like any other programming language has a way of solving simple math problems. The basic math operations that are integrated in Python are: addition (+), subtraction (-), multiplication (*), division (/), power (**), modulo (%), less-then (<), greater-than (>), less-than-equal (<=), greater-than-equal (>=). These operations are used without any library import. Python has a built-in library called math which has all commonly used math functions. However, here we are investigating simple math operations without the help of any library.
Example 1 Solve the following simple mathematical problems and print their solution.
  • 3 + 15 = ?
  • 4*6-3 = ?
  • 3*7 + 4*8 = ?
  • 3**2 - 4**3 = ?
  • 9**(1/2) + 27**(1/3) = ?
  • (10%12) - (3%4) = ?
  • 5+3 < 4+8
  • 50 > -20
  • 30 >= -4
  • 10 <=-4
Solution:
print("3 + 15 = ",3+15)
print("4 * 6 - 3 = ", 4*6-3)
print("3 * 7 - 4 * 8 = ", 3 * 7 - 4 * 8)
print("3**2 - 4**3 = ", 3**2 - 4**3)
print("9**(1/2) + 27**(1/3) = ", 9**(1/2) + 27**(1/3))
print("(10%12) - (3%4) = ",(10%12) - (3%4) )
print("Is 5 + 3 less than 4 + 8", 5+3 < 4+8)
print("Is 50 greater than -20?", 50 > -20)
print("Is 30 greater or equal to -4?", 30 >= -4)
print("Is 10 less or equal to -4?", 10 <= -4)
The output of previous code is given below.
3 + 15 =  18
4 * 6 - 3 = 21
3 * 7 - 4 * 8 = -11
3**2 - 4**3 = -55
9**(1/2) + 27**(1/3) = 6.0
(10%12) - (3%4) = 7
Is 5 + 3 less than 4 + 8 True
Is 50 greater than -20? True
Is 30 greater or equal to -4? True
Is 10 less or equal to -4? False
In the previous example, we saw that it is possible to use basic mathematical operations without the need to call any library. In the following example, we will show the calculation of potencies and roots also without the need to import any Python libraries.
Example 2 Calculate the following mathmatical problems. \begin{eqnarray} 2^2 &=&?\nonumber\\ 2^2 + 3^2 &=& ? \nonumber\\ 4^2 - 3^2 + 2^2 &=& ? \nonumber\\ \sqrt{64} &=& ?\nonumber\\ \sqrt{256} - \sqrt{196} &=& ?\nonumber\\ \sqrt[3]{1000} &=& ? \end{eqnarray}
Solution: The potencies are written with two asterix sign so if we have to write \(2^2\) in Python we will write 2**2. The roots will be written in form of potencies in the form of fractions. For example \(\sqrt{64}\) in Python it will be written as 64**(1/2). All the expressions will be solved/written inside the print function just like in the Example 1.
print("2**2 = ",2**2)
print("2**2 + 3**2 = ",2**2+3**2)
print("4**2 - 3**2 + 2**2 = ",4**2-3**2+2**2)
print("64**(1/2) = ",64**(1/2))
print("256**(1/2) - 196**(1/2) = ",256**(1/2)-196**(1/2))
print("1000**(1/3) = ",round(1000**(1/3),2))
The output of previous code is given below.
2**2 =  4
2**2 + 3**2 = 13
4**2 - 3**2 + 2**2 = 11
64**(1/2) = 8.0
256**(1/2) - 196**(1/2) = 2.0
1000**(1/3) = 10.0
The output in this example is pretty straightforward. The most interesting part of this example is the last command line in which we calculated the \(\sqrt[3]{1000}\). The result of this code is 10 since 10*10*10 is equal to 1000. However, without the use of the round function, the result was 9.9999998. The round function is a built-in Python function that returns a floating-point number that is the rounded version of the specified number, with the specified number of decimals. Since the result was near 10 i.e. 9.99998 using the round function we rounded the number to 10.0. The general form of the round function can be written as:
round(number, number_of_decimals)
So the first argument is the number that we want to round up, and the second argument is the number of decimals that the rounded number will contain. The default number of decimals is 0, which means that the function will return the nearest integer.

How to write comments in Python?

When writing a script in Python programming language it is suggested that you write comments. Comments are very important since they give you additional information about what a specific line of code or chunk of code does. During the program development, it is good practice to sometimes comment on the parts of code to provide additional information. Example 1 Create a script and write the following code.
#This is the first comment that I'm going to create.
#After typing first # everything is ignored by Python
print("This is the first line of code that Python can execute.")
# You can put a comment right after the code and it will be ignored by Python
# The comments can be used to disable lines of code.
#To disable the line of code simply put # before the line of code.
#print("This will not be executed in Python")
print("This # will be executed.")

Solution: After creating a script and running it the following output will be produced.
This is the first line of code that Python can execute.
This # will be executed.
When the script and the output are compared it can be noticed that all the lines that started with # were skipped by Python.
As you can see Python has executed two print commands and as output shows only the strings inside the parenthesis of print functions. In Spyder the hashtag sign (#) can be created by pressing Ctrl and 1 simultaneously, or by pressing SHIFT + 1

How to create comments in multiple lines?

To create a comment in multiple lines each line has to begin with #. In Example 1 first two lines of code are comments and each line begins with #. So to create comments in multiple lines each line has to begin wtih the character #.

Why is the # -*- coding: utf-8 -*- skipped?

Every time you create a new Python script in Python the script will contain the following lines of code.
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 23 12:38:08 2022

@author: user
"""
This code contains the line # -*- coding: utf-8 -*- which starts with sign for comments (#). Apparently the Python ignores that as the code however, a "hack" (workaround) for problems is developed for problems with setting and detecting the format of a file.
The UTF-8 is commonly used encoding, and Python defaults to using it. The UTF stands for Unicode Transformation Format and number 8 represents the 8-bit values are used for encoding.

How come the string "This # will be executed" is shown as output?

This line was a string inside the parenthesis of print function which means that is treated as a string so the sign here does not have influece, i.e. does not create a comment. # sign is treated as a string since it is inside the string.

Writing your first program in Python.

The first Python program that we are going to create will consist of only print built-in function. After the program is written the different procedures of running your first Python program will be shown. To write your first program simply use txt editor such as Notepad or Notepad++ on your operating system and save the file with .py extension.
Example 1 Create the Python script that will print out the following sentences:
  • Helo World!
  • This is my first Python Program.
  • Programming in Python is awesome!!!!
  • There's a long way to the programming expert if you like Python programming language.
  • The end of my Python program. Goodbye.
Name the script as "My_1._Py_Program.py".
Solution: Using Notepad or Notpead++ or Visual Studio code or any other simple text editor open New file and type in the following code:
print("Hello World!")
print("This is my first Python Program.")
print("Programming in Python is awesome!!!!")
print("There's a long way to be a programming expert if you like Python programming language.")
print("The end of my Python program. Goodbye.")
As seen from the previous block of code the only function that was used is the print function. The print is the built-in Python function that prints the specified message to the screen, or another standard output device. The message inside the function can be a string or any other object since it will be converted to a string before it is shown on the screen. As already mentioned in the description of Exercise 1 save the file as "My_1._Py_Program.py".

How to run your first program/Python script?

There are mutltiple ways to run Python script and here some of them will be covered.
  • Run your first python script from CommandPrompt or Terminal.
  • Run your first python script from Spyder.
  • Run your first python script from Ipython.
  • Run your first python script from Visual Studio Code.

Run your first python script from Command Prompt or Terminal.

To run the script from Command Prompt on Windows or Terminal on Linux operating system you have to navigate to directory of your saved Python script and then type in the following code.
python My_1._Py_Program.py
The first word is the name of the program that we are trying to call i.e. Python and the second is the name of the Python script. In newer versions of Python you have to write py instead of python.
py My_1._Py_Program.py
Either way the output of the My_1._Py_Program.py is given below.
Hello World!
This is my first Python Program.
Programming in Python is awesome!!!!
Ther's a long way to the programming expert if you like Python programming language
The end of my Python program. Goodbye.

How to run your first Program from Spyder?

To run your first Python script from Spyder first you need to open it. In Windows operating system if you have installed Anaconda distribution go to Start Menu then open Anaconda3 (64-bit) and click on the icon Spyder (Anaconda 3) and double click on it. When the Spyder program opens go to File->Open and navigate to a folder where you saved your "My_1._Py_Program.py". Then select the script and click Open. To run it just press F5 on your keyboard or click on the play button in the Toolbar. The output of the running script in the Spyder is given below.
Hello World!
This is my first Python Program.
Programming in Python is awesome!!!!
Ther's a long way to the programming expert if you like Python programming language
The end of my Python program. Goodbye.
Instead of going to File -> Open we could click on the Open icon in the toolbar and navigate to a folder where you saved your Python script.

How to run Python script from IPython?

To run the script from IPython first you need to open the IPython program. In Windows operating system if you installed the Anaconda distribution of Python, go to Start Menu and type IPython. When you find it double-click on it to open it. After the IPython is opened you have to import os library which will be used to write a file path where you saved your Python script and then you can run your Python script by typing the %run My_1._Py_Program.py. The entire code on how to run a python script is given below.
import os
filepath = "C:\\Users\\User\\FolderWithPythonScript"
os.chdir(filepath)
%run My_1._Py_Program.py
With use of os.chdir(filepath) command we have changed current working directory of IPython session. If you want after os.chdir(filepath) you can write os.getpwd() to see current working directory. After os.chdir(filepath) using %run command we have run the Python script. The output of the script is given below.
Hello World!
This is my first Python Program.
Programming in Python is awesome!!!!
Ther's a long way to the programming expert if you like Python programming language
The end of my Python program. Goodbye.

How to run python script from Visual Studio Code ?

To run the Python script from Visual Studio Code first you have to isntall the Visual Studio Code. After it is installed you have to install Python Extension or if you already installed Anaconda distribution of Python create connection with VSCode.

How to install Python Extension on VSCode ?

If you want to install Python Extension click on the link. Along with the Python extension, you need to install a Python interpreter. To install Python interpreter click on the link.

How to connect Anaconda with VSCode?

If you already have the Anaconda distribution of Python and want to connect it with VSCode then we want to make VSCode recognize the Anaconda installation so it can access installed packages for autocomplete, syntax highlighting, and error checking. VSCode should automatically recognize Anaconda. The proof of VSCode recognition of installed Anaconda would be the notification "Python 3.x ('base': conda)" in the lower-left corner of VSCode.
If for some reason you don't see the notification then press CTRL+SHIFT+P and type select interpreter. You should see "Python: Select Interpreter". If the Python interpreter is not visible then you have to find "Enter Interpreter Path" and then click on Find. This will be File Explorer and you have to find the location where you installed the Anaconda environment. In File Explorer, you have to find and select "python.exe" and that's it.
To run our first script you have to open it inside VSCode and click on the Play button which will automatically run our script. The output is shown below.
Hello World!
This is my first Python Program.
Programming in Python is awesome!!!!
Ther's a long way to the programming expert if you like Python programming language
The end of my Python program. Goodbye.

Conclusion

As seen in this post we have written our first Python script and run it using Command Prompt, Spyder, IPython, and VSCode. In the further posts we will be developing and executing Python scripts in Spyder.

Sunday, June 26, 2022

How to install Python programming language?

To install Python programming language only, simply type in your Web browser https://www.python.org/downloads/ or click on the link.
Figure 1 - Download page for Python

As seen from Figure 1 there is a Download button and by clicking on it you will download an Python installer (.exe) format for Windows operating system. If you are not using Windows operating system such as Linux/UNIX, macOS or Other then you should download an isntaller for specific operating system. Currently the latest version of Python programming language is 3.10.5 and since we are using Windows operating system we will click the button Download Python 3.10.5 and wait until the .exe file is downloaded.
Figure 2 - Downloaded python-3.10.5-amd64.exe

To run the installation process of Python programming language go to a folder where you downloaded the python-3.10.5-amd64.exe and double click on it. The window should appear "Open File - Security Warning" asking you Do you want to run this file? -> click Run. After clicking Run the new window entitled "Python 3.10.5 (64-bit) Setup" should appear.
Figure 3 - Python 3.10.5 (64-bit) Setup window
In this window you can see there are two different installation options. The first option is named "Install Now" option which will install Python programming language using default settings. The second option is the "Customize installation" where you can configure Python isntallation i.e. define installation location and select/deselect features. There are two additional options down below where one is to Install launcher of all users (recommended) and the other is to Add Python 3.10 to PATH. Both options should be checked. The first option is important since it will allow to run the Python without asking administration privilages. The second one is to allow Python setup to automatically add the Python 3.10 to Path which will allow you to run the Python from Command Prompt of Windows Shell after Python installation. After choosing the Install Now option as well as Install launcher of all users (recommended) and Add Python 3.10 to PATH.
Figure 4 - Python 3.10.5 (64-bit) Setup Progress
After setup is successfully completed the window with "Setup was successful" should appear. To finish the installation click Close.
Figure 5 - Python 3.10.5 (64-bit) Setup was successful

How to install Anaconda distribution?

To install latest Anaconda distribution (Python distribution platform) go to Anaconda.com and on the top navigation menu select Products and then click Anaconda Distribution. On this page click on Download button to Download the latest version of Anaconda distribution for Windows operating system.
Figure 1 - Anaconda distribution download page
There are of course the additional installers available for other operating systems. To find other installers click on the icons below the Get Additional Installers on icon of operating system you have. As seen from figure three icons are available Windows, MacOS and Linux. Since we are using Windows operating system we will click on the Download button and download the latest version of the Anaconda distribution.
Figure 2 - Anaconda distribution downloading
After Anaconda distribtuion is downloaded double click on the Anaconda3-2022.05-Windows-x86_64.exe and the Open File - Security Warning window shoud appear. In that window click Run. By clicking "Run" the window Anaconda3 2022.05 (64-bit) Setup will appear with message Welcome to Anaconda3 2022.05 (64-bit) Setup. At the bottom of the window Two buttons are located one whit title Next > (continues isntallation) and the other with Cancel (terminates installation).
Figure 3 - Anaconda3 2022.05 (64-bit) Setup Welcome to Anaconda3 2022.05 (64-bit) Setup
By clicking Next button on the window shown in Figure 3 the new window Anaconda3 2022.05 (64-bit) Setup with subtitle License Agreement will appear. If you want you can read it and if you accept hte terms of the agreement, you have to click I Agree button to continue the installation. If you want ot go back you click on the button < Back and if you want to terminate the installation click Cancel.
Figure 4 - Anaconda3 2022.05 (64-bit) Setup - License Agreement
In Figure 4 by clickign on the button I Agree the next window Anaconda3 2022.05 (64-bit) Setup with subtitle Select Installation Type will appear. In this window two options are available i.e. Install for: Just Me (recommended) and All Users (requires adimn privilages). The first option Just Me will isntall the Anaconda distribution for your Windows account. The second option will install Anaconda distribution for all users however, Windows administrator account information is required to install it.
Figure 5 - Anaconda3 2022.05 (64-bit) Setup - Select Installation Type
By choosing the Installation Type Option and clicking on the button Next > the window Anaconda3 2022.05 (64-bit) Setup with subtitle Choose Install Location will appear. In this window you have to manually type the Destination Folder where you want to install Anaconda distribution or click on button Browse.. which will open a new window Browse For Folder and let you select the folder where to install Anaconda. Now specify the installation location and click Next >.
Figure 6 - Anaconda3 2022.05 (64-bit) Setup - Choose Install Location
After installation location is specified and you clicked on the Next > the window Anaconda3 2022.05 (64-bit) Setup with subtitle Advanced Installation Options will appear. Two options are available and these are: Add Anacona3 to the system PATH environment variable and Reguster Anaconda3 as the system Python 3.9.. Select the options you prefer and click Install button.
Figure 7 - Anaconda3 2022.05 (64-bit) Setup - Advanced Installation Options
After you click on Install button and the Anaconda distribution of Python will be installed.
Figure 8 - Anaconda3 2022.05 (64-bit) Setup - Setup in progress
When setup is completed as shown in Figure 9 click on the Next > button.
Figure 9 - Anaconda3 2022.05 (64-bit) Setup - Installation Completed
The window shown in Figure 10 show additional information about combining Anaconda + JetBrains if you are visit the link provided in window if not click Next >
Figure 10 - Anaconda3 2022.05 (64-bit) Setup - Information about Anaconda + JetBrains integration
After clicking Next > the final window of Anaconda installation will appear with subtitle Completing Anaconda3 2022.05 (64-bit) Setup will appear. In this window you can select Anaconda Distribution Tutorial and Getting Started with Anaconda option that will be opened after you click on Finish button. The window Completing Anaconda3 2022.05 (64-bit) Setup is shown Figure 11.
Figure 11 - Anaconda3 2022.05 (64-bit) Setup - Completing Anaconda3 2022.05 (64-bit) Setup

How to check Python installed version ?

In Windows operating system press Windows key, then type cmd and press Enter. In command prompt window type in:
python --version
and then press Enter. This will give us the information about last version of Python installed on your computer.
Python 3.x.x
The x.x. is given since our version of installed Python may be different from yours. In newer versions of Python (Python 3.10.5 or Anaconda distribution with Python 3.9.12) to see the version of installed Python programming language type in the following command.
py --version
Output of the previous command if you installed the latest version of Python will be:
Python 3.10.5
If you have installed the latest version of Anaconda distribution then the output will be:
Python 3.9.12
Alternatively you can write:
python -V
or
py -V
and the output will be the current Python version that is installed on your computer.