AI Assignments for Practical Record Class-X
AI Assignments for Practical Record Class-X
ADVANCE PYTHON
1. Write a program in python to display your
name along with your age and school name in
separate lines.
Ans: name = input(“Enter your name:”)
age = int(input(“Enter your age:”))
school = input(“Enter your school name:”)
print (name, “\n”)
print (age, “\n”)
print (school)
2. Write a program in python to calculate the
total bill of house rent and electricity bill when the
user enters the electricity units consumed.
Ans: units= int(input(“Enter the electricity units
consumed:”))
price= int(input(“Enter the price of one unit of
electricity:”))
rent = 500
bill= rent + units*price
print (bill)
3. Write a program in python to find whether the
user is eligible for the job or not according to his
age
Ans: age = int(input(“Enter your age:”))
If age>=18:
print (“Eligible for the job”)
Else:
Print (“ Not eligible for the job”)
4. Write a program in python to print odd and
even series of number
Ans: Odd Series:
n= int(input(“Enter the numbers you want in the
series”))
a=1
for i in range (1,n+1,1):
print (a, end= ‘ ’)
a = a+2
Even Series:
n= int(input(“Enter the numbers you want in the
series”))
a=2
for i in range (1,n+1,1):
print (a, end= ‘ ’)
a = a+2
ASSIGNMENT-2
1.Write a program in python to print Fibonacci series
Ans: n= int(input(“Enter the numbers you want in the
series”))
a=0
b=1
print (a, b, end= ‘ ’)
For i in range (3, n+1, 1):
c= a + b
print (c, end= ‘ ’)
a=b
b=c
2.Write a program in python to make the following
pattern:
*
* *
* * *
* * * *
Ans: n= int(input(“Enter the number of lines you
want”))
for i in range (1, n+1, 1):
for j in range (1, n+1, 1):
print (“ * ”, end= ‘ ’)
print ( )
3.Write a program in python to make the following
pattern:
1
1 2
1 2 3
1 2 3 4
Ans: n= int(input(“Enter the number of lines you
want”))
for i in range (1, n+1, 1):
for j in range (1, n+1, 1):
print (“ j ”, end= ‘ ’)
print ( )
4.Write a program in python to find whether the
number entered by the user is palindrome or not
Ans: # palindrome number …..n = 3478
#output …. Reverse the number= 8743
n= input(“Enter the numbers in non-fraction form to
reverse”)
x=len(n)
rev=0
n=int(n)
m=n
if n>0:
for i in range (x):
r = n % 10
n = n // 10
rev = rev *10 + r
if (m==rev):
Print(“Answer is”, rev, “and”, m, “so number is
palindrome”)
else:
Print (“Answer is”, rev, “and”, m, “so number is
not palindrome”)
else
print (“Number must be positive”)
ASSIGNMENT-3
1.Write a program in python to print the following
pattern
4 4 4 4
3 3 3
2 2
1
Ans: n= int(input(“Enter the number of line you want
to print”))
a=n
for i in range (1, n+1):
for x in range (n, i-1, -1):
print (a, end= ‘ ’)
a = a-1
print ( “ ”)
2.Write a program in python to print the number of
vowels, consonant, digits and spaces in the text
entered by the user.
Ans. str=input(“Enter a string:”)
n=len(str)
x=0
v=0
c=0
s=0
d=0
while x<n:
if str[x]== ‘a’ or str[x]== ‘e’ or str[x]== ‘i’ or str[x]==
‘o’ or str[x]== ‘u’:
v=v+1
elif str[x]== ‘ ’:
s = s+1
elif str[x]== ‘0’ or str[x]== ‘1’ or str[x]== ‘2’ or
str[x]== ‘3’ or str[x]== ‘4’:
d= d+1
elif str[x]== ‘5’ or str[x]== ‘6’ or str[x]== ‘7’ or
str[x]== ‘8’ or str[x]== ‘9’:
d= d+1
else:
c = c+1
x = x+1
print (“vowels are”, v)
print (“Consonants are”, c)
print (“Spaces are”, s)
print (“Digits are”, d)
3.Write a program in python to make the following
pattern
1
1 2
1 2 3
1 2 3 4
1 2 3 4
1 2 3
1 2
1
Ans: n= int(input(“Enter the number of lines you want
to print”))
for i in range (1, n+1):
a=1
for x in range (n, i – 1, -1):
print (a, end= “ ”)
a= a+1
print (“ ”)
4.Write a program in python to make the following
pattern
1
1 2
1 2 3
1 2 3 4
Ans: n= int(input(“Enter the number of lines you want
to print”))
for i in range (1, n+1):
for c in range (n, i – 1, -1):
print (“ ”, end= “ ”)
for j in range (n, i+1):
print(j, end= “ ”)
print (“ ”)
ASSIGNMENT-4
DATA SCIENCE
1.Write a program in python to plot the data series:
Rol Name Clas M_Hind M_En M_Math M_EV
l s i g s S
No.
1 Ayan 4 56 67 62 59
2 Ayush 4 67 78 73 69
3 Suma 4 45 65 68 63
n
4 Juhi 4 69 78 75 72
5 Rohan 4 55 62 60 58
6 Raghu 4 66 73 71 70
7 Tarun 4 67 88 80 73
8 Zahir 4 78 83 73 72
9 Milan 4 79 73 68 68
10 Zubin 4 71 69 72 65
Create the above file and save is as student.csv
import pandas as pd
dataframe = pd.read_csv(“student.csv”)
print (dataframe.head())
Lemmatization
from nltk.stem import WordNetLemmatizer
l= WordNetLemmatizer()
wl= [“like”, “dryness”, “dried”, “liking”, “drys”,
“likes”]
for w in wl:
print(l.lemmatize(w))
ASSIGNMENT-7
EVALUATION
import pandas as pd
from pandas_ml import ConfusionMatrix
import matplotlib.pyplot as plt
data = {‘y_Actual’: [1,0,0,1,0,1,0,0,1,0,1,0],
‘Y_Predicted’: [1,1,0,1,0,1,1,0,1,0,0,0]
}
df = pd.DataFrame(data, columns = [‘y_Actual’,
‘Y_Predicted’])
Confusion matrix =
ConfusionMatrix(df[‘y_Actual’],df[‘y_Predicted’])
Confusion_Matrix.print_stats()
ASSIGNMENT-8
1.Write a program in Python to print String in output
Screen
Ans: print("Hello\n Sir")
print("I am", end = " ")
print("Student of")
print("KV No 4, BBSR")
O/P – Hello
Sir
I am student of
KV No4, BBSR
2. Write a program in Python to input name and age
and print it
Ans: #Program to Print Name and Age
nm = input("Enter your name : ")
age = input("Enter your age : ")
print("You are Mr. ", nm)
print("Your age is : ", age)
O/P - Enter your name : XYZ
Enter your age : 20
You are Mr. XYZ
Your age is :20
3. Write a program in Python to add two numbers
# Program to add two numbers
a = int(input("Enter First number : "))
b = int(input("Enter Second number : "))
c=a+b
print(a, " + ", b," = ", c)
O/P: Enter First number :10
Enter Second number :20
10+20 = 30
4. Write a program in Python to input 2 no.s and print
the addition and multiplication
#Program of Arithmetic Operator
a = int(input("Enter First number : "))
b = int(input("Enter Second number : "))
res1 = a + b
res2 = a * b
print(a," + ",b," = ", res1)
print(a," * ",b," = ", res2)
o/p: Enter First number : 9
Enter Second number : 6
9 + 6 = 15
9 * 6 = 54
ASSIGNMENT-9
1. Write a program in Python to input an integer and
print its square and cube
num = int(input("Enter any number :"))
sq = num*num
cu = num*num*num
print("Squre is ", sq)
print("Cube is ",cu)
o/p: Enter any number : 8
Square is 64
Cube is 512
2. Write a program in Python to input a number and print first 5
multiple of that number
#Program to print first 5 multiple
num1 = int(input("Enter any number : "))
m2 = num1*2
m3 = num1*3
m4 = num1*4
m5 = num1 *5
print("First five multiples are :")
print(num1, m2, m3, m4, m5)
o/p: Enter any number : 7
First five multiples are :
7 14 21 28 35
3. Write a program in Python to input Principal, Rate and time
and calculate Simple Interest.
#Program of Simple Interest
pr = int(input("Enter Principal : "))
rate = int(input("Enter Rate : "))
ti = int(input("Enter Time : "))
si = pr * rate * ti/100
print("Simple Interest is : ,si)
O/P: Enter Principal: 100
Enter Rate: 5
Enter Time: 3
Simple Interest is : 15.0
4. Write a program in Python to input two numbers and calculate
the Quotient and Remainder.
#Program of Quotient and Remainder
print("Program of Quotient and Remainder)
n1 = int(input("Enter First number : "))
n2 = int(input("Enter Second number : "))
R = n1 % n2
Q = n1 // n2
print("Quotient is : ",Q)
print("Remainder is : ",R)
O/P: Program of Quotient and Remainder
Enter First number: 22
Enter Second number:6
Quotient is : 3
Remainder is : 4
ASSIGNMENT-10
1. Write a program in Python to input the length and
breadth and calculate the area of the rectangle.
#Program to Calculate Rectangle
a =12
b=5
area = a * b
print("Length is : ",a)
print("Breadth is : ",b)
print("Area is : ", area)
O/P: Length is : 12
Breadth is : 5
Area is: 60
2. Write a program in Python to input your age and print
present age, age after 5 and 10 yrs.
# Program to print age after 5 yr and after 10 yr
age = int(input("Enter your present age : "))
age5 = age + 5
age10 = age + 10
print("Your present age is : ", age)
print("Your age after 5 years : ", age5)
print("Your age after 10 years : ", age10)
O/P: Enter your present age : 12
Your present age is : 12
Your age after 5 years : 17
Your age after 10 years : 22
3. Write a program in Python to input Cost Price and
Selling Price and Print Profit or Loss
#Program of Profit / Loss
print("Program - Profit or Loss")
cp = int(input("Enter Cost Price : "))
sp = int(input("Enter Selling Price : "))
if(cp>sp):
ans = cp - sp
print("Loss for Rs. ",ans)
elif(sp>cp):
ans = sp - cp
print("Profit for Rs. ",ans)
else:
print("No Profit No Loss")
O/P: Program – Profit or Loss
Enter Cost Price: 100
Enter Selling Price : 75
Loss for Rs. 25
Program – Profit or Loss
Enter Cost Price: 80
Enter Selling Price : 110
Profit for Rs. 30
4. Write a program in Python to input the marks of students and
find Pass or Fail
#Student pass or fail
mark = int(input("Enter Marks of Student : "))
if(mark >= 33):
print("Student Pass")
else :
print("Student Fail")
print("Over")
O/P: Enter Marks of Student : 65
Student Pass
Over
Enter Marks of Student : 21
Student Fail
Over
ASSIGNMENT-11
1. Write a program to input a number and find whether it is Zero,
Positive or negative
#Number to find whether Positive, Negative or Zero
num = int(input("Enter any Number : "))
if(num>=0):
if(num==0):
print("Number is ZERO")
else:
print("Positive number")
else:
print("Negative number")
O/P: Enter any Number :5
Positive number
Enter any Number :-5
Negative number
2. Write a program in Python to input a number and print its
absolute number.
#program Absolute
num = int(input("Enter any number: "))
if(num<0):
num = -1*num
print("Absolute number is :",num)
O/P: Enter any number: -9
Absolute number is : 9
Enter any number: 99
Absolute number is : 99
3. Write a program in Python to input Marks and print the grade
based on the marks