Python & AI PPT Updated
Python & AI PPT Updated
Intelligence
While making red sauce pasta, we
refer to its recipe.
Here recipe is a set of
instructions. It tells what to do,
how to do and when to do.
The recipe(set of instructions)
uses ingredients(input) to make red
sauce pasta(output).
Likewise, a computer also works in the
three stages.
To get the work done on a computer, you
enter the raw data(input), a computer
operates on this data(processing) and
the desired is obtained(output)
To get the desired output from the
computer, you give instructions to the
computer using programming language.
Example of programming
languages : Python, C ,C++
Program is a sequence of
instructions that specifies how to
perform a computation.
Python is a simple programming
language that is used to write codes
for computer programs.
Features of Python
Easy to learn
Simple syntax
Case-Sensitive language
Free to use
Platform independent
Applications of Python
Build a website
Develop the games
Perform Scientific Computations
Develop Artificial Intelligence
Applications
Modes in Python
There are two ways to write the
program in python programming
language:
1) Interactive Mode : In this mode,
we run the python code line by line.
It is useful for small codes.
2) Script Mode : In this mode, longer
programs can be written. We can
also edit the programs when
Variables
If you need to store some food for
future use, you will need a container.
Similarly, when you are working
with the values in the python, you
require some storage to hold values
for later use.
Such storage l0cations are known
as variables.
Keywords
Keywords in Python are special words that
are part of the language itself.
They have fixed meaning and purpose.
We can think keywords like “reserved seats”
at a movie theatre.
Example: input(), print()
Basic Data Types
1) int(integers): Represents integral
numbers. Ex: 2
2) float : Representing floating point
numbers. Here, numbers have
fractional part. Ex: 2.5
3) str(string) : Represents string of
characters enclosed within single or
double quotes. Ex : ‘Hello’ , “World”.
4) Bool (boolean) : Here allowed values
are True or False.
Comments
Comments in Python is the inclusion of short
descriptions along with the code to increase
its readability.
#(hash) for single-line comment
Triple quotes :
Single triple quotes(’’’) and
Double triple quotes(”””)
Operators
1) Arithmetic Operators
2) Comparison Operators
3) Assignment Operators
4) Membership Operators
Arithmetic Operators
Addition(+) - Example: 2 + 3
Subtraction(-) - Example: 5 - 2
Multiplication(*) – Example: 2*3
Division(/) – Example: 9%2
Modulus(%) – Example: 9%2
Exponent(**) – Example: 2**3
Comparision Operators
< (Lesser than)
> (Greater than)
<=(Lesser than Equal to)
>=(Greater than Equal to)
==(Equal to)
!=(Not Equal to)
Assignment Operator (=)
Example :
a=5
b=8
a=b
a and b both are variables, so their value can
be changed during the program.
New value of a=8, as the value of b is
assigned to a.
Membership Operators
in Membership Operator
Example : x=[1,2,3]
3 in x
Its answer is True