0% found this document useful (0 votes)
2 views

_ARTIFICIAL INTELLIGENCE project

Uploaded by

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

_ARTIFICIAL INTELLIGENCE project

Uploaded by

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

ARTIFICIAL

INTELLIGENCE
(CODE-417)

ROLL NO. 10206


NAME ANISH BAGALKOTKER
CLASS AND SECTION 10th - B
SCHOOL MANAV MANGAL SMART
WORLD
SUBMITTED TO: BALDEEP KAUR
2

Introduction to Python:

❖ Python is a programming language developed by Guido Van


Rossum and it first appeared on 20th February, 1991.
❖ Python is an interpreted, object oriented, high-level
programming language. Python's simple, easy to learn
syntax emphasizes readability and therefore reduces the
cost of program maintenance.
❖ Python is meant to be an easily readable language. Its
formatting is visually uncluttered, and it often uses English
keywords where other languages use punctuation. Unlike
many other languages, it does not use curly brackets to
delimit blocks, and semicolons after statements are allowed
but are rarely, if ever, used. It has fewer syntactic exceptions
and special cases than C or Pascal.
❖ There are many functions that get the work done in Python.
If someone is used to writing programs in other languages,
Python requires getting used to the functions, as the
functions in Python are more versatile. For example, the
print() function in Python, can print information in a variety of
ways. A person may end the printing in a certain way,
separate items in a way, concatenate text naturally, etc.
3

Program#1
Learning Outcome: Basic Python Functions

Objective: Using functions print() operations

Task: To print personal information like Name, Father’s


Name, Class and School Name.

INPUT:
#To print personal information like Name, Father’s Name,
Class and School Name

a= ‘Anish bagalkotker’

b= 'Gruraj bagalkotker'

c= 'Xth B'

d= 'manav mangal SMART WORLD'

print('Name of the student is', a)

print('Name of the father is', b)

print('Class of the student is', c)

print('Name of the school is', d)


4

OUTPUT:
Name of the student is Anish bagalkotker

Name of the father is Gururaj bagalkotker

Class of the student is Xth B

Name of the school is manav mangal SMART WORLD


5

Program#2
Learning Outcome: Basic Python Functions

Objective: Using functions print() operations

Task: To find the square of number 7.

INPUT:
#To find square of number 7

a=7

sq=a**2

print('Square of number 7 is ',sq)

OUTPUT:
Square of number 7 is 49
6

Program#3
Learning Outcome: Basic Python Functions

Objective: Using functions print() operations

Task: To find the sum of two numbers 15 and 20.

INPUT:
#To find the sum of two numbers 15 and 20

a=15

b=20

Sum=a+b

print('Sum of two numbers 15 and 20 is ',Sum)

OUTPUT:
Sum of two numbers 15 and 20 is 35
7

Program#4
Learning Outcome: Basic Python Functions

Objective: Using functions print() operations

Task: To convert length given in kilometers into meters.

INPUT:
#To convert length given in kilometers into meters

a=3

b=a*1000

print('Length in meters is ',b)

OUTPUT:
Length in meters is 3000
8

Program#5
Learning Outcome: Basic Python Functions

Objective: Using functions print() operations

Task: To convert hours into seconds.

INPUT:
#To convert hours into seconds

a=17

b=a*60*60

print(a,'hours in seconds is ',b)

OUTPUT:
17 hours in seconds is 61200
9

Program#6
Learning Outcome: Basic Python Functions

Objective: Using functions print() operations

Task: To calculate Simple Interest if the principle amount =


2000, rate of interest = 4.5 and time = 10.

INPUT
#To calculate Simple Interest if the principle_amount =
2000, rate_of_interest = 4.5 and time = 10

p=2000

r=4.5

t=10

s=(p*r*t)/100

print('Simple Interest is Rs.',s)

OUTPUT:
Simple Interest is Rs. 900.0
10

PROGRAM#7
Learning Outcome: Python Arithmetic Operators

Objective: Using functions input() operations

Task: To calculate Area and Perimeter of a rectangle.

INPUT:
#To calculate Area and Perimeter of a rectangle

l=int(input('Enter the length in cm: '))

b=int(input('Enter the breadth in cm: '))

area=l*b

p=2*(l+b)

print('Area of the rectangle is',area,'sq. cm')

print('Perimeter of the rectangle is',p,'cm')

OUTPUT:
Enter the length in cm: 23

Enter the breadth in cm: 15


11

Area of the rectangle is 345 sq. cm

Perimeter of the rectangle is 76 cm

Program#8
Learning Outcome: Python Arithmetic Operators

Objective: Using functions input() operations

Task: To calculate Area of a triangle with Base and Height.

INPUT:
#To calculate Area of a triangle with Base and Height

b=int(input('Enter the length of base of triangle in cm: '))

h=int(input('Enter the height of the triangle in cm: '))

area=(1/2)*b*h

print('The area of triangle is ',area,'sq. cm')

OUTPUT
Enter the length of base of triangle in cm: 33

Enter the height of the triangle in cm: 25


12

The area of triangle is 412.5 sq. cm

Program#9
Learning Outcome: Python Arithmetic Operators

Objective: Using functions input() operations

Task: To calculate average marks of 3 subjects.

INPUT:
#To calculate average marks of 3 subjects

a=int(input('Enter the marks in First Subject: '))

b=int(input('Enter the marks in Second Subject: '))

c=int(input('Enter the marks in Third Subject: '))

avg=(a+b+c)/3

print('Average marks are ',avg)

OUTPUT
Enter the marks in First Subject: 95

Enter the marks in Second Subject: 93


13

Enter the marks in Third Subject: 86

Average marks are 91.33333333333333

Program#10
Learning Outcome: Python Arithmetic Operators

Objective: Using functions input() operations

Task: To calculate discounted amount with discount %.

INPUT:
#To calculate discounted amount with discount %

l=int(input('Enter the list price Rs.'))

s=int(input('Enter the selling price Rs.'))

d=l-s

dp=(l-s)/l*100

print('Discounted amount is Rs.',d)

print('Discount percentage is ',dp,'%')

OUTPUT:
14

Enter the list price Rs.6000

Enter the selling price Rs.5700

Program#11
Learning Outcome: Python Arithmetic Operators

Objective: Using functions input() operations

Task: To calculate Surface Area and Volume of a Cuboid.

INPUT:
#To calculate Surface Area and Volume of a Cuboid

l=int(input('Enter the length of the cuboid in cm: '))

b=int(input('Enter the breadth of the cuboid in cm: '))

h=int(input('Enter the height of the cuboid in cm: '))

SA=2*(l*b + b*h + h*l)

vol=l*b*h

print('The surface area of cuboid is',SA,'cubic cm')

print('The volume of cuboid is',vol,'cubic cm')


15

OUTPUT:
Enter the length of the cuboid in cm: 26

Enter the breadth of the cuboid in cm: 22

Enter the height of the cuboid in cm: 13

The surface area of cuboid is 2392 cubic cm

The volume of cuboid is 7436 cubic cm


16

Program#12
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: Program to check if a person can vote.

INPUT:
#Program to check if a person can vote

a=int(input('Enter your age: '))

if(a>=18):

print('You are eligible to vote')

else:

print('No, you are not eligible to vote')

OUTPUT:
Case 1: Enter your age: 27 You are eligible to vote

Case 2: Enter your age: 18 You are eligible to vote

Case 3: Enter your age: 16 No, you are not eligible to vote
17

Program#13
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: To check the grade of a student.

INPUT:
#To check the grade of a student

e=int(input('Enter marks obtained in English: '))

h=int(input('Enter marks obtained in Hindi: '))

m=int(input('Enter marks obtained in Maths: '))

s=int(input('Enter marks obtained in Science: '))

ss=int(input('Enter marks obtained in Social Science: '))

avg=(e+h+m+s+ss)/5

if(avg>90):

OUTPUT:
Case 1: Enter marks obtained in English: 95
18

Enter marks obtained in Hindi: 86

Enter marks obtained in Maths: 98

Enter marks obtained in Science: 93

Enter marks obtained in Social Science: 97

You got A grade, Excellent

Case 2: Enter marks obtained in English: 83

Enter marks obtained in Hindi: 86

print('You got A grade, Excellent')

elif(avg>80):

print('You got B grade, Good job')

elif(avg>70):

print('You got C grade, Can score better')

elif(avg>60):

print('You got D grade, Needs improvement')

elif(avg>50):

print('You got E grade, You need to work hard')


19

else:

print('You have failed the examination')

Enter marks obtained in Maths: 84

Enter marks obtained in Science: 93

Enter marks obtained in Social Science: 85

You got B grade, Good job

Case 3: Enter marks obtained in English: 48

Enter marks obtained in Hindi: 43

Enter marks obtained in Maths: 42

Enter marks obtained in Science: 51

Enter marks obtained in Social Science: 47

You have failed the examination


20

Program#14
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: Input a number and check if the number is positive,


negative or zero and display an appropriate message.

INPUT:
#Input a number and check if the number is positive,
negative or zero and display an appropriate message

n=float(input('Enter the number: '))

if(n<0):

print('The number entered is negative')

elif(n>0):

print('The number entered is positive')

else:

print('The number entered is zero')


21

OUTPUT:
Case 1: Enter the number: 5.5 The number entered is
positive

Case 2: Enter the number: -26 The number entered is


negative

Case 3: Enter the number: 0 The number entered is zero


22

Program#15
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: Input a number and check if the number is positive,


negative or zero and display an appropriate message.

INPUT:
#Input a number and check if the number is positive,
negative or zero and display an appropriate message

n=float(input('Enter the number: '))

if(n<0):

print('The number entered is negative')

elif(n>0):

print('The number entered is positive')

else:

print('The number entered is zero')

OUTPUT:
23

Case 1: Enter the number: 5.5 The number entered is


positive

Case 2: Enter the number: -26 The number entered is


negative

Case 3: Enter the number: 0 The number entered is zero


24

Program#16
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: To calculate the roots of Quadratic Equation by


checking the value of discriminant.

INPUT:
#To calculate the roots of Quadratic Equation by checking
the value of discriminant

a=int(input('Enter the value of a: '))

b=int(input('Enter the value of b: '))

c=int(input('Enter the value of c: '))

d=b**2-4*a*c

if(d>0):

print('It has real and distinct roots')

alpha=(-b+d**2-0.5)/(2*a)

beta=(-b-d**2-0.5)/(2*a)
25

print('The roots are',alpha,'and',beta)

elif(d==0):

print('It has real and same roots')

alpha=(-b-d**2-1/2)/2*a

print('The roots are',alpha,'and',alpha)

else:

print('It has no real roots')

OUTPUT:
Case 1: Enter the value of a: 3

Enter the value of b: 5

Enter the value of c: 2

It has real and distinct roots

The roots are -0.75 and -1.0833333333333333

Case 2: Enter the value of a: 4

Enter the value of b: 4

Enter the value of c: 1


26

It has real and same roots

The roots are -9.0 and -9.0

Case 3: Enter the value of a: 6

Enter the value of b: 3

Enter the value of c: 1

It has no real roots


27

Program#17
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: To make a menu based calculator to perform


various arithmetic calculations.

INPUT:
#To make menu based calculator to perform various
arithmetic calculations

while True:

print('''

Press 1 for Addition

Press 2 for Subtraction

Press 3 for Multiplication

Press 4 for Division and Remainder

Press 5 to Exit the program''')

choice = int(input('Enter your choice: '))


28

if choice == 5:

print('You exited the program')

break

elif(choice>=1 and choice<=4):

a = float(input('Enter the first number: '))

b = float(input('Enter the second number: '))

if(choice==1):

print('Sum of two numbers is ',a+b)

elif(choice==2):

print('Difference of two numbers is ',a-b)

elif(choice==3):

print('Product of two numbers is ',a*b)

else:

if(b!=0):
29

print('Quotient of two numbers is ',a//b)

print('Remainder of two numbers is ',a%b)

else:

print('Division by zero is not defined')

else:

print('Invalid choice! Please enter a valid choice.')

OUTPUT:
Case 1:

Press 1 for Addition

Press 2 for Subtraction

Press 3 for Multiplication

Press 4 for Division and Remainder

Press 5 to Exit the program

Enter your choice: 3

Enter the first number: 35

Enter the second number: 60


30

Product of two numbers is 2100.0

Case:2

Press 1 for Addition

Press 2 for Subtraction

Press 3 for Multiplication

Press 4 for Division and Remainder

Press 5 to Exit the program

Enter your choice: 4

Enter the first number: 77

Enter the second number: 0

Division by zero is not defined


31

Program#18
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: To print the first 10 natural numbers.

INPUT:
#To print first 10 natural numbers

n=1

print('First 10 natural numbers are:')

for n in range(1,11):

print(n)

OUTPUT:
First 10 natural numbers are:

1 5 9

2 6 10

3 7
32

Program#19
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: To print the first 10 even numbers.

INPUT:
#To print first 10 even numbers

n=2

count=0

print('First 10 even numbers are:')

while(count<10):

print(n)

n+=2

count+=1

OUTPUT:
First 10 even numbers are: 2 4 6 8 10 12 14 16
18 20
33

Program#20
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: To print odd numbers from 1 to n.

INPUT:
#To print odd numbers from 1 to n

n=int(input('Enter the number: '))

i=1

print('Odd numbers from 1 to',n,'are:')

for i in range(i,n+1,2):

print(i)

OUTPUT:
Enter the number: 20

Odd numbers from 1 to 20 are:

1 5 9 13 17 3 7
11 15 19
34

Program#20
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: To print the sum of the first 10 natural numbers.

INPUT:
#To print sum of first 10 natural numbers

n=1

s=0

while(n<=10):

s+=n

n+=1

print('Sum of first 10 natural numbers is',s)

OUTPUT:
Sum of first 10 natural numbers is 55
35

Program#21
Learning Outcome: Python Arithmetic Operators

Objective: Using functions if(), for(), while() operations

Task: To print the table of 5.

INPUT:
#To print the table of 5

n=1

print('Following is the table of 5:')

for n in range(1,11):

print('5 *',n,'=',n*5)

OUTPUT:
Following is the table of 5:

5*1=5 5 * 5 = 25 5 * 9 = 45

5 * 2 = 10 5 * 6 = 30 5 * 10 = 50

5 * 3 = 15 5 * 7 = 35
36

Program#22
Learning Outcome: Python Arithmetic Operators

Objective: Using functions list() operations

Task: Program to find the sum of all numbers stored in a


list.

INPUT:
#Program to find the sum of all numbers stored in a list

list=[5,6,9,12,17,15]

s=sum(list)

print('The sum of all numbers stored in the list is',s)

OUTPUT:
The sum of all numbers stored in the list is 64
37

Program#23
Learning Outcome: Python Arithmetic Operators

Objective: Using functions list() operations

Task: Create a list in Python of children selected for


science quiz with following names- Arjun, Sonakshi,
Vikram, Sandhya, Sonal, Isha, Kartik Perform the following
tasks on the list in sequence.

INPUT:
#Create a list in Python of children selected for science
quiz with following names- Arjun, Sonakshi, Vikram,
Sandhya, Sonal, Isha, Kartik Perform the following tasks
on the list in sequence

list=['Arjun','Sonakshi','Vikram','Sandhya','Sonal','Isha','Kar
tik']

print('Initial List:',list)

list.remove('Vikram')

print('List after removing Vikram:',list)

list.append('Jay')
38

print('List after adding Jay at the end:',list)

del list[2]

print('List after removing second item:',list)

OUTPUT:
Initial List: ['Arjun', 'Sonakshi', 'Vikram', 'Sandhya', 'Sonal',
'Isha', 'Kartik']

List after removing Vikram: ['Arjun', 'Sonakshi', 'Sandhya',


'Sonal', 'Isha', 'Kartik']

List after adding Jay at the end: ['Arjun', 'Sonakshi',


'Sandhya', 'Sonal', 'Isha', 'Kartik', 'Jay']

List after removing second item: ['Arjun', 'Sonakshi',


'Sonal', 'Isha', 'Kartik', 'Jay']
39

Program#24
Learning Outcome: Python Arithmetic Operators

Objective: Using functions list() operations

Task: Create a list List_1=[10,20,30,40]. Add the elements


[14,15,12] using extend function. Now sort the final list in
ascending order and print it.

INPUT:
#Create a list List_1=[10,20,30,40]. Add the elements
[14,15,12] using extend function. Now sort the final list in
ascending order and print it

List_1=[10,20,30,40]

List_1.extend([14,15,12])

print("List after adding elements is",List_1)

print("Sorted list in ascending order is",List_1)

OUTPUT:
List after adding elements is [10, 20, 30, 40, 14, 15, 12]

Sorted list in ascending order is [10, 12, 14, 15, 20, 30, 40]
40

Program#25
Learning Outcome: Python Arithmetic Operators

Objective: Using functions list() operations

Task: Write a program to add the elements of the two lists.

INPUT:
#Write a program to add the elements of the two lists

import math

list1=[52,93,156,643,6]

list2=[75,93,96,16,4,55,1546]

print('First list is:',list1)

print('Secons list is:',list2)

list1.extend(list2)

print('Result after adding both the list is:',list1)

print('The sum of the list is:',sum(list1))

OUTPUT:
41

First list is: [52, 93, 156, 643, 6]

Secons list is: [75, 93, 96, 16, 4, 55, 1546]

Result after adding both the list is: [52, 93, 156, 643, 6, 75,
93, 96, 16, 4, 55, 1546]

The sum of the list is: 2835


42

Program#26
Learning Outcome: Python Arithmetic Operators

Objective: Using libraries

Task: Write a program to calculate mean, median and


mode using Numpy.

INPUT:
#Write a program to calculate mean, median and mode
using Numpy

import numpy as np

data = np.array([165, 26, 39, 42, 65, 69, 157, 26, 49, 160])

mean = np.mean(data)

median = np.median(data)

mode = np.bincount(data).argmax()

print("The given data is:", data)

OUTPUT:
The given data is: [165 26 39 42 65 69 157 26 49 160]
43

Mean of the given data is: 79.8

Median of the given data is: 57.0

Mode of the given data is: 26

print("Mean of the given data is:", mean)

print("Median of the given data is:", median)

print("Mode of the given data is:", mode)


44

Program#27
Learning Outcome: Python Arithmetic Operators

Objective: Using libraries

Task: Write a program to display line charts from (2,5) to


(9,10).

INPUT:
#Write a program to display line chart from (2,5) to (9,10)

import matplotlib.pyplot as plt

import numpy as np

x_start, y_start = 2, 5

x_end, y_end = 9, 10

x = np.linspace(x_start, x_end, 100)

y = (y_end - y_start) / (x_end - x_start) * (x - x_start) +


y_start

plt.plot(x, y)

plt.xlabel("X")
45

plt.ylabel("Y")

plt.title("Line Chart")

plt.show()

OUTPUT:
46

Program#28
Learning Outcome: Python Arithmetic Operators

Objective: Using libraries

Task: Write a program to display a scatter chart for the


following points (2,5), (9,10),(8,3),(5,7),(6,18).

INPUT:
#Write a program to display a scatter chart for the
following points (2,5), (9,10),(8,3),(5,7),(6,18)

import matplotlib.pyplot as plt

x_coordinates = [2, 9, 8, 5, 6]

y_coordinates = [5, 10, 3, 7, 18]

plt.scatter(x_coordinates, y_coordinates)

plt.xlabel("X")

plt.ylabel("Y")

plt.title("Scatter Plot")

plt.show()
47

OUTPUT:
48

Program#29
Learning Outcome: Python Arithmetic Operators

Objective: Using libraries

Task: Read CSV file saved in your system and display 10


rows.

INPUT:
#Read CSV file saved in your system and display 10 rows

import pandas as pd

file_path = r“C:\Users\Home\Documents\country_full.csv”

df = pd.read_csv(file_path, encoding='latin1')

print(df.head(10))

OUTPUT:
49

Program#30
Learning Outcome: Python Arithmetic Operators

Objective: Using libraries

Task: Read CSV file saved in your system and display its
information.

INPUT:
#Write a program to display line chart from (2,5) to (9,10)

import matplotlib.pyplot as plt

import numpy as np

x_start, y_start = 2, 5

x_end, y_end = 9, 10

x = np.linspace(x_start, x_end, 100)

y = (y_end - y_start) / (x_end - x_start) * (x - x_start) +


y_start

plt.plot(x, y)

plt.xlabel("X")
50

plt.ylabel("Y")

plt.title("Line Chart")

plt.show()

OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy