Practical
Practical
Practical
p = float(input('Enter principle'))
r = float(input('Enter rate'))
t = float(input('Enter time'))
i=p*r*t/100
print("Interest=",i)
Output:
Enter principle22000
Enter rate15
Enter time8
Interest= 26400.0
Practical No – 02
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
if num%2==0:
if num%3==0:
else:
else:
if num%3==0:
else:
Output:
Enter a number144
Divisible by 3 and 2
Practical No – 03
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
if choice==1 :
c=a+b
print("Sum=",c)
elif choice==2 :
c=a-b
print("Subtraction=",c)
elif choice==3 :
c=a*b
print("Multiplication=",c)
elif choice==4 :
c=a/b
print("Division=",c)
else :
print("Wrong choice")
Output:
1. Sum of two numbers
Multiplication= 4459455
Practical No – 04
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
eligible= a>=33
fail=a<20
if eligible :
print("Pass");
elif compartment :
print("compartment");
elif fail:
print("Fail");
Output:
Enter your percentage578
Pass
Practical No – 05
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
i=1
f=1
while i<=n:
f=f*i #1*2*3*4*5
i=i+1
print("Factorial of",n,"=",f)
Output:
Enter a number=57
Factorial of 57 =
405269195048772167556806019054323221349803847962266021451844812
80000000000000
Practical No – 06
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
print("Original List",aList)
n=len(aList)
for i in range(n-1):
for j in range(0,n-i-1):
if aList[j]>aList[j+1]:
aList[j],aList[j+1]=aList[j+1],aList[j]
print("Sorted List",aList)
Output:
Enter list:[34,65,23,67,54]
for i in range(1,len(aList)):
key=aList[i]
j=i-1
aList[j+1]=aList[j]
j=j-1
else:
aList[j+1]=key
Output:
Original list is = [15, 6, 13, 22, 3, 52, 2]
if a>b :
else:
return
largest()
Output:
Enter first number=67
Largest value=76
Practical No – 09
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
i=p*r*t/100
return(i)
p=int(input("Enter principle="))
r=int(input("Enter rate="))
t=int(input("Enter time="))
in1=interest(p,r,t)
print("Interest=",in1)
Output:
Enter principle=76890
Enter rate=14
Enter time=9
Interest= 96881.4
Practical No – 10
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
mylist[0]=n
return
changeme( list1,n )
Output:
Enter list:[78,95,45,67,65]
Enter value to mdify:63
outside function before calling function [78, 95, 45, 67, 65]
inside the function before change [78, 95, 45, 67, 65]
inside the function after change ['63', 95, 45, 67, 65]
outside function after calling function ['63', 95, 45, 67, 65]
Practical No – 11
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
return
name=input("Enter name:")
age=int(input("Enter age:"))
printinfo(name)
printinfo(name,age)
Output:
Enter name:'Ajay'
Enter age:56
Name: 'Ajay'
Age 35
Name: 'Ajay'
Age 56
Practical No – 12
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
size=0
tsize =0
while str1:
str1=myfile.readline()
tsize=tsize+len(Str1)
size=size+len(Str1.strip())
print(“Size of file after removing all EOL characters & blank lines:”,size)
myfile.close()
Output:
Size of the file after removing all EOL characters & blank lines: 360
fileout=open(“Marks.txt”,”w”)
for i in range(count):
rollno=int(input(“Roll no.:”))
name=input(“Name:”)
marks=float(input(“Marks:”))
rec=str(rollno)+”,”+name+”,”+str(marks)+’\n’
fileout.write(rec)
fileout.close()
Output:
Rollno: 12
Name: Hazel
Marks: 67.75
Rollno: 15
Name: Jiya
Marks: 78.5
Rollno: 16
Name: Noor
Marks: 68.9
Practical No – 13
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
#Write a program to read a text file line by line and display each
#word separated by a ‘#’.
Myfile=open(“Answer.txt”,”r”)
While line:
print(word,end=’#’)
print()
Myfile.close()
Output:
Letter#’a’#is#a#wonderful#letter.#
It#is#impossible#to#think#of#a#sentence#without#it.#
Practical No – 14
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
fh=open(“Student.csv”,”w”)
stuwriter.writerow(*‘Rollno’,’Name’,’Marks’+)
for i in range(5):
print(“Student record”,(i+1))
name=input(“Enter name:”)
marks=float(input(“Enter marks:”))
sturec=[rollno,name,marks]
stuwriter.writerow(sturec)
Output:
Student record 1
Enter rollno:11
Enter name: Nistha
Enter marks: 79
Student record 2
Enter rollno: 12
Enter marks: 89
Student record 3
Enter rollno: 13
Enter marks: 93
Practical No – 15
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
def Bsearch(AR,ITEM):
beg=0
last=len(AR)-1
while (beg<=last):
mid=(beg+last)/2
if (ITEM==AR[mid]):
return mid
elif (ITEM>AR[mid]):
beg=mid+1
else:
last=mid-1
else:
return False
#_main_
myList=[10,20,30,40,50,60,70]
print("The list in sorted order is")
print(myList)
position=Bsearch(myList,ITEM)
if position:
del myList[position]
print(myList)
else:
Output:
The list in sorted order is
”””
”””
Def isEmpty(stk) :
if stk==[] :
return True
else :
return False
def Push(stk,item) :
stk.append(item)
top=len(stk)-1
def Pop(stk) :
if isEmpty(stk) :
return”Underflow”
else :
item=stk.pop()
if len(stk)==0 :
top=len(stk)-1
return item
def Peek(stk) :
if isEmpty(stk) :
return”Underflow”
else:
top=len(stk)-1
return stk[top]
def Display(stk) :
if isEmpty(stk):
print(“Stack empty”)
else:
top=len(stk)-1
print(stk*top+,”<-top”)
for a in range(top-1,-1,-1):
print(stk[a])
#___main___
Stack=[]
Top=None
While True :
print(“STACK OPERATIONS”)
print(“1.Push”)
print(“2.Pop”)
print(“3.Peek”)
print(“4.Display stack”)
if ch==1 :
item=int(input(“Enter item:”))
Push(Stack,item)
elif ch ==2:
item=Pop(Stack)
if item==”Underflow”:
else:
elif ch==3 :
item=Peek(Stack)
if item ==”Underflow” :
else:
elif ch == 4:
Display(Stack)
elif ch==5 :
break
else:
print(“Invalid choice”)
Output:
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display
5. Exit
Enter item : 6
---------------------------
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display stack
5. Exit
Enter item : 8
--------------------------
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display stack
5. Exit
Enter item : 2
--------------------------
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display stack
5. Exit
Enter item : 4
--------------------------
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display stack
5. Exit
4<-top
------------------------
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display stack
5. Exit
Enter item : 4
-------------------------
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display stack
5. Exit
Enter your choice (1-5) : 4
4<-top
------------------------
STACK OPERATIONS
1. Push
2. Pop
3. Peek
4. Display stack
5. Exit
Objective-SQL QUERIES
SQL 1
(i) Display the Mobile company, Mobile name & price in descending
(ii) List the details of mobile whose name starts with “S”.
(iii) Display the Mobile supplier & quantity of all mobiles except
“MB003‟.
(iv) To display the name of mobile company having price between 3000 &
5000.
MB004 450
MB003 400
MB003 300
MB003 200
(vi) SELECT MAX(M_Mf_Date), MIN(M_Mf_Date) FROM MobileMaster;
2017-11-20 2010-08-21
AND M2.M_Qty>=300;
Classic Mobile
MB001 Galaxy 300
Store
5450
Practical No – 18
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
Objective-SQL QUERIES
SQL 2
theirHiredate.
Ans. SELECT TNAME, CITY, SALARY FROM TRAINER
ORDER BY HIREDATE;
ii. To display the TNAME and CITY of Trainer who joined the Institute in
AND „2001-12-31‟;
tables TRAINER and COURSE of all those courses whose FEES is less than
or equal to 10000.
GROUP BY CITY;
‘MUMBAI’);
Practical No – 19
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit :
Date : Chapter :
Remarks : Teacher’s sign :
SQL 3
iii ) To increase the fees of all courses by 500 of “System Design” Course.
SQL 4
i. To display all the details of those watches whose name ends with ‘Time’
ii. To display watch’s name and price of those watches which have price
iv. To display watch name and their quantity sold in first quarter.
SQL 5
(i) To display the records from table student in alphabetical order as per
order by name;
(ii ) To display Class, Dob and City whose marks is between 450 and 551.
(iii) To display Name, Class and total number of students who have
group by class
set marks=marks+20
where class=‟XII‟;