You are on page 1of 23

COMPUTER SCIENCE PRACTICAL FILE

TERM - 1
SESSION – 2021-2022

SUMITTED TO- SUBMITTED BY-


KALPANA KAUSHIK DEEP KASHYAP
COMPUTER SCIENCE 11TH-SCIENCE
Roll no. - 12
INDEX

S.No. Program Name Date Teacher Sign.


1. To find out 2-08-21
average and grade
for given marks
2. To find the sell 6-08-21
price of an item
with a given cost
and discount.
3. To find the 10-08-21
perimeter and area
of shapes such as
triangle, rectangle,
square, circle.
4. To find out simple 16-08-21
and compound
interest.
5. To find out profit 27-08-21
and loss for given
cost and selling
price.
6. To calculate EMI 2-09-21
for amount period
and interest.
7. To calculate tax- 6-09-21
GST/income tax.
8. To find the largest 10-09-21
and smallest no. in
the list.
9. To find the third 14-09-21
largest and
smallest no. in the
list.
10. To find the sum of 21-09-21
squares of first 100
numbers.
11. To print first n 27-09-21
multiples of a
given no.
12. To count the no. of 28-09-21
vowels in user
given string
13. To print the words 4-10-21
starting with a
particular alphabet
in a user given
string.
14. Input any number 6-10-21
from user and
calculate factorial
of a number.
15. Input any number 9-10-21
from user and
check it is prime
no. or not.
Que-1. W.A.P. to find out average and grade for given marks?

#Deep , 11th sci. Computer science

CODE:
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")
OUTPUT:
Que-2. Wap To find the sell price of an item with a given cost
and discount?
#Deep , 11-sci.
CODE:
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)
OUTPUT:
Que-3. Wap to find the perimeter and area of shapes such as
triangle, rectangle, square, circle?
#Deep , 11 –sci.
CODE:
length = float(input("Enter length of the
rectangle: "))
breadth = float(input("Enter breadth of
the rectangle: "))
area = length * breadth
perimeter = 2 * (length * breadth)
print("Area of rectangle = ", area)
print("Perimeter of rectangle = ",
perimeter)
OUTPUT:
CODE:
#Deep , 11 – sci

b=int(input("Length : "))
h=int(input("Height : "))
area=0.5 * b * h
print("Area of Triangle : ",area)

OUTPUT:
CODE:
#deep,11-sci
s=int(input("Side : "))
area=s*s
perimeter=4*s
print("Area of Square : ",area)
print("Perimeter of Square : ",perimeter)
OUTPUT:
CODE:
#deep, 11 – sci
r=float(input("Input Radius : "))
area=3.14*r*r
perimeter=2*3.14*r
print("Area of Circle: ",area)
print("Perimeter of Circle: ",perimeter)

OUTPUT:
Que-4. Wap to find out simple and compound interest?
#deep 11-sci
CODE:
P= 5000
R=15
T=1
SI = (P*R*T)/100;
print(SI)

OUTPUT:
CODE:
#deep 11-Sci.
p = 25000
r = 36
t = 1
ci = p * (pow((1 + r / 100), t))
print(ci)

OUTPUT:
Que-5. Wap To find out profit and loss for given cost and
selling price?

#deep 11 – sci
CODE:
cp=float(input("Enter the Cost Price :
"));
sp=float(input("Enter the Selling Price :
"));
if cp==sp:
print("No Profit No Loss")
else:
if sp>cp:
print("Profit of ",sp-cp)
else:
print("Loss of ",cp-sp)
OUTPUT:
Que-6. Wap to calculate EMI for amount period and interest?
#deep 11-sci
CODE:
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)

OUTPUT:
Que-7. Wap to calculate tax-GST/income tax?
#deep 11 – sci
CODE:
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))

OUTPUT:
Que-8.Wap to find the largest and smallest no. in the list?
#deep 11 - sci
CODE:

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))
OUTPUT:
Que-9.Wap to find the third largest and smallest no. in the list?
#deep 11-sci
CODE:
list1 = [20,63,32,54,89,10]
print(sorted(list1))
print(sorted(list1)[-3])

OUTPUT:
Que -10.Wap to find the sum of squares of first 100 numbers?
#deep 11 –sci
CODE:
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)

OUTPUT:
Que-11. Wap to print first n multiples of a given no.?
#deep 11-sci
CODE:
number = int(input(“Enter number: “))

print(“The multiples are: “)


for i in range(1,11):
print(number*i, end =" ")
OUTPUT:
Que-12. Wap to count the no. of vowels in user given string?
#deep 11-sci
CODE:
string=("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)
OUTPUT:
Que-13. Wap to print the words starting with a particular
alphabet in a user given string?
#deep 11-sci
CODE:
import re
text = "The following example creates an
ArrayList with a capacity of 50 elements.
Four elements are then added to the
ArrayList and the ArrayList is trimmed
accordingly."
list = re.findall("[ae]\w+", text)
print(list)
OUTPUT:
Que – 14. Wap to Input any number from user and calculate
factorial of a number?
#deep 11-sci
CODE:
num = int(input("Enter a number: "))
factorial = 1
if num < 0:
print(" Factorial does not exist for
negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
print("Thefactorial
of",num,"is",factorial)

OUTPUT:
Que-15. Wap to Input any number from user and check it is
prime no. or not?
#deep 11-sci
CODE:
num=469
if num > 1:
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime
number")

print(i,"times",num//i,"is",num)
break
else:
print(num,"is a prime number")

OUTPUT:

You might also like