[go: up one dir, main page]

0% found this document useful (0 votes)
16 views25 pages

Python & AI PPT Updated

The document explains the basics of Python programming and its applications in Artificial Intelligence (AI). It covers Python's features, modes of operation, data types, operators, and provides example programs for various computations. Additionally, it highlights the role of Python in AI, including machine learning, computer vision, and natural language processing.

Uploaded by

21cse056
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)
16 views25 pages

Python & AI PPT Updated

The document explains the basics of Python programming and its applications in Artificial Intelligence (AI). It covers Python's features, modes of operation, data types, operators, and provides example programs for various computations. Additionally, it highlights the role of Python in AI, including machine learning, computer vision, and natural language processing.

Uploaded by

21cse056
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/ 25

Python & Artificial

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

not in Membership Operator


Example : x=[1,2,3]
3 in x
Its answer is True
Program 1:
Sum of Two Numbers
a = int(input("Enter first number ="))
b = int(input("Enter second number ="))
c=a+b
print("Sum of two numbers = ",c)
Program 2:
To Find Simple Interest
P = int(input("Enter the Principal ="))
R = int(input("Enter the Rate ="))
T = int(input("Enter the Time ="))
SI = P*R*T/100
print("Simple Interest =",SI)
Program 3:
Area & Circumference of Circle
r = int(input("Enter the Radius of the circle
="))
area = 3.14 * r * r
circumference = 2 * 3.14 * r
print("Area of Circle =",area)
print("Circumference of Circle
=",circumference)
Program 4:
Area and Perimeter of Square
side = int(input("Enter the side of the
square ="))
area = side * side
perimeter = 4 * side
print("Area of Square =",area)
print("Perimeter of Square =",perimeter)
Program 5:
Area and Perimeter of Rectangle
l = int(input("Enter the length of the
rectangle ="))
b = int(input("Enter the breadth of the
rectangle="))
area = l * b
perimeter = 2 * l + 2 * b
print("Area of Square =",area)
print("Perimeter of Square =",perimeter)
Program 6:
Program to accept Name, Age &
Marks of the student
name = input("Enter the name of the
student =")
age = input("Enter the age of the student
=")
marks = input("Enter the marks of the
student =")
print("Name of the student = ",name)
print("Age of the student = ",age)
print("Marks of the student = ",marks)
Artificial Intelligence(AI)
Artificial Intelligence(AI) is like teaching
computers to think and learn like the human
brain.
It helps computers and machines to do smart
things, like recognizing faces in pictures,
playing games or even talking to humans.
It is like giving computers the ability to solve
problems or make decisions on their own
using special programs and lots of
information.
For example, AI is what makes virtual
assistants like Siri or Alexa answer your
questions
Alexa is a virtual assistant created by
Amazon. It is powered by AI and lives in
devices like Echo speaker or Echo Show
screen.
You can talk to Alexa by saying her name,
followed by a command or question.
For example, “what is the capital of Italy?”
She listens, processes your request and
Use of Python in Artificial
Intelligence (AI)
Machine Learning(ML): Python helps
create systems that can learn from data using
libraries.
Example: Predicting the weather
Computer Vision : Teaching a computer to
see.
Example: Recognizing faces or objects.
Natural Language Processing : Teaching a
computer to understand text. Example: Chat
GPT.

You might also like