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

Artificial Intelligence

The document is a practical file for a student named Sanvi Sharma, detailing various programming tasks related to artificial intelligence. It includes code examples for checking numbers, voting eligibility, student grades, array creation, list manipulation, and calculating area, perimeter, and simple interest. Each section provides specific programming exercises and their corresponding Python code.

Uploaded by

Priyanka Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Artificial Intelligence

The document is a practical file for a student named Sanvi Sharma, detailing various programming tasks related to artificial intelligence. It includes code examples for checking numbers, voting eligibility, student grades, array creation, list manipulation, and calculating area, perimeter, and simple interest. Each section provides specific programming exercises and their corresponding Python code.

Uploaded by

Priyanka Sharma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

ArtificiAl intelligence

(code:417)

PrActicAl file
nAme:- sAnvi shArmA
clAss:- 10 e
th
index
• check if the number is Positive,
we Print An APProPriAte messAge…………………………………..1
• A ProgrAm to check if A Person cAn vote………………………2
• to check the grAde of A student…………………………………….3
• check if the number is Positive or negAtive or
zero And disPlAy An APProPriAte messAge……………..…….4
• creAting 1-d ArrAy……………………………………………………………5
• creAting 2-d ArrAy……………………………………………………………6
• creAting An ArrAy of evenly sPAced vAlues………………..7
• creAting An ArrAy of ones………………………………………………8
• creAting An ArrAy of zeros…………………………………………….9
• creAting An ArrAy with rAndom vAlues………………………10
• creAting An emPty ArrAy……………………………………………….11
• creAting A full ArrAy……………………………………………………12
• to Print elements from Pre-defined Point to end…………13
• using slicing from A list………………………………………………….14
• removing element from the set using the PoP()
method……………………………………………………………………………….15
• removing elements from list using remove()
method……………………………………………………………………………….16
• Addition of multiPle elements to the list At
the end (using extend method)………………………………………17
• Addition of element At sPecific Position
(using insert method)………………………………………………………18
• Addition of elements in the list……………………………………..19
• to cAlculAte AreA And Perimeter of A rectAngle…….20
• code to cAlculAte the simPle interest………………………...21
#Check if the number is positive, we print an appropriate
message
num = 3
if num > 0:
print(num, “is a positive number.”)
print(“this is always printed”)
num = -1
if num > 0:
print(num, “is a positive number.”)
print(“this is always printed”)

1
#A program to check if a person can vote
age=int(input("Enter Your Age"))
if age>=18:
print('You are eligible to vote')
else:
print("You are not eligible to vote")

2
#To check the grade of a student
marks = int(input("enter your marks"))
if marks > 75:
print("You get an A grade")
elif marks > 60:
print("You get a B grade")
else:
print("You get a C grade")

3
# In this program, we input a number check if the number is
positive or negative or zero and display an appropriate
message.
num = float(input("Enter a number: "))
if num == 0:
print("Zero")
elif num >0:
print("Positive number")
else:
print("Negative number")

4
#Creating 1-D Array:
import numpy as np
array1=np.array([10,20,30,40,50])
print(array1)

5
#Creating 2-D array
import numpy as np
array1=np.array([[10,20,30,40,50],[100,200,300,400,500]])
print(array1)

6
#Creating an array of evenly spaced values
import numpy as np
array1=np.arange(0,10,2)
print(array1)

7
#Creating an array of ones
import numpy as np
array1=np.ones(8)
print(array1)

8
#Creating an array of zeros
import numpy as np
array1=np.zeros((2,3))
print(array1)

9
#Creating an array with random values
import numpy as np
random_array=np.random.random((2,2))
print(random_array)

10
#Creating an empty array
import numpy as np
empty_array=np.array(())
print(empty_array)

11
#Creating a full array
import numpy as np
full_array=np.full ((2,3),5)
print(full_array)

12
# Print elements from a
# pre-defined point to end
List=[2,3,4,5,6,7,8]
Sliced_List= List[5:]
print("Elements sliced from 5th element till the end: ")
print(Sliced_List)

13
# Using Slicing from a List
List= ['G','O','O','D','M','O', 'R','N','I','N','G']
print("Initial List: ")
print(List)
# using Slice operation
Sliced_List = List[3:8]
print("Slicing elements in a range 3-8: ")
print(Sliced_List)

14
# Removing element from the Set using the pop() method
List = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,12]
print("Intial List: ")
print(List)
List.pop()
print("List after popping an element: ")
print(List)
# Removing element at a
# specific location from the
# Set using the pop() method
List.pop(2)
print("Content after pop ")
print(List)

15
# Removing elements from a List using Remove() method
List = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,12]
print("Intial List: ")
print(List)
# Removing elements from List
# using Remove() method
List.remove(1)
List.remove(12)
print("List after Removal:")
print(List)

16
#Addition of multiple elements to the list
List = [1,2,3,4]
print("Initial List: ")
print(List)
# Addition of multiple elements to the List at the end (using
Extend Method)
List.extend([8, 'Artificial', 'Intelligence'])
print("List after Extend Operation: ")
print(List)

17
# Addition of Element at specific Position(using Insert
Method)

List = [1,2,3,4]
print("Initial List: ")
print(List)
List.insert(3, 12)
List.insert(0, 'Kabir')
print("List after Insert Operation: ")
print(List)

18
# Addition of elements in the list
List = []
print("Initial blank List: ")
print(List)
# Addition of Elements
# in the List
List.append(1)
List.append(2)
List.append(4)
print("List after Addition :")
print(List)

19
# To calculate Area and Perimeter of a rectangle
L=int(input("Length"))
B=int(input("Breadth"))
Area=L*B
Perimeter=2*(L+B)
print("Area:",Area)
print("Perimeter:",Perimeter)

20
# Code to calculate the Simple Interest
principle_amount =int(input("Enter principle amount"))
roi = int(input("Enter rate of interest "))
time = int(input("Enter time period(in years)"))
simple_interest = (principle_amount * roi * time)/100
print("datatype of principle amount : ",
type(principle_amount))
print("datatype of rate of interest : ", type(roi))
print("value of simple interest : ", simple_interest)
print("datatype of simple interest : ", type(simple_interest))

21

You might also like