Professional Documents
Culture Documents
Agra
PRACTICAL FILE
COMPUTER SCIENCE
[NEW] [083]
SESSION: 2019-20
Name: ABIGAIL
RODRIGUES Mr. SK Sharma
Class: XII-B PGT(Comp.sc)
Acknowledgement
I would like to express a deep sense of thanks &
gratitude to my subject teacher Mr. SK Sharma for guiding
me immensely through the course of the computer lab
practical. He always evinced keen interest in my work. His
constructive advice & constant motivation have been
responsible for the successful completion of this computer
lab file report.
My sincere thanks go to Mr. Yogesh Upadhyay, our
principal sir, for his co-ordination in extending every
possible support for the completion of this practical lab
file.
I also thanks to my parents for their motivation &
support. I must thanks to my classmates for their timely
help & support for compilation of this practical lab file.
Last but not the least, I would like to thank all those
who had helped directly or indirectly towards the
completion of this practical lab file.
ABIGAILRODRIGUES
Class:XIIB
Certificate
This is to certify that School ABIGAIL
RODRIGUES of class XII-B, All Saint School,
Agra has successfully completed his lab practical
in computer science (083) for the AISSCE as
prescribed by CBSE in the year 2019-20.
The report is the result of her efforts &
endeavors. She has prepared the computer lab file
under my guidance.
Date:
OUTPUT :--
PRACTICAL-2
def COUNTLINES():
file=open('file.txt','r')
count=0
for w in file.readlines():
if w[0]=="A" or w[0]=="a":
count=count+1
print('Total lines ',count)
COUNTLINES()
OUTPUT :--
PRACTICAL 3
3. Remove all the lines that contain the character `a' in a file
and write it to another file.
file=open('file.txt','r')
for i in file:
print(i)
OUTPUT;-
PRACTICAL 4
4. Write a Python function sin(x, n) to calculate the value of
sin(x) using its Taylor series expansion up to n terms.
Compare the values of sin(x) for different values of n with the
correct value.
import numpy as np
import matplotlib.pyplot as plt
def mysin(x, order):
a=x
s=a
for i in range(1, order):
a *= -1 * x**2 / ((2 * i) * (2 * i + 1))
s += a
return s
mysin = np.vectorize(mysin, excluded=['order'])
x = np.linspace(-80, 80, 500)
y2 = mysin(x, 2)
y10 = mysin(x, 10)
y100 = mysin(x, 100)
y1000 = mysin(x, 1000)
y = np.sin(x)
plt.plot(x, y, label='sin(x)')
plt.plot(x, y2, label='order 2')
plt.plot(x, y10, label='order 10')
plt.plot(x, y100, label='order 100')
plt.plot(x, y1000, label='order 1000')
plt.ylim([-3, 3])
plt.legend()
plt.show(
OUTPUT:-
PRACTICAL 5
import random
for i in range(11):
print("Dice value:- ",random.randint(1,6))
OUTPUT:-
PRACTICAL 6
OUTPUT:-
PRACTICAL 7
OUTPUT:-
PRACTICAL 8
OUTPUT:-
OUTPUT: -
PRACTICAL 10
OUTPUT:-
PRACTICAL 11
def Add():
L4=Label(window,text="Result : "+str(int(I1.get())+int(I2.get())))
L4.grid(column=2, row=8)
def Sub():
L4=Label(window,text="Result : "+str(int(I1.get())-int(I2.get())))
L4.grid(column=2, row=8)
def Mul():
L4=Label(window,text="Result : "+str(int(I1.get())*int(I2.get())))
L4.grid(column=2, row=8)
def Div():
L4=Label(window,text="Result : "+str(float(I1.get())/float(I2.get())))
L4.grid(column=2, row=8)
L1 = Label(window, text = "Number 1")
L1.grid(column=2, row=2)
L2 = Label(window, text = "Number 2")
L2.grid(column=2, row=4)
I1 = Entry(window, width = 10)
I1.grid(column=4, row=2)
I2 = Entry(window, width = 10)
I2.grid(column=4, row=4)
B1 = Button(window, text = "Add",command = Add)
B1.grid(column=1, row=6)
B2 = Button(window, text = "Subtract",command = Sub)
B2.grid(column=2, row=6)
B3 = Button(window, text = "Multiply",command = Mul)
B3.grid(column=3, row=6)
B4 = Button(window, text = "Divide",command = Div)
B4.grid(column=4, row=6)
window.mainloop()
OUTPUT:--
PRACTICAL 12
OUTPUT:-
PRACTICAL 13
OUTPUT:
PRACTICAL 14
OUTPUT:-
PRACTICAL 15
#simple recursion
def bp(sg,n):
if n>0:
print(sg[n],end='')
bp(sg,n-1)
elif n==0:
print(sg[0])
# main
s=input("ENTER A STRING:")
bp(s,len(s)-1)
OUTPUT:-
Data Management: SQL and
web-server
Q1. Find the min, max, sum, and average of the marks
in a student marks table.
Create table student (sid int PRIMARY KEY ,name varchar(20),marks
int);
Insert into student values(101,'Bill',45);
Insert into student values(102,'Mary',31);
Insert into student values(103,'Sue',95);
Insert into student values(104,'Tom',35);
Insert into student values(105,'Alex',75);
Insert into student values(106,'Sam',25);
Insert into student values(107,'Joan',90);
Select min(marks) as Minimum_Marks,max(marks)as
Maximum_Marks,sum(marks) as Sum,avg(marks) as Average from
student;
OUTPUT:-
2. Find the total number of customers from each country in
the table (customer ID, customer name, country) using group
by.
OUTPUT:-
3. Write a SQL query to order the (student ID, marks) table in
descending order of the marks.
OUTPUT:-