KEMBAR78
Introduction To Python-13 Mar 2023 | PDF | Data Type | Variable (Computer Science)
0% found this document useful (0 votes)
54 views67 pages

Introduction To Python-13 Mar 2023

The document provides an overview of Python's history, advantages, disadvantages, and its applications in various fields such as machine learning, web development, and scientific computing. It discusses Python's ease of use, extensive libraries, and community support, while also highlighting its limitations in speed and mobile development. Additionally, it covers Python variables, data types, keywords, and literals, emphasizing its dynamic typing and object-oriented nature.

Uploaded by

Vrushank Bhatt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views67 pages

Introduction To Python-13 Mar 2023

The document provides an overview of Python's history, advantages, disadvantages, and its applications in various fields such as machine learning, web development, and scientific computing. It discusses Python's ease of use, extensive libraries, and community support, while also highlighting its limitations in speed and mobile development. Additionally, it covers Python variables, data types, keywords, and literals, emphasizing its dynamic typing and object-oriented nature.

Uploaded by

Vrushank Bhatt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 67

Python for Machine

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

• Guido van Rossum was reading the script


of a popular BBC comedy series "Monty
Python's Flying Circus". It was late on-air
1970s.
• Van Rossum wanted to select a name which
unique, sort, and little-bit mysterious. So he
decided to select naming Python after
the "Monty Python's Flying Circus" for
their newly created programming language.
• The comedy series was creative and well
random. It talks about everything. Thus it is
slow and unpredictable, which made it very
interesting.
◦ Python is also versatile and widely used in every technical field, such as Machine Learning
◦ , Artificial Intelligence
◦ , Web Development, Mobile Application
◦ , Desktop Application, Scientific Calculation, etc.
Advantages of Python :
◦ Python is a general purpose and high level programming language. You can use Python for developing desktop GUI
applications, websites and web applications. Also, Python, as a high level programming language, allows you to focus
on core functionality of the application by taking care of common programming tasks.
◦ Need to use python
◦ Readable and Maintainable Code
◦ Multiple Programming Paradigms
◦ Compatible with Major Platforms and Systems
◦ Robust Standard Library
◦ Many Open Source Frameworks and Tools
◦ Simplify Complex Software Development
◦ Adopt Test Driven Development
Installing Python
Installation on Windows
◦ Visit the link https://www.python.org/downloads/ to download the latest release of Python. In this process, we
will install Python 3.8.6 on our Windows operating system. When we click on the above link, it will bring us
the following page.
◦ Step - 1: Select the Python's version to download.
◦ Click on the download button.
◦ Step - 2: Click on the Install Now
◦ Double-click the executable file, which is downloaded; the following window will open. Select Customize
installation and proceed. Click on the Add Path check box, it will set the Python path automatically.
◦ Step - 3 Installation in Process
Installation on Mac
◦ To install python3 on MacOS, visit the link https://www.javatpoint.com/how-to-install-python-on-mac and
follow the instructions given in the tutorial.
Applications of Python
1) Web Applications
◦ We can use Python to develop web applications. It provides libraries to handle internet protocols such as HTML and XML, JSON,
Email processing, request, beautifulSoup, Feedparser, etc. One of Python web-framework named Django is used on Instagram.
Python provides many useful frameworks, and these are given below:
• Django and Pyramid framework(Use for heavy applications)
• Flask and Bottle (Micro-framework)
• Plone and Django CMS (Advance Content management)

2) Desktop GUI Applications


◦ The GUI stands for the Graphical User Interface, which provides a smooth interaction to any application. Python provides a Tk GUI
library to develop a user interface. Some popular GUI libraries are given below.
3) Console-based Application
◦ Console-based applications run from the command-line or shell. These applications are computer program which are used commands
to execute. This kind of application was more popular in the old generation of computers. Python can develop this kind of application
very effectively. It is famous for having REPL, which means the Read-Eval-Print Loop that makes it the most suitable language for
the command-line applications.
◦ Python provides many free library or module which helps to build the command-line apps. The necessary IO libraries are used to read
and write. It helps to parse argument and create console help text out-of-the-box. There are also advance libraries that can develop
independent console apps.
4) Software Development
◦ Python is useful for the software development process. It works as a support language and can be used to build control
and management, testing, etc.
• SCons is used to build control.
• Buildbot and Apache Gumps are used for automated continuous compilation and testing.
• Round or Trac for bug tracking and project management.
5) Scientific and Numeric
◦ This is the era of Artificial intelligence where the machine can perform the task the same as the human. Python
language is the most suitable language for Artificial intelligence or machine learning. It consists of many scientific and
mathematical libraries, which makes easy to solve complex calculations.
◦ Implementing machine learning algorithms require complex mathematical calculation. Python has many libraries for
scientific and numeric such as Numpy, Pandas, Scipy, Scikit-learn, etc. If you have some basic knowledge of Python,
you need to import libraries on the top of the code. Few popular frameworks of machine libraries are given below.
• SciPy
• Scikit-learn
• NumPy
• Pandas
• Matplotlib
6) Business Applications
◦ Business Applications differ from standard applications. E-commerce and ERP are an example of a business
application. This kind of application requires extensively, scalability and readability, and Python provides all these
features.
◦ Oddo is an example of the all-in-one Python-based application which offers a range of business applications. Python
provides a Tryton platform which is used to develop the business application.
7) Audio or Video-based Applications
◦ Python is flexible to perform multiple tasks and can be used to create multimedia applications. Some multimedia
applications which are made by using Python are TimPlayer, cplay, etc. The few multimedia libraries are given below.
• Gstreamer
• Pyglet
• QT Phonon
8) 3D CAD Applications
◦ The CAD (Computer-aided design) is used to design engineering related architecture. It is used to develop the 3D representation of a
part of a system. Python can create a 3D CAD application by using the following functionalities.
• Fandango (Popular )
• CAMVOX
• HeeksCNC
• AnyCAD
• RCAM

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.

True False None and as


asset def class continue break
else finally elif del except
global for if from import
raise try or return pass
nonlocal in not is lambda
◦ Python Literals
◦ Python Literals can be defined as data that is given in a variable or constant.
◦ Python supports the following literals:
◦ 1. String literals:
◦ String literals can be formed by enclosing a text in the quotes. We can use both single as well as double quotes to create a
string.
◦ Example:
"Aman" , '12345'
◦ Types of Strings:
There are two types of Strings supported in Python:
a) Single-line String- Strings that are terminated within a single-line are known as Single line Strings.
◦ Example:
1. text1='hello'
◦ b) Multi-line String - A piece of text that is written in multiple lines is known as multiple lines string.
◦ There are two ways to create multiline strings:
◦ 1) Adding black slash at the end of each line.
◦ Example:
1. text1='hello\
2. user'
3. print(text1)
◦ 2) Using triple quotation marks:-
◦ Example:
1. str2='''''welcome
2. to
3. SSSIT'''
4. print str2
II. Numeric literals:
Numeric Literals are immutable. Numeric literals can belong to
following four different numerical types

Int(signed Long(long float(floating Complex(comp


integers) integers) point) lex)
Numbers( can Integers of Real numbers In the form of
be both positive unlimited size with both a+bj where a
and negative) followed by integer and forms the real
with no lowercase or fractional part part and b
fractional uppercase L eg: eg: -26.2 forms the
part.eg: 100 87032845L imaginary part
of the complex
number. eg:
3.14j
III. Boolean literals:
◦ A Boolean literal can have any of the two values: True or False.
IV. Special literals.
◦ Python contains one special literal i.e., None.
◦ None is used to specify to that field that is not created. It is also used for the end of lists in Python.

◦ Example - Special Literals


1.val1=10
2.val2=None
3.print(val1)
4.print(val2)

1. list1=[456,'Andrew']
2. print(list)
3. print(list + list1)
V. Literal Collections.
◦ Python provides the four types of literal collection such as List literals, Tuple literals, Dict literals, and Set literals.
◦ List:
• List contains items of different data types. Lists are mutable i.e., modifiable.
• The values stored in List are separated by comma(,) and enclosed within square brackets([]). We can store different
types of data in a List.
◦ Example - List literals
1. list=['John',678,20.4,'Peter’]
◦ Dictionary:
• Python dictionary stores the data in the key-value pair.
• It is enclosed by curly-braces {} and each pair is separated by the commas(,).
◦ Example
1. dict = {'name': 'Pater', 'Age':18,'Roll_nu':101}
2. print(dict)
◦ Tuple:
• Python tuple is a collection of different data-type. It is immutable which means it cannot be modified after creation.
• It is enclosed by the parentheses () and each element is separated by the comma(,).
◦ Example
1. tup = (10,20,"Dev",[2,3,4])
2. print(tup)
◦ Set:
• Python set is the collection of the unordered dataset.
• It is enclosed by the {} and each element is separated by the comma(,).
◦ Example: - Set Literals
1. set = {'apple','grapes','guava','papaya'}
2. print(set)
Operators :
◦ Python divides the operators in the following groups:
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Identity operators
• Membership operators
• Bitwise operators
Arithmetic Operators :

Operator Name Example


+ Addition x+y
- Subtraction x-y
* Multiplication x*y
/ Division x/y
% Modulus x%y
** Exponentiation x ** y
// Floor division x // y
Assignment Operator :
Operator Example Same As
= x=5 x=5
+= x += 3 x=x+3
-= x -= 3 x=x-3
*= x *= 3 x=x*3
/= x /= 3 x=x/3
%= x %= 3 x=x%3
//= x //= 3 x = x // 3
**= x **= 3 x = x ** 3
&= x &= 3 x=x&3
|= x |= 3 x=x|3
^= x ^= 3 x=x^3
>>= x >>= 3 x = x >> 3
<<= x <<= 3 x = x << 3
Comparison Operators :

Operator Name Example


== Equal x == y
!= Not equal x != y
> Greater than x>y
< Less than x<y
>= Greater than or equal x >= y
to
<= Less than or equal to x <= y
Logical Operators :
Operator Description Example

and Returns True if both x < 5 and x < 10


statements are true

or Returns True if one of x < 5 or x < 4


the statements is true

not Reverse the result, not(x < 5 and x <


returns False if the 10)
result is true
Identity Operators :

Operator Description Example

is Returns True if both x is y


variables are the
same object

is not Returns True if both x is not y


variables are not the
same object
Membership Operators :

Operator Description Example


in Returns True if a x in y
sequence with the
specified value is
present in the object
not in Returns True if a x not in y
sequence with the
specified value is not
present in the object
Bitwise Operators :

Oper Name Description


ator
& AND Sets each bit to 1 if both bits are 1
| OR Sets each bit to 1 if one of two bits is 1
^ XOR Sets each bit to 1 if only one of two bits is 1
~ NOT Inverts all the bits
<< Zero fill Shift left by pushing zeros in from the right and
left shift let the leftmost bits fall off
>> Signed Shift right by pushing copies of the leftmost bit in
right from the left, and let the rightmost bits fall off
shift
Input and Output in Python :
◦ Python provides us with two inbuilt functions to read the input from the keyboard.

• 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 = input ("Enter number :")


◦ print(a)
◦ b = input("Enter name : ")
◦ print(b)
◦ # Printing type of input value
◦ print ("type of number", type(num))
◦ print ("type of name", type(name1))
◦ Output : Task for the day
◦ # a use of raw_input()

◦ g = raw_input("Enter your name : ")


◦ print g
◦ Here, g is a variable which will get the string value, typed by user during the execution of program. Typing of data for the
raw_input() function is terminated by enter key.
◦ By using Console : For coding in Python you must know the basics of the console used in Python.
◦ The primary prompt of the python console is the three greater than symbols
◦ >>>
◦ You are free to write the next command on the shell only when after executing the first command these prompts have
appeared. The Python Console accepts command in Python which you write after the prompt.
Output in python :
◦ Parameters:
• value(s) : Any value, and as many as you like. Will be converted to string before printed
• sep=’separator’ : (Optional) Specify how to separate the objects, if there is more than one.Default :’ ‘
• end=’end’: (Optional) Specify what to print at the end.Default : ‘\n’
• file : (Optional) An object with a write method. Default :sys.stdout
• flush : (Optional) A Boolean, specifying if the output is flushed (True) or buffered (False). Default: False
◦ Returns: It returns output to the screen.
◦ Indentation :
◦ Python relies on indentation (whitespace at the beginning of a line) to define scope in the code. Other programming languages
often use curly-brackets for this purpose.

◦ 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)

◦ Score validated. Your total is: 85


Elif :
◦ Elif
◦ The elif keyword is pythons way of saying "if the previous conditions were not true, then try this condition".
◦ a = 33
b = 33
if b > a:
print("b is greater than a")
elif a == b:
print("a and b are equal")

◦ 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.

◦ Print i as long as i is less than 6:


◦ i=1
while i < 6:
print(i)
i += 1
◦ The break Statement
◦ With the break statement we can stop the loop even if the while condition is true:
◦ Example
◦ Exit the loop when i is 3:
◦ i=1
while i < 6:
print(i)
if i == 3:
break
i += 1
◦ The else Statement
◦ With the else statement we can run a block of code once when the condition no longer is true:
◦ Print a message once the condition is false:
◦ i=1
while i < 6:
print(i)
i += 1
else:
print("i is no longer less than 6")
◦ The break Statement
◦ With the break statement we can stop the loop before it has looped through all the items:
◦ fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
if x == "banana":
break
◦ fruits = ["apple", "banana", "cherry"]
for x in fruits:
if x == "banana":
break
print(x)
◦ The continue Statement
◦ With the continue statement we can stop the current iteration of the loop, and continue with the next:
◦ fruits = ["apple", "banana", "cherry"]
for x in fruits:
if x == "banana":
continue
print(x)
Introduction to range() :
◦ Python range() function returns the sequence of the given number between the given range.
◦ range() is a built-in function of Python. It is used when a user needs to perform an action a specific number of times. range() in
Python(3.x) is just a renamed version of a function called xrange in Python(2.x).
◦ Python range() function for loop is commonly used hence, knowledge of same is the key aspect when dealing with any kind
of Python code. The most common use of range() function in Python is to iterate sequence type (Python range() List, string,
etc. ) with for and while loop.

◦ Python range syntax


◦ range(stop)
◦ range(start, stop[, step])

◦ range_0_5= range(5)
◦ for number in range_0_5:
◦ print(number)
◦ Example 2 :
◦ for number in range(5):
◦ print(number)

◦ Range syntax : range(start , stop , step)


• start – It indicates the starting integer of the sequence that you want to generate. It is optional and set to 0 by default.
• stop – It indicates the integer at which you want to stop. It is mandatory to mention and is exclusive i.e., it is not included in
the sequence generated.
• step – It indicates the difference between consecutive integers in the sequence. In other words, it specifies the value of
incrementation or decrementation step. By default, it is set to 1 and is optional.
◦ The range() Function
◦ To loop through a set of code a specified number of times, we can use the range() function,
◦ The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1 (by default), and ends at a
specified number.
◦ for x in range(6):
print(x)
◦ for x in range(2, 6):
print(x)

Else in For Loop


The else keyword in a for loop specifies a block of code to be executed when the loop is finished:
◦ for x in range(6):
print(x)
else:
print("Finally finished!")
◦ for x in range(6):
if x == 3: break
print(x)
else:
print("Finally finished!")
Loop :
◦ # Program to find the sum of all numbers stored in a list

◦ # List of numbers
◦ numbers = [6, 5, 3, 8, 4, 2, 5, 4, 11]

◦ # variable to store the sum


◦ sum = 0

◦ # iterate over the list


◦ for val in numbers:
◦ sum = sum+val

◦ print("The sum is", sum)

◦ 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.

◦ Pandas :examine,mnipulate and clean tabular data.

◦ SciPy : used for scientific calculations.

◦ Scikit learn : It is collection of some advanced machine Learning algorithms.

◦ Matplotib : helps to visualise data.


Applications used in Airforce :
◦ A The Defense Advanced Research Projects Agency (DARPA) research program is developing AI
systems to fight aerial battles on their own. The AI pilots are expected to fly for the first time in
2024.Currently, more than 600 projects are underway to integrate AI into warfare.

◦ 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).

◦ Termed the health usage and


monitoring system, it will use AI to
reduce the time needed for data
analysis, resulting in faster
turnaround of aircraft and having
better projection for preventive
maintenance.
Application 4 :
◦ Deep Learning (DL) and Machine
Learning (ML) are effectively utilized
in various complicated challenges in
healthcare, industry, and academia.
◦ The Internet of Drones (IoD) has
lately cropped up due to high
adjustability to a broad range of
unpredictable circumstances.
◦ In addition, Unmanned Aerial
Vehicles (UAVs) could be utilized
efficiently in a multitude of
scenarios, including rescue missions
and search, farming, mission-critical
services, surveillance systems
How machine learning helpful for IAF :
◦ Simplicity: Python code is concise and readable even to new developers, which is beneficial to
machine and deep learning projects. Due to its simple syntax, the development of applications with
Python is fast when compared to many programming languages. Furthermore, it allows the
developer to test algorithms without implementing them.

◦ 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!!!

You might also like