Introduction To Python-13 Mar 2023
Introduction To Python-13 Mar 2023
Learning
By - ANIKET
MISHRA
Agenda
1 2 3 4 5
Python and Its Concepts of Relation to Various Conclusion
History Python ML Applications
w.r.t. Airforce
History
• Python laid its foundation in the late 1980s.
• The implementation of Python was started in December 1989 by Guido Van Rossum at CWI in Netherland.
• In February 1991, Guido Van Rossum published the code (labeled version 0.9.0) to alt.sources.
• In 1994, Python 1.0 was released with new features like lambda, map, filter, and reduce.
• Python 2.0 added new features such as list comprehensions, garbage collection systems.
• On December 3, 2008, Python 3.0 (also called "Py3K") was released. It was designed to rectify the fundamental flaw
of the language.
• ABC programming language is said to be the predecessor of Python language, which was capable of Exception
Handling and interfacing with the Amoeba Operating System.
• The following programming languages influence Python:
• ABC language.
• Modula-3
The implementation of Python was started in December 1989 by Guido Van
Rossum at CWI in Netherland
9) Enterprise Applications
◦ Python can be used to create applications that can be used within an Enterprise or an Organization. Some real-time applications are
OpenERP, Tryton, Picalo, etc.
10) Image Processing Application
◦ Python contains many libraries that are used to work with the image. The image can be manipulated according to our requirements.
Some libraries of image processing are given below.
• OpenCV
• Pillow
• SimpleITK
◦ In this topic, we have described all types of applications where Python plays an essential role in the development of these applications.
In the next tutorial, we will learn more concepts about Python.
Advantages :
1. Easy to use and learn: For beginners, Python is straightforward to use. It is a high-level programming language, and its syntax is like
the English language. These reasons make the language easy to learn and adapt to. Compared to Java and C, in Python, the same task can
be performed using fewer lines of code. As a result of its easy learning, the principles in Python can be executed faster compared to other
languages.
2. Increased productivity: Python is a very productive language. The simple nature of Python helps the developers to concentrate on
solving the issues in it. To understand the syntax and behavior of the programming language, the users do not have to spend hours, so
more work is done.
3. Flexibility: This language is very flexible, and hence it allows the user to try new things. The users can develop new sorts of the
application using Python programming language. The language does not restrict the user from trying something different. Other
programming languages do not provide this type of flexibility and freedom, and hence Python is more preferred in these matters.
4. Extensive library: Python provides the user with a vast library. Python’s standard library is massive, and just about every function one
needs to perform is available in its library. This is because it has a hugely supportive community and corporate sponsorship. External
libraries are not used by users while working with Python.
5. Supportive community: The Python language was created years ago, and hence it has a mature community that can support every type
of developer, starting from beginners’ level to expert level. There are enough guides, tutorials, and documentation available on the
Python programming language, which helps the developers to understand the language faster and better. Because of its supportive
community, Python has rapid growth compared to other languages.
Disadvantages :
1. Speed: Compared to Java or C, the rate of Python is slower. Python is an interpreted language that is dynamically typed. For the execution of a code,
each line of the code needs to be explicitly ordered since the language gets interpreted. This is time-consuming, and hence it slows down the process of
execution. The dynamic structure of Python also slows its speed because while executing the code, the excess work also needs to be completed.
Therefore, in cases where fast acceleration is required, Python is not used there very commonly.
2. Memory consumption: Python has a very high memory consumption. This is because it is flexible to the data types. It uses large amounts of memory.
Python is not a good choice for tasks where the user wants to optimize memory, i.e., a memory-intensive language.
3. Mobile development: Python is strong in server platforms and desktops, and hence it is a fantastic server-side programming language. But it is not
appropriate for mobile development. For mobile development, Python is a fragile language. Since it is not memory efficient and has a prolonged power
for processing, due to these reasons, Python does not have many built-in mobile applications. Carbonnelle is a built-in application present in Python.
4. Database access: Python provides easy programming. However, when it interacts with the database, some issues arise. Compared to technologies like
JDBC and ODBC, which are pretty famous, the database access layer of the Python programming language is primitive and underdeveloped. Large
enterprises that usually need smooth interaction with complex legacy data do not prefer the usage of Python.
5. Runtime errors: The users of Python mentioned various issues they faced with the language design. Since the language of Python is dynamically typed,
there can be changes in the data type of a variable at any time. Therefore, it needs to be tested more often, and also, there are errors in the language
displayed during runtime.
6. Simplicity: Python is a straightforward and easy-to-use programming language which is also a disadvantage of the language. The users of Python get so
accustomed to its easy syntax and extensive library feature that they face issues while learning other programming languages. Some users also feel that
the Java codes are unnecessary due to their complexity. Therefore, Python has a very vulnerable nature, and the users start taking everything lightly.
Python Variables
◦ Variable is a name that is used to refer to memory location. Python variable is also known as an identifier and used to
hold value.
◦ In Python, we don't need to specify the type of variable because Python is a infer language and smart enough to get
variable type.
◦ Variable names can be a group of both the letters and digits, but they have to begin with a letter or an underscore.
◦ It is recommended to use lowercase letters for the variable name. Rahul and rahul both are two different variables.
◦ Identifier Naming
◦ Variables are the example of identifiers. An Identifier is used to identify the literals used in the program. The rules to
name an identifier are given below.
• The first character of the variable must be an alphabet or underscore ( _ ).
• All the characters except the first character may be an alphabet of lower-case(a-z), upper-case (A-Z), underscore, or
digit (0-9).
• Identifier name must not contain any white-space, or special character (!, @, #, %, ^, &, *).
• Identifier name must not be similar to any keyword defined in the language.
• Identifier names are case sensitive; for example, my name, and MyName is not the same.
• Examples of valid identifiers: a123, _n, n_9, etc.
• Examples of invalid identifiers: 1a, n%4, n 9, etc.
◦ Declaring Variable and Assigning Values
◦ Python does not bind us to declare a variable before using it in the application. It allows us to create a variable at the
required time.
◦ We don't need to declare explicitly variable in Python. When we assign any value to the variable, that variable is
declared automatically.
◦ The equal (=) operator is used to assign value to a variable.
◦ Object References
◦ It is necessary to understand how the Python interpreter works when we declare a variable. The process of treating
variables is somewhat different from many other programming languages.
◦ Python is the highly object-oriented programming language; that's why every data item belongs to a specific type of
class.
◦ Variable Names
◦ We have already discussed how to declare the valid variable. Variable names can be any length can have uppercase,
lowercase (A to Z, a to z), the digit (0-9), and underscore character(_). Consider the following example of valid
variables names.
◦ Multiple Assignment
◦ Python allows us to assign a value to multiple variables in a single statement, which is also known as multiple assignments.
◦ We can apply multiple assignments in two ways, either by assigning a single value to multiple variables or assigning multiple
values to multiple variables. Consider the following example.
1. Assigning single value to multiple variables
◦ Eg:
1. x=y=z=50
2. print(x)
3. print(y)
4. print(z)
2. Assigning multiple values to multiple variables:
◦ Eg:
1. a,b,c=5,10,15
2. print a
3. print b
4. print c
◦ Python Data Types
◦ Variables can hold values, and every value has a data-type. Python is a dynamically typed language; hence we do not
need to define the type of the variable while declaring it. The interpreter implicitly binds the value with its type.
1. a = 5
◦ The variable a holds integer value five and we did not define its type. Python interpreter will automatically interpret
variables a as an integer type.
◦ Python enables us to check the type of the variable used in the program. Python provides us the type() function, which
returns the type of the variable passed.
◦ Consider the following example to define the values of different data types and checking its type.
1. a=10
2. b="Hi Python"
3. c = 10.5
4. print(type(a))
5. print(type(b))
6. print(type(c))
◦ Standard data types
◦ A variable can hold different types of values. For example, a person's name must be stored as a string whereas its id
must be stored as an integer.
◦ Python provides various standard data types that define the storage method on each of them. The data types defined in
Python are given below.
1. Numbers
2. Sequence Type
3. Boolean
4. Set
5. Dictionary
◦ Python Keywords
◦ Python Keywords are special reserved words that convey a special meaning to the compiler/interpreter. Each keyword
has a special meaning and a specific operation. These keywords can't be used as a variable. Following is the List of
Python Keywords.
• input ( prompt )
• raw_input ( prompt )
◦ input ( ) : This function first takes the input from the user and then evaluates the expression, which means Python
automatically identifies whether user entered a string or a number or list. If the input provided is not correct then either syntax
error or exception is raised by python.
◦ Example : a = input (“Enter the number”)
◦ Print (a)
◦ When input() function executes program flow will be stopped until the user has given an input.
◦ # Program to check input
◦ # type in Python
◦ a = 33
b = 200
if b > a:
print("b is greater than a") # you will get an error
if statement :
◦ Simple if statement
◦ this is the simplest example of a conditional statement. The syntax is:
◦ if(condition):
◦ indented Statement Block
◦ score_theory = 40
◦ score_practical = 45
◦ if(score_theory + score_practical > 100):
◦ print("Invalid score. Please check the input.")
◦ The colon is important because it separates the condition from the statements to be executed after the evaluation of the condition. This is
specially important for statements where there is only a single statement and the bracket () is not used.
if statement :
◦ Simple if statement
◦ this is the simplest example of a conditional statement. The syntax is:
◦ if(condition):
◦ indented Statement Block
◦ score_theory = 40
◦ score_practical = 45
◦ if(score_theory + score_practical > 100):
◦ print("Invalid score. Please check the input.")
◦ The colon is important because it separates the condition from the statements to be executed after the evaluation of the condition. This is
specially important for statements where there is only a single statement and the bracket () is not used.
If else statement :
◦ The if-else statement is used to code the same way you would use it in the English language. The syntax for the if-else
statement is:
◦ score_theory = 40
◦ score_practical = 45
◦ if(score_theory + score_practical > 100):
◦ print("Please check the input. Score exceeds total possible score.")
◦ else:
◦ print("Score validated. Your total is: ", score_theory + score_practical)
◦ a = 200
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")
else:
print("a is greater than b")
Nested loops :
◦ if
◦ x = 41
if x > 10:
print("Above ten,")
if x > 20:
print("and also above 20!")
else:
print("but not above 20.")
◦ for
◦ A nested loop is a loop inside a loop.
◦ The "inner loop" will be executed one time for each iteration of the "outer loop":
◦ adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]
for x in adj:
for y in fruits:
print(x, y)
◦ The while Loop
◦ With the while loop we can execute a set of statements as long as a condition is true.
◦ range_0_5= range(5)
◦ for number in range_0_5:
◦ print(number)
◦ Example 2 :
◦ for number in range(5):
◦ print(number)
◦ # List of numbers
◦ numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]
◦ Sum is 48
Relation to Machine Learning :
◦ Reasons for using the Python language in Machine Learning.
◦ It has a huge number of libraries and frameworks: The Python language comes with many
libraries and frameworks that make coding easy. This also saves a significant amount of time.
◦ The most popular libraries are NumPy, which is used for scientific calculations; SciPy for more
advanced computations; and scikit, for learning data mining and data analysis.
◦ These libraries work alongside powerful frameworks like TensorFlow, CNTK, and Apache Spark.
These libraries and frameworks are essential when it comes to machine and deep learning
projects.
Python Modules used in Machine Learning:
◦ NumPy : numpy library offers special types of arrays. It can easily stored and handled.
◦ DARPA projects are developing unmanned underwater vehicles for the U.S. Navy, Gremlin drones
that can be recovered from Air Force C-130 aircraft, and large drone swarm (OFFSET) technologies.
◦ Military researchers host industry day briefings for artificial intelligence (AI) and machine learning :
The Stratagem project has three parts: machine intelligence support for complex military operations;
capturing human expertise to augment warfighter capability; and transferring machine-learning
models from video gaming to Air Force battle management and simulations.
◦ The Indian Air Force (IAF) has established a Center of Excellence (CoE) for the integration of Artificial
Intelligence (AI) into its warfighting capabilities, becoming the first among the three armed services
of India.
◦ A Big Data Analytics and Al Platform have been commissioned in the IAF’s Al Centre, for handling all
aspects of Analytics, Machine Learning, Natural Language Processing, Neural Networks, and Deep
Learning algorithms,” said the IAF.
◦ Application1 :
◦ We have autonomous wingman programs like Defense Research and Development Organisation
(DRDO)’s indigenous Combat Air Teaming System (CATS), which focuses on expanding the
capabilities of each pilot in the air by increasing payloads at hand and also offering greater
situational awareness.”
Application 2 :
◦ The IAF is also working on advanced
AI and Big Data analytics projects for
forecasting operational stamina. The
AI-driven platform will provide a real-
time operational stamina status and
forecast a realistic operational
potential based on a selected time
horizon and the objectives of the
campaign.
Application 3 :
◦ Engines of the fleet of MiG-29K fighter
jets of the Navy will now be
maintained by using artificial
intelligence (AI).
◦ Readable code is also vital for collaborative coding. Many individuals can work together on a
complex project.
◦ One can easily find a Python developer for the team, as Python is a familiar platform. Therefore, a
new developer can quickly get acquainted with Python’s concepts and work on the project instantly.
◦ The massive online support: Python is an open-source programming language and enjoys
excellent support from many resources and quality documentation worldwide. It also has a large and
active community of developers who provide their assistance at any stage of development.
◦ Most scientists have adopted Python for Machine Learning and Deep Learning projects, which means
most of the brightest minds worldwide, can be found in Python communities.
◦ Fast code tests: Python provides a lot of code review and test tools. Developers can quickly check
the correctness and quality of the code.
◦ AI projects tend to be time-consuming, so a well-structured environment for testing and checking for
bugs is needed. Python is the ideal language since it supports these features.
◦ Flexible integrations: Python projects can be integrated with other systems coded in different
programming languages. This means that it is much easier to blend it with other AI projects written
in other languages.
◦ Also, since it is extensible and portable, Python can be used to perform cross languages tasks. The
adaptability of Python makes it easy for data scientists and developers to train machine learning
models.
◦ Fast development: Python has a syntax that is easy to understand and friendly. Furthermore, the
numerous frameworks and libraries boost software development. By using out-of-box solutions, a lot
can be done with a few lines of code. Python is good for developing prototypes, which boosts
productivity.
◦ Machine learning and AI, as a unit, are still developing but are rapidly growing in usage due to the
need for automation. Artificial Intelligence makes it possible to create innovative solutions to
common problems, such as fraud detection, personal assistants, spam filters, search engines, and
recommendations systems.
◦ The demand for smart solutions to real-world problems necessitates the need to develop AI further
in order to automate tasks that are tedious to program without AI. Python programming language is
considered the best algorithm to help automate such tasks, and it offers greater simplicity and
consistency than other programming languages. Further, the presence of an engaging python
community makes it easy for developers to discuss projects and contribute ideas on how to enhance
their code.
Conclusion :
◦ Many other languages can be used in Artificial Intelligence and Machine Learning
projects, but the fact remains that Python is still the best and should be given significant
consideration. It can be incorporated into the developer’s workflow alongside other
popular tools.
◦ Today, developers use the Python programming language for machine and deep learning
projects due to its significant benefits.
◦ Happy coding!
Thank
you!!!