INFORMATICS PRACTICES (065)
CLASS - XI
PRACTICAL LIST
========================================
EXPERIMENT – 1
Objective: The marks
obtained by a student in 3 different subjects are input by the user. Your
program should calculate the average of subjects and display the grade. The
student gets a grade as per the following rules:
Average Grade
90-100 A
80-89 B
70-79 C
60-69 D
0-59 F
Solution:
sub1 = int(input("Enter marks obtained in subject 1: "))
sub2 = int(input("Enter marks obtained in subject 2: "))
sub3 = int(input("Enter marks obtained in subject 3: "))
avg_marks =(sub1+sub2+sub3)/3
print("Average mark:",avg_marks)
if avg_marks>=90:
print("Grade is A")
elif avg_marks>=80:
print("Grade is B")
elif avg_marks>=70:
print("Grade is C")
elif avg_marks>=60:
print("Grade is D")
else:
print("Grade is F")
EXPERIMENT – 2
Objective: WAP in Python to find the sale price of an item with a given cost and discount (%).
Solution:
price=float(input("Enter Price : "))
dp=float(input("Enter discount % : "))
discount=price*dp/100
sp=price-discount
print("Cost Price : ",price)
print("Discount: ",discount)
print("Selling Price : ",sp)
EXPERIMENT – 3
Objective: To calculate perimeter/circumference and area of shapes such as triangle, rectangle, square and circle.
Solution:
import math
def area_square(a):
area1=float(a*a);
print("Area of square is:",area1)
def area_circle(r):
area2=float(3.14*r*r);
print("Area of circle is:",area2)
def area_rectangle(a,b):
area3=float(a*b);
print("Area of rectangle is:",area3)
def area_triangle(x,y):
area4=float((x*y)/2);
print("Area of triangle is:",area4)
def peri_square(a):
peri1=float(4*a);
print("Perimeter of square is:",peri1)
def peri_circle(r):
peri2=float(2*3.14*r);
print("Perimter of circle is:",peri2)
def peri_triangle(a,b):
hypotenuse=float(math.sqrt(a*a+b*b))
peri3=float(a+b+hypotenuse)
print("Perimter of right angled triangle is:",peri3)
def peri_rectangle(a,b):
peri4=float(2*(a+b))
print("Perimter of rectangle is:",peri4)
side=float(input("enter the side of square:"))
area_square(side)
print()
peri_square(side)
radius=float(input("enter the radius of circle:"))
area_circle(radius)
peri_circle(radius)
length=float(input("enter the length of rectangle:"))
breadth=float(input("enter the breadth of rectangle:"))
area_rectangle(length,breadth)
peri_rectangle(length,breadth)
base=float(input("enter the base of right angled triangle:"))
height=float(input("enter the height of right angled triangle:"))
area_triangle(base,height)
peri_triangle(base,height)
EXPERIMENT - 4
Objective: To calculate Simple and Compound interest.
Solution:
principal = float(input('Enter amount: '))
time = float(input('Enter time: '))
rate = float(input('Enter rate: '))
simple_interest = (principal*time*rate)/100
compound_interest = principal * ( (1+rate/100)**time - 1)
print('Simple interest is: %f' % (simple_interest))
print('Compound interest is: %f' %(compound_interest))
EXPERIMENT - 5
Objective: Write a python program to input cost price, selling price of product from user and check whether is profit or loss and also print the Profit/loss amount
Solution:
cp=float(input("Enter the Cost Price : "));
sp=float(input("Enter the Selling Price : "));
if cp==sp:
print("No Profit No Loss")
elif sp>cp:
print("Profit of ",sp-cp)
else:
print("Loss of ",cp-sp)
EXPERIMENT - 6
Objective: Python program to calculate monthly EMI (Equated Monthly Instalments)
Solution:
# EMI Formula = p * r * (1+r)^n/((1+r)^n-1)
# Monthly Interest Rate (r) = R/(12*100)
# p = Principal or Loan Amount
# r = Interest Rate Per Month
# n = Number of monthly instalments
p = float(input("Enter principal amount: "))
R = float(input("Enter annual interest rate: "))
n = int(input("Enter number of months: " ))
r = R/(12*100)
emi = p * r * ((1+r)**n)/((1+r)**n - 1)
print("Monthly EMI = ", emi)
Objective: To calculate tax - GST / Income Tax.
Solution:
item=input("Enter item name :")
sp_cost=float(input("How much is selling price of item:"))
gst_rate=float(input("What is GST rate % :"))
cgst=sp_cost*((gst_rate/2)/100)
sgst=cgst
amt=sp_cost+cgst+sgst
print("CGST (@",(gst_rate/2),"%) :",(cgst))
print("SGST(@",(gst_rate/2),"%) :",(sgst))
print("Amount payable: ",(amt))
EXPERIMENT – 8
Objective: To find the largest and smallest numbers in a list.
Solution:
lst = [ ]
num = int(input('How many numbers: '))
for n in range(num):
numbers = int(input('Enter number '))
lst.append(numbers)
print("Maximum element in the list is :", max(lst), "\nMinimum
element in the list is :", min(lst))
EXPERIMENT – 9
Objective: To find the third largest/smallest number in a list.
Solution:
num = [2,3,7,4,5,6,10,11,120]
largest_num = num[0]
second_largest_num = num[0]
third_largest_num = num[0]
for i in num :
if i > largest_num :
third_largest_num = second_largest_num
second_largest_num = largest_num
largest_num = i
elif i > second_largest_num :
third_largest_num = second_largest_num
second_largest_num = i
elif i > third_largest_num :
third_largest_num = i
print("Third largest number of the list is
{}".format(third_largest_num))
EXPERIMENT – 10
Objective:To find the sum of squares of the first 100 natural
numbers.
Solution:
n = int(input("Enter nth number : "))
sum = 0
for s in range(1, n+1):
sum = sum + (s*s)
print("Sum of squares is : ", sum)
EXPERIMENT – 11
Objective:To print the first ‘n’ multiples of a given number.
Solution:
number = int(input("Enter number: "))
print("The multiples are: ")
for i in range(1,11):
print(number*i, end =" ")
EXPERIMENT – 12
Objective: To count the number of vowels in a user entered
string.
Solution:
string=input("Enter string:")
vowels=0
for i in string:
if(i=='a' or i=='e' or
i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'):
vowels=vowels+1
print("Number of vowels are:")
print(vowels)
==================================
No comments:
Post a Comment
Please do not any spam in the comment box.