Practical No
Practical No
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 : Computational
Thinking and Programming
Date : Chapter : Flow of Control
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 : Computational
Thinking and Programming
Date : Chapter : Flow of Control
Remarks : Teacher’s sign :
if choice==1 :
c=a+b
print("Sum=",c)
elif choice==2 :
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 : Computational
Thinking and Programming
Date : Chapter : Flow of Control
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 : Computational
Thinking and Programming
Date : Chapter : Flow of Control
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 :Computational
Thinking and Programming
Date : Chapter : LIST
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]
#function
def largest():
if a>b :
else:
largest()
Output:
Enter first number=67
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 : Computational
Thinking and Programming
Date : Chapter : Working with
Functions
Remarks : Teacher’s sign :
mylist[0]=n
return
changeme( list1,n )
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 : Computational
Thinking and Programming
Date : Chapter : Working with
Functions
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 : Computational
Thinking and Programming
Date : Chapter : File Handling
Remarks : Teacher’s sign :
size=0
tsize =0
while str1:
str1=myfile.readline()
tsize=tsize+len(Str1)
size=size+len(Str1.strip())
myfile.close()
Output:
Size of the file after removing all EOL characters & blank lines: 360
The total size of the file: 387
Practical No – 12
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit : Computational
Thinking and Programming
Date : Chapter : File Handling
Remarks : Teacher’s sign :
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:
Roll no:12
Name:Hazel
marks:67.75
Roll no:15
Name:Jiya
marks:78.5
Roll no:16
Name:Noor
marks:68.9
Practical No – 13
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit : Computational
Thinking and Programming
Date : Chapter : File Handling
Remarks : Teacher’s sign :
Objective: To read a text file line by line and display each words
#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 : Computational
Thinking and Programming
Date : Chapter : File Handling
Remarks : Teacher’s sign :
fh=open("Student.csv","w")
stuwriter=csv.writerow(fh)
stuwriter.writerow(['Rollno','Name','Marks'])
for i in range(5):
print("Student record",(i+1))
rollno=int(input("Enter rollno:"))
name=input("Enter name:")
marks=float(input("Enter marks:"))
sturec=[rollno,name,marks]
stuwriter.writerow(sturec)
fh.close() #close file
Output:
Student record 1
Enter rollno:11
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 : Computational
Thinking and Programming
Date : Chapter : Working with
Functions
Remarks : Teacher’s sign :
size =len(AR)
for i in range(size):
print(AR[i],end=' ')
#___________main___________
AR=[None]*size
for i in range(size):
AR[i]=int(input("Element"+str(i)+":"))
traverse(AR)
Output:
Enter the size of linear list to be input:2
Element0:23
Element1:45
23 45
Practical No – 16
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit : Computational
Thinking and Programming
Date : Chapter : Data Structures
Remarks : Teacher’s sign :
”””
”””
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])
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("5. Exit")
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":
elif ch == 4:
Display(Stack)
elif ch==5:
break
else:
print("Invalid choice")
Output:
STACK OPERATIONS
1.Push
2.Pop
3.Peek
4. Display stack
5. Exit
Enter item6
STACK OPERATIONS
1.Push
2.Pop
3.Peek
4. Display stack
5. Exit
Enter your choice (1-5):1
Enter item8
STACK OPERATIONS
1.Push
2.Pop
3.Peek
4. Display stack
5. Exit
Enter item2
STACK OPERATIONS
1.Push
2.Pop
3.Peek
4. Display stack
5. Exit
Enter item4
STACK OPERATIONS
1.Push
2.Pop
3.Peek
4. Display stack
5. Exit
STACK OPERATIONS
1.Push
2.Pop
3.Peek
4. Display stack
5. Exit
Topmost item is 4
STACK OPERATIONS
1.Push
2.Pop
3.Peek
4. Display stack
5. Exit
2
8
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
2017-11-20 2010-08-21
AND M2.M_Qty>=300;
Classic Mobile
MB001 Galaxy 300
Store
5454
Practical No – 18
Class : XII B Subject: Computer Science
Name : Shivam Soni Unit : Database Management
Date : Chapter : Simple Queries in
SQL
Remarks : Teacher’s sign :
Objective-SQL QUERIES
SQL 2
i. Display the Trainer Name, City & Salary in descending order of
theirHiredate.
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 : Database Management
Date : Chapter : Simple Queries in
SQL
Remarks : Teacher’s sign :
SQL 3
i) To display details of those Faculties whose salary is greater than 12000.
ii) To display the details of courses whose fees is i n the range of 15000 to
iii ) To increase the fees of all courses by 500 of “System Design” Course.
(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‟;