SlideShare a Scribd company logo
3
[Document title]
Prof. K. Adisesha Page 3
6. Write a program to check a number whether it is palindrome or not.
num=int(input("Enter a number : "))
n=num
res=0
while num>0:
rem=num%10
res=rem+res*10
num=num//10
if res==n:
print(n,": Number is Palindrome")
else:
print(n, ": Number is not Palindrome")
7. Write a program to test if a string is palindrome or not.
SOURCE CODE:
string = input("Please enter your own String : ")
if(string == string[:: - 1]):
print(string, ": is a Palindrome String")
else:
print(string, ": is Not a Palindrome String")
8. Write a program to calculate Simple and compound interest.
p=float(input("Enter the principal amount : "))
r=float(input("Enter the rate of interest : "))
t=float(input("Enter the time in years : "))
SI=(p*t*r)/100
x=(1+r/100)**t
CI= p*x-p
print("Simple interest is : ", round(SI,2))
print("Compound interest is : ", round(CI,2))
Most read
5
[Document title]
Prof. K. Adisesha Page 5
11.Program to create a dictionary containing names of competition winner
students as key number of their wins as values
SOURCE CODE:
n=int(input("How many students? "))
winners ={ }
for a in range(n):
key=input("Name of the student : ")
value=int(input ("Number of competitions won : "))
winners [key]=value
print ("The dictionary now is : ")
print (winners)
12.Write a program to calculate the factorial of an integer using recursion.
SOURCE CODE:
def factorial(n):
if n == 1:
return n
else:
return n*factorial(n-1)
num=int(input("enter the number: "))
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
print("The factorial of ",num," is ", factorial(num))
Most read
7
[Document title]
Prof. K. Adisesha Page 7
15.Write a program for linear search.
SOURCE CODE:
L=int(input("Enter the list size:"))
a=[]
loc=-1
for i in range(L):
num=int(input("Enter the number"))
a.append(num)
print (a)
n=len(a)
item=eval(input("Enter the element that you want to search : "))
for i in range(n):
if a[i]==item:
loc=i+1
break
if loc > -1:
print("Element found at the position :", i+1)
else:
print("Element not Found")
16.Write a program for bubble sort.
SOURCE CODE:
L=int(input("Enter the list size:"))
a=[]
loc=-1
Most read
[Document title]
Prof. K. Adisesha Page 1
COMPUTER SCIENCE
PYTHON PRACTICAL PROGRAMS
1. Program to obtain length and breadth of a rectangle and calculate its area.
Solution.
#to input length and breadth of a rectangle and calculate its area
length = float( input("Enter length of the rectangle : "))
breadth= float( input (" Enter breadth of the rectangle: "))
area=length * breadth
print ("Rectangle specifications ")
print ("Length = ", length)
print ("breadth ", breadth)
print ("Area = ", area)
2. Write a program in python to display even and odd numbers from 1 to N.
Solution.
num=int(input("Enter the Range:"))
for i in range(1,num+1):
if i%2==0:
print(i, "is even number")
else:
print(i,"is odd number")
3. Write a program in python to all print prime number from 1 to n.
Solution.
num=int(input("Enter the number:"))
for val in range(1,num + 1):
# If num is divisible by any number
# between 2 and num, it is not prime
[Document title]
Prof. K. Adisesha Page 2
if num > 1:
for n in range(2, val):
if (val % n) == 0:
break
else:
print(val)
4. Write Python script to print the following for n numbers pattern:
1
1 3
1 3 5
1 3 5 7
Solution.
num=int(input("Enter the number:"))
for a in range (2, num, 2):
for b in range (1, a, 2):
print (b, end =(' '))
print ()
5. Write a program to find sum of the series: S=1+ X + X2
+X3
+….Xn
Solution.
x = int ( input ( "Enter value of X :" ) )
n= int (input( "Enter value of n (for x ** y) :" ))
s=0
for a in range(n):
s += x ** a
print ("Sum of first" , x,'^',a , "terms :", s)
[Document title]
Prof. K. Adisesha Page 3
6. Write a program to check a number whether it is palindrome or not.
num=int(input("Enter a number : "))
n=num
res=0
while num>0:
rem=num%10
res=rem+res*10
num=num//10
if res==n:
print(n,": Number is Palindrome")
else:
print(n, ": Number is not Palindrome")
7. Write a program to test if a string is palindrome or not.
SOURCE CODE:
string = input("Please enter your own String : ")
if(string == string[:: - 1]):
print(string, ": is a Palindrome String")
else:
print(string, ": is Not a Palindrome String")
8. Write a program to calculate Simple and compound interest.
p=float(input("Enter the principal amount : "))
r=float(input("Enter the rate of interest : "))
t=float(input("Enter the time in years : "))
SI=(p*t*r)/100
x=(1+r/100)**t
CI= p*x-p
print("Simple interest is : ", round(SI,2))
print("Compound interest is : ", round(CI,2))
[Document title]
Prof. K. Adisesha Page 4
9. Write a program to input a character and to print whether a given character
is an alphabet, digit or any other character.
SOURCE CODE:
ch=input("Enter a character: ")
if ch.isalpha():
print(ch, "is an alphabet")
elif ch.isdigit():
print(ch, "is a digit")
elif ch.isalnum():
print(ch, "is alphabet and numeric")
else:
print(ch, "is a special symbol")
10.Program to count frequency of a given element in a list of numbers
SOURCE CODE:
Lst=eval(input ( " Enter list :"))
length=len(Lst)
element=int(input( " Enter element :"))
count=0
for i in range(0, length):
if element==Lst [i]:
count += 1
if count == 0:
print (element, "not found in given list")
else:
print(element, "has frequency as", count, "in given list")
[Document title]
Prof. K. Adisesha Page 5
11.Program to create a dictionary containing names of competition winner
students as key number of their wins as values
SOURCE CODE:
n=int(input("How many students? "))
winners ={ }
for a in range(n):
key=input("Name of the student : ")
value=int(input ("Number of competitions won : "))
winners [key]=value
print ("The dictionary now is : ")
print (winners)
12.Write a program to calculate the factorial of an integer using recursion.
SOURCE CODE:
def factorial(n):
if n == 1:
return n
else:
return n*factorial(n-1)
num=int(input("enter the number: "))
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
print("The factorial of 0 is 1")
else:
print("The factorial of ",num," is ", factorial(num))
[Document title]
Prof. K. Adisesha Page 6
13.Write a program to print fibonacci series using recursion.
SOURCE CODE:
def fibonacci(n):
if n<=1:
return n
else:
return(fibonacci(n-1)+fibonacci(n-2))
num=int(input("How many terms you want to display: "))
for i in range(1,num+1):
print(fibonacci(i)," ", end=" ")
14.To write a Python program to find the maximum of a list of numbers.
n=int(input("Enter the list size:"))
a=[]
for i in range(n):
num=int(input("Enter the number"))
a.append(num)
print (a)
max=a[0]
for i in range(n):
if(max<a[i]):
max=a[i]
print ("maximum",max)
[Document title]
Prof. K. Adisesha Page 7
15.Write a program for linear search.
SOURCE CODE:
L=int(input("Enter the list size:"))
a=[]
loc=-1
for i in range(L):
num=int(input("Enter the number"))
a.append(num)
print (a)
n=len(a)
item=eval(input("Enter the element that you want to search : "))
for i in range(n):
if a[i]==item:
loc=i+1
break
if loc > -1:
print("Element found at the position :", i+1)
else:
print("Element not Found")
16.Write a program for bubble sort.
SOURCE CODE:
L=int(input("Enter the list size:"))
a=[]
loc=-1
[Document title]
Prof. K. Adisesha Page 8
for i in range(L):
num=int(input("Enter the number"))
a.append(num)
print (a)
n=len(a)
for p in range(0,n-1):
for i in range(0,n-1):
if a[i]>a[i+1]:
t=a[i]
a[i]=a[i+1]
a[i+1]=t
print("The sorted list is : ", a)
17.Program to input two numbers and print their LCM and HCF.
SOURCE CODE:
X=int(input("Enter first number:"))
Y= int (input("Enter second number:"))
if X >Y:
smaller = Y
else:
smaller = X
for i in range(1, smaller + 1):
if((X % i==0) and (Y % i == 0) ) :
hcf = i
lcm=(X* Y) / hcf
print("The H.C.F. of", X, "and ", Y, "is", hcf)
print("The L.C.M. of", X, "and ", Y, "is", lcm)
[Document title]
Prof. K. Adisesha Page 9
18.Write a python function sin(x, n) to calculate the value of sin(x) using its
taylor series expansion up to n terms.
SOURCE CODE:
import math
def fact(k):
if k<=1:
return 1
else:
return k*fact(k-1)
step=int(input("How many terms : "))
x=int(input("Enter the value of x :"))
sum=0
for i in range(step+1):
sum+=(math.pow(-1,i)*math.pow(x,2*i+1))/fact(2*i+1)
print("The result of sin",'(', x, ')', "is :", sum)
19.Write a program to display ASCII code of a character and vice versa.
SOURCE CODE:
var=True
while var:
choice=int(input("Press-1 to find the ordinal value of a character
nPress-2 to find a character of a valuen"))
if choice==1:
ch=input("Enter a character : ")
print(ord(ch))
elif choice==2:
val=int(input("Enter an integer value: "))
print(chr(val))
else:
print("You entered wrong choice")
print("Do you want to continue? Y/N")
option=input()
if option=='y' or option=='Y':
var=True
else:
var=False
[Document title]
Prof. K. Adisesha Page 10
SQL Program
SQL PROGRAMS
PART-B
Exp A: CREATE A STUDENT DATABASE AND COMPUTE THE RESULT.
1) Create a student database and compute the result.
Query 1:
 Create table student(stud_id number(4), stud_name varchar2(20),
Computer number(3), Maths number(3), Physics number(3), Chem
number(3));
2) Add record into the table for 5 students, using insert command.
Query 2:
 insert into student values('101','arun','69','70','55','90');
 insert into student values('102','Sunny','39','50','58','67');
 insert into student values('103','Prajwal','67','40','59','89');
 insert into student values('104','Satish','20','30','56','45');
 insert into student values('105','Rekha','19','70','89','40');
3) Display the description of the fields in table using desc command.
Query3:
 desc table student;
 desc student;
4) Display all records form the Student table using select command:
Query4:
 Select * from student;
5) Add to new fields to the table :
*total number(3)
FIELD NAME DATA TYPE
StudentID Number(4)
Studentname Varchar(20)
Computer Number(3)
Maths Number(3)
Physics Number(3)
Chem Number(3)
[Document title]
Prof. K. Adisesha Page 11
Query5:
 Alter table student add (total number (3));
6) Calculate total Marks.
Query6:
 Update student set total=Comp+Maths+Physics+Chem;
7) Find the min, max, sum, and average of the marks in a student marks table.
Query7:
 SELECT min(total) FROM student;
 SELECT max(total) FROM student;
 SELECT sum(total) FROM student;
 SELECT avg(total) FROM student;
8) Add to new fields to the table:
*percentage number(3)
*result varchar2(10)
Query8:
 Alter table student add (percentage number (3), result varchar2(10));
(9) Calculate Percentage Marks.
Query9:
 Update student set percentage=total/4 where studentid>0;
10)Compute the result as "pass" or "fail" by checking if the student has scored
more than 35 marks in each subject.
Query10(a):
 Update student set result='pass' where Comp>=35 and Maths>=35 and
Physics>=35 and Chem>=35;
Query 10(b):
 Update student set result='fail' where Comp<35 or Maths<35 or
Physics<35 or Chem<35;
11)Retrieve all the records of the table.
Query 11:
 Select * from student;
12) Retrieve only student_id and student_name of all the students.
Query 12:
[Document title]
Prof. K. Adisesha Page 12
 select student_id, student_name from student;
13) List the students who have the result as "pass".
Query 13:
 select * from student where result='pass';
14)List the students who have the result as "fail".
Query 14:
 select * from student where result='fail';
15)Count the number of students who have passed and failed.
 Query 15(a): select count (*) from student where result='pass';
 Query 15(b): select count (*) from student where result='fail';
Exp B: CONSIDER THE FOLOWING TABLE GAMES COMPUTE THE RESULT:
Table: GAMES
GCODE GAMENAME Type NUMBER PRIZE SCHEDULE
101 CaromBoard Indoor 2 5000 23-Jan-2019
102 Badminton Outdoor 2 12000 12-Dec-2019
103 TableTennis Indoor 4 8000 14-Feb-2019
104 Chess Indoor 2 9000 01-Sep-2019
105 Cricket Outdoor 4 25000 19-Mar-2019
Write SQL commands for the flowing statements:
1) Create a game database and compute the result.
Query 1:
 Create table games(gcode number(4), g_name varchar2(20), type
varchar2(10),gnumber number(3), gprize number(10), schedule date);
2) Add record into the table games.
Query 2:
insert into game values(101,' CaromBoard',' Indoor ',2, 5000,'23-Jan-2019');
insert into game values(102,' Badminton ',' Outdoor ',2, 12000, '12-Dec-2019');
insert into game values(103,' TableTennis ',' Indoor ',4, 8000,'14-Feb-2019');
insert into game values(104,' Chess ',' Indoor ',2, 9000,'01-Sep-2019');
insert into game values(105,' Cricket ',' Outdoor ',4, 25000, '19-Mar-2019');
[Document title]
Prof. K. Adisesha Page 13
3) To display the name of all GAMES with their GCodes.
Query 3: select gcodes, gamename from games;
4) To display details of those GAMES which are scheduled between 02-Mar-
2014 and 10-Dec-2019.
Query 4: select * from games where scheduledate between ‘02-mar-2019'
and '10-dec-2019';
5) To display the content of the GAMES table in ascending order of Schedule
Date.
Query 5: select * from games order by scheduledate;
6)To display sum of Prize Money for each Type of GAMES.
Query 6: select sum(prizemoney) from games order by type;
(B) Give the output of the following SQL queries:
1) select count(distinct number) from games;
OUTPUT 1:
count(distinct number)
----------------------------------
2
2) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
OUTPUT 2:
max(scheduledate) min(scheduledate)
---------------------------- --------------------------------
23-jan-2016 12-dec-2019

More Related Content

What's hot (20)

Python- Regular expression
Python- Regular expressionPython- Regular expression
Python- Regular expression
Megha V
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
Mohammed Sikander
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in C
Muthuganesh S
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in c
Prabhu Govind
 
IMPLEMENTATION OF AUTO KEY IN C++
IMPLEMENTATION OF AUTO KEY IN C++IMPLEMENTATION OF AUTO KEY IN C++
IMPLEMENTATION OF AUTO KEY IN C++
Sanjay Kumar Chakravarti
 
File handling in c
File handling in cFile handling in c
File handling in c
aakanksha s
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Chapter 8 Inheritance
Chapter 8 InheritanceChapter 8 Inheritance
Chapter 8 Inheritance
Amrit Kaur
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
programming9
 
PYTHON FEATURES.pptx
PYTHON FEATURES.pptxPYTHON FEATURES.pptx
PYTHON FEATURES.pptx
MaheShiva
 
Functions in C
Functions in CFunctions in C
Functions in C
Shobhit Upadhyay
 
Python recursion
Python recursionPython recursion
Python recursion
Prof. Dr. K. Adisesha
 
Python Control structures
Python Control structuresPython Control structures
Python Control structures
Siddique Ibrahim
 
Function in c
Function in cFunction in c
Function in c
Raj Tandukar
 
Function in c
Function in cFunction in c
Function in c
savitamhaske
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
Appili Vamsi Krishna
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Edureka!
 
Python Notes.pdf
Python Notes.pdfPython Notes.pdf
Python Notes.pdf
sunithareddy78
 
Python- Regular expression
Python- Regular expressionPython- Regular expression
Python- Regular expression
Megha V
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in C
Muthuganesh S
 
Memory allocation in c
Memory allocation in cMemory allocation in c
Memory allocation in c
Prabhu Govind
 
File handling in c
File handling in cFile handling in c
File handling in c
aakanksha s
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Chapter 8 Inheritance
Chapter 8 InheritanceChapter 8 Inheritance
Chapter 8 Inheritance
Amrit Kaur
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
programming9
 
PYTHON FEATURES.pptx
PYTHON FEATURES.pptxPYTHON FEATURES.pptx
PYTHON FEATURES.pptx
MaheShiva
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Edureka!
 

Similar to Xi CBSE Computer Science lab programs (20)

xii cs practicals class 12 computer science.pdf
xii cs practicals class 12 computer science.pdfxii cs practicals class 12 computer science.pdf
xii cs practicals class 12 computer science.pdf
gmaiihghtg
 
python practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfpython practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdf
rajatxyz
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdfsolution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
parthp5150s
 
Python program For O level Practical
Python program For O level Practical Python program For O level Practical
Python program For O level Practical
pavitrakumar18
 
xii cs practicals
xii cs practicalsxii cs practicals
xii cs practicals
JaswinderKaurSarao
 
Basic python laboratoty_ PSPP Manual .docx
Basic python laboratoty_ PSPP Manual .docxBasic python laboratoty_ PSPP Manual .docx
Basic python laboratoty_ PSPP Manual .docx
Kirubaburi R
 
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
anuragupadhyay0537
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL
Rishabh-Rawat
 
python file for easy way practicle programs
python file for easy way practicle programspython file for easy way practicle programs
python file for easy way practicle programs
vineetdhand2004
 
Python..._Practical_.goated programs.pptx
Python..._Practical_.goated programs.pptxPython..._Practical_.goated programs.pptx
Python..._Practical_.goated programs.pptx
GoatME
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
Arockia Abins
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
Vishal Singh
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptx
jeyel85227
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
ArghodeepPaul
 
Functions Practice Sheet.docx
Functions Practice Sheet.docxFunctions Practice Sheet.docx
Functions Practice Sheet.docx
SwatiMishra364461
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
BAINIDA
 
R basic programs
R basic programsR basic programs
R basic programs
Priya Shetty
 
Python Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docxPython Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docx
ShylajaS14
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
srxerox
 
xii cs practicals class 12 computer science.pdf
xii cs practicals class 12 computer science.pdfxii cs practicals class 12 computer science.pdf
xii cs practicals class 12 computer science.pdf
gmaiihghtg
 
python practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfpython practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdf
rajatxyz
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdfsolution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
parthp5150s
 
Python program For O level Practical
Python program For O level Practical Python program For O level Practical
Python program For O level Practical
pavitrakumar18
 
Basic python laboratoty_ PSPP Manual .docx
Basic python laboratoty_ PSPP Manual .docxBasic python laboratoty_ PSPP Manual .docx
Basic python laboratoty_ PSPP Manual .docx
Kirubaburi R
 
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
678676286-CLASS-12-COMPUTER-SCIENCE-PRACTICAL-FILE-2023-24.pdf
anuragupadhyay0537
 
CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL CBSE Class 12 Computer practical Python Programs and MYSQL
CBSE Class 12 Computer practical Python Programs and MYSQL
Rishabh-Rawat
 
python file for easy way practicle programs
python file for easy way practicle programspython file for easy way practicle programs
python file for easy way practicle programs
vineetdhand2004
 
Python..._Practical_.goated programs.pptx
Python..._Practical_.goated programs.pptxPython..._Practical_.goated programs.pptx
Python..._Practical_.goated programs.pptx
GoatME
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
Vishal Singh
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptxANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptx
jeyel85227
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
ArghodeepPaul
 
Functions Practice Sheet.docx
Functions Practice Sheet.docxFunctions Practice Sheet.docx
Functions Practice Sheet.docx
SwatiMishra364461
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
BAINIDA
 
Python Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docxPython Laboratory Programming Manual.docx
Python Laboratory Programming Manual.docx
ShylajaS14
 
III MCS python lab (1).pdf
III MCS python lab (1).pdfIII MCS python lab (1).pdf
III MCS python lab (1).pdf
srxerox
 
Ad

More from Prof. Dr. K. Adisesha (20)

Design and Analysis of Algorithms ppt by K. Adi
Design and Analysis of Algorithms ppt by K. AdiDesign and Analysis of Algorithms ppt by K. Adi
Design and Analysis of Algorithms ppt by K. Adi
Prof. Dr. K. Adisesha
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
Operating System-4 "File Management" by Adi.pdf
Operating System-4 "File Management" by Adi.pdfOperating System-4 "File Management" by Adi.pdf
Operating System-4 "File Management" by Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System-3 "Memory Management" by Adi.pdf
Operating System-3 "Memory Management" by Adi.pdfOperating System-3 "Memory Management" by Adi.pdf
Operating System-3 "Memory Management" by Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System Concepts Part-1 by_Adi.pdf
Operating System Concepts Part-1 by_Adi.pdfOperating System Concepts Part-1 by_Adi.pdf
Operating System Concepts Part-1 by_Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System-2_Process Managementby_Adi.pdf
Operating System-2_Process Managementby_Adi.pdfOperating System-2_Process Managementby_Adi.pdf
Operating System-2_Process Managementby_Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Prof. Dr. K. Adisesha
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
Prof. Dr. K. Adisesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
Prof. Dr. K. Adisesha
 
Introduction to Computers.pdf
Introduction to Computers.pdfIntroduction to Computers.pdf
Introduction to Computers.pdf
Prof. Dr. K. Adisesha
 
R_Programming.pdf
R_Programming.pdfR_Programming.pdf
R_Programming.pdf
Prof. Dr. K. Adisesha
 
Scholarship.pdf
Scholarship.pdfScholarship.pdf
Scholarship.pdf
Prof. Dr. K. Adisesha
 
Design and Analysis of Algorithms ppt by K. Adi
Design and Analysis of Algorithms ppt by K. AdiDesign and Analysis of Algorithms ppt by K. Adi
Design and Analysis of Algorithms ppt by K. Adi
Prof. Dr. K. Adisesha
 
Data Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsxData Structure using C by Dr. K Adisesha .ppsx
Data Structure using C by Dr. K Adisesha .ppsx
Prof. Dr. K. Adisesha
 
Operating System-4 "File Management" by Adi.pdf
Operating System-4 "File Management" by Adi.pdfOperating System-4 "File Management" by Adi.pdf
Operating System-4 "File Management" by Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System-3 "Memory Management" by Adi.pdf
Operating System-3 "Memory Management" by Adi.pdfOperating System-3 "Memory Management" by Adi.pdf
Operating System-3 "Memory Management" by Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System Concepts Part-1 by_Adi.pdf
Operating System Concepts Part-1 by_Adi.pdfOperating System Concepts Part-1 by_Adi.pdf
Operating System Concepts Part-1 by_Adi.pdf
Prof. Dr. K. Adisesha
 
Operating System-2_Process Managementby_Adi.pdf
Operating System-2_Process Managementby_Adi.pdfOperating System-2_Process Managementby_Adi.pdf
Operating System-2_Process Managementby_Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdfSoftware Engineering notes by K. Adisesha.pdf
Software Engineering notes by K. Adisesha.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdfSoftware Engineering-Unit 1 by Adisesha.pdf
Software Engineering-Unit 1 by Adisesha.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdfSoftware Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Software Engineering-Unit 2 "Requirement Engineering" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdfSoftware Engineering-Unit 3 "System Modelling" by Adi.pdf
Software Engineering-Unit 3 "System Modelling" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdfSoftware Engineering-Unit 4 "Architectural Design" by Adi.pdf
Software Engineering-Unit 4 "Architectural Design" by Adi.pdf
Prof. Dr. K. Adisesha
 
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdfSoftware Engineering-Unit 5 "Software Testing"by Adi.pdf
Software Engineering-Unit 5 "Software Testing"by Adi.pdf
Prof. Dr. K. Adisesha
 
Computer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. AdiseshaComputer Networks Notes by -Dr. K. Adisesha
Computer Networks Notes by -Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. AdiaeshaCCN Unit-1&2 Data Communication &Networking by K. Adiaesha
CCN Unit-1&2 Data Communication &Networking by K. Adiaesha
Prof. Dr. K. Adisesha
 
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. AdiseshaCCN Unit-3 Data Link Layer by Dr. K. Adisesha
CCN Unit-3 Data Link Layer by Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. AdiseshaCCN Unit-4 Network Layer by Dr. K. Adisesha
CCN Unit-4 Network Layer by Dr. K. Adisesha
Prof. Dr. K. Adisesha
 
CCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdfCCN Unit-5 Transport & Application Layer by Adi.pdf
CCN Unit-5 Transport & Application Layer by Adi.pdf
Prof. Dr. K. Adisesha
 
Ad

Recently uploaded (20)

How to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo SlidesHow to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
Celine George
 
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdfTechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup
 
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdfপ্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
Pragya - UEM Kolkata Quiz Club
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
RVSPSOA
 
Order: Odonata Isoptera and Thysanoptera.pptx
Order: Odonata Isoptera and Thysanoptera.pptxOrder: Odonata Isoptera and Thysanoptera.pptx
Order: Odonata Isoptera and Thysanoptera.pptx
Arshad Shaikh
 
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptxQUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
Sourav Kr Podder
 
"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx
Arshad Shaikh
 
Pragya Champion's Chalice 2025 Set , General Quiz
Pragya Champion's Chalice 2025 Set , General QuizPragya Champion's Chalice 2025 Set , General Quiz
Pragya Champion's Chalice 2025 Set , General Quiz
Pragya - UEM Kolkata Quiz Club
 
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
0b - THE ROMANTIC ERA: FEELINGS AND IDENTITY.pptx
Julián Jesús Pérez Fernández
 
Odoo 18 Point of Sale PWA - Odoo Slides
Odoo 18 Point of Sale PWA  - Odoo  SlidesOdoo 18 Point of Sale PWA  - Odoo  Slides
Odoo 18 Point of Sale PWA - Odoo Slides
Celine George
 
Coleoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptxColeoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptx
Arshad Shaikh
 
K-Circle-Weekly-Quiz-May2025_12345678910
K-Circle-Weekly-Quiz-May2025_12345678910K-Circle-Weekly-Quiz-May2025_12345678910
K-Circle-Weekly-Quiz-May2025_12345678910
PankajRodey1
 
Search Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website SuccessSearch Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website Success
muneebrana3215
 
Writing Research Papers: Guidance for Research Community
Writing Research Papers: Guidance for Research CommunityWriting Research Papers: Guidance for Research Community
Writing Research Papers: Guidance for Research Community
Rishi Bankim Chandra Evening College, Naihati, North 24 Parganas, West Bengal, India
 
Introduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdfIntroduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdf
CME4Life
 
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
Arshad Shaikh
 
Uterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managmentUterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managment
Ritu480198
 
LDMMIA About me 2025 Edition 3 College Volume
LDMMIA About me 2025 Edition 3 College VolumeLDMMIA About me 2025 Edition 3 College Volume
LDMMIA About me 2025 Edition 3 College Volume
LDM & Mia eStudios
 
How to Create a Stage or a Pipeline in Odoo 18 CRM
How to Create a Stage or a Pipeline in Odoo 18 CRMHow to Create a Stage or a Pipeline in Odoo 18 CRM
How to Create a Stage or a Pipeline in Odoo 18 CRM
Celine George
 
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo SlidesHow to Manage Orders in Odoo 18 Lunch - Odoo Slides
How to Manage Orders in Odoo 18 Lunch - Odoo Slides
Celine George
 
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdfTechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup Microsoft Copilot Nonprofit Use Cases and Live Demo - 2025.05.28.pdf
TechSoup
 
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdfপ্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
প্রত্যুৎপন্নমতিত্ব - Prottutponnomotittwa 2025.pdf
Pragya - UEM Kolkata Quiz Club
 
State institute of educational technology
State institute of educational technologyState institute of educational technology
State institute of educational technology
vp5806484
 
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
SEM II 3202 STRUCTURAL MECHANICS, B ARCH, REGULATION 2021, ANNA UNIVERSITY, R...
RVSPSOA
 
Order: Odonata Isoptera and Thysanoptera.pptx
Order: Odonata Isoptera and Thysanoptera.pptxOrder: Odonata Isoptera and Thysanoptera.pptx
Order: Odonata Isoptera and Thysanoptera.pptx
Arshad Shaikh
 
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptxQUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
Sourav Kr Podder
 
"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx"Hymenoptera: A Diverse and Fascinating Order".pptx
"Hymenoptera: A Diverse and Fascinating Order".pptx
Arshad Shaikh
 
Odoo 18 Point of Sale PWA - Odoo Slides
Odoo 18 Point of Sale PWA  - Odoo  SlidesOdoo 18 Point of Sale PWA  - Odoo  Slides
Odoo 18 Point of Sale PWA - Odoo Slides
Celine George
 
Coleoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptxColeoptera: The Largest Insect Order.pptx
Coleoptera: The Largest Insect Order.pptx
Arshad Shaikh
 
K-Circle-Weekly-Quiz-May2025_12345678910
K-Circle-Weekly-Quiz-May2025_12345678910K-Circle-Weekly-Quiz-May2025_12345678910
K-Circle-Weekly-Quiz-May2025_12345678910
PankajRodey1
 
Search Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website SuccessSearch Engine Optimization (SEO) for Website Success
Search Engine Optimization (SEO) for Website Success
muneebrana3215
 
Introduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdfIntroduction to Online CME for Nurse Practitioners.pdf
Introduction to Online CME for Nurse Practitioners.pdf
CME4Life
 
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
Arshad Shaikh
 
Uterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managmentUterine Prolapse, causes type and classification,its managment
Uterine Prolapse, causes type and classification,its managment
Ritu480198
 
LDMMIA About me 2025 Edition 3 College Volume
LDMMIA About me 2025 Edition 3 College VolumeLDMMIA About me 2025 Edition 3 College Volume
LDMMIA About me 2025 Edition 3 College Volume
LDM & Mia eStudios
 
How to Create a Stage or a Pipeline in Odoo 18 CRM
How to Create a Stage or a Pipeline in Odoo 18 CRMHow to Create a Stage or a Pipeline in Odoo 18 CRM
How to Create a Stage or a Pipeline in Odoo 18 CRM
Celine George
 

Xi CBSE Computer Science lab programs

  • 1. [Document title] Prof. K. Adisesha Page 1 COMPUTER SCIENCE PYTHON PRACTICAL PROGRAMS 1. Program to obtain length and breadth of a rectangle and calculate its area. Solution. #to input length and breadth of a rectangle and calculate its area length = float( input("Enter length of the rectangle : ")) breadth= float( input (" Enter breadth of the rectangle: ")) area=length * breadth print ("Rectangle specifications ") print ("Length = ", length) print ("breadth ", breadth) print ("Area = ", area) 2. Write a program in python to display even and odd numbers from 1 to N. Solution. num=int(input("Enter the Range:")) for i in range(1,num+1): if i%2==0: print(i, "is even number") else: print(i,"is odd number") 3. Write a program in python to all print prime number from 1 to n. Solution. num=int(input("Enter the number:")) for val in range(1,num + 1): # If num is divisible by any number # between 2 and num, it is not prime
  • 2. [Document title] Prof. K. Adisesha Page 2 if num > 1: for n in range(2, val): if (val % n) == 0: break else: print(val) 4. Write Python script to print the following for n numbers pattern: 1 1 3 1 3 5 1 3 5 7 Solution. num=int(input("Enter the number:")) for a in range (2, num, 2): for b in range (1, a, 2): print (b, end =(' ')) print () 5. Write a program to find sum of the series: S=1+ X + X2 +X3 +….Xn Solution. x = int ( input ( "Enter value of X :" ) ) n= int (input( "Enter value of n (for x ** y) :" )) s=0 for a in range(n): s += x ** a print ("Sum of first" , x,'^',a , "terms :", s)
  • 3. [Document title] Prof. K. Adisesha Page 3 6. Write a program to check a number whether it is palindrome or not. num=int(input("Enter a number : ")) n=num res=0 while num>0: rem=num%10 res=rem+res*10 num=num//10 if res==n: print(n,": Number is Palindrome") else: print(n, ": Number is not Palindrome") 7. Write a program to test if a string is palindrome or not. SOURCE CODE: string = input("Please enter your own String : ") if(string == string[:: - 1]): print(string, ": is a Palindrome String") else: print(string, ": is Not a Palindrome String") 8. Write a program to calculate Simple and compound interest. p=float(input("Enter the principal amount : ")) r=float(input("Enter the rate of interest : ")) t=float(input("Enter the time in years : ")) SI=(p*t*r)/100 x=(1+r/100)**t CI= p*x-p print("Simple interest is : ", round(SI,2)) print("Compound interest is : ", round(CI,2))
  • 4. [Document title] Prof. K. Adisesha Page 4 9. Write a program to input a character and to print whether a given character is an alphabet, digit or any other character. SOURCE CODE: ch=input("Enter a character: ") if ch.isalpha(): print(ch, "is an alphabet") elif ch.isdigit(): print(ch, "is a digit") elif ch.isalnum(): print(ch, "is alphabet and numeric") else: print(ch, "is a special symbol") 10.Program to count frequency of a given element in a list of numbers SOURCE CODE: Lst=eval(input ( " Enter list :")) length=len(Lst) element=int(input( " Enter element :")) count=0 for i in range(0, length): if element==Lst [i]: count += 1 if count == 0: print (element, "not found in given list") else: print(element, "has frequency as", count, "in given list")
  • 5. [Document title] Prof. K. Adisesha Page 5 11.Program to create a dictionary containing names of competition winner students as key number of their wins as values SOURCE CODE: n=int(input("How many students? ")) winners ={ } for a in range(n): key=input("Name of the student : ") value=int(input ("Number of competitions won : ")) winners [key]=value print ("The dictionary now is : ") print (winners) 12.Write a program to calculate the factorial of an integer using recursion. SOURCE CODE: def factorial(n): if n == 1: return n else: return n*factorial(n-1) num=int(input("enter the number: ")) if num < 0: print("Sorry, factorial does not exist for negative numbers") elif num == 0: print("The factorial of 0 is 1") else: print("The factorial of ",num," is ", factorial(num))
  • 6. [Document title] Prof. K. Adisesha Page 6 13.Write a program to print fibonacci series using recursion. SOURCE CODE: def fibonacci(n): if n<=1: return n else: return(fibonacci(n-1)+fibonacci(n-2)) num=int(input("How many terms you want to display: ")) for i in range(1,num+1): print(fibonacci(i)," ", end=" ") 14.To write a Python program to find the maximum of a list of numbers. n=int(input("Enter the list size:")) a=[] for i in range(n): num=int(input("Enter the number")) a.append(num) print (a) max=a[0] for i in range(n): if(max<a[i]): max=a[i] print ("maximum",max)
  • 7. [Document title] Prof. K. Adisesha Page 7 15.Write a program for linear search. SOURCE CODE: L=int(input("Enter the list size:")) a=[] loc=-1 for i in range(L): num=int(input("Enter the number")) a.append(num) print (a) n=len(a) item=eval(input("Enter the element that you want to search : ")) for i in range(n): if a[i]==item: loc=i+1 break if loc > -1: print("Element found at the position :", i+1) else: print("Element not Found") 16.Write a program for bubble sort. SOURCE CODE: L=int(input("Enter the list size:")) a=[] loc=-1
  • 8. [Document title] Prof. K. Adisesha Page 8 for i in range(L): num=int(input("Enter the number")) a.append(num) print (a) n=len(a) for p in range(0,n-1): for i in range(0,n-1): if a[i]>a[i+1]: t=a[i] a[i]=a[i+1] a[i+1]=t print("The sorted list is : ", a) 17.Program to input two numbers and print their LCM and HCF. SOURCE CODE: X=int(input("Enter first number:")) Y= int (input("Enter second number:")) if X >Y: smaller = Y else: smaller = X for i in range(1, smaller + 1): if((X % i==0) and (Y % i == 0) ) : hcf = i lcm=(X* Y) / hcf print("The H.C.F. of", X, "and ", Y, "is", hcf) print("The L.C.M. of", X, "and ", Y, "is", lcm)
  • 9. [Document title] Prof. K. Adisesha Page 9 18.Write a python function sin(x, n) to calculate the value of sin(x) using its taylor series expansion up to n terms. SOURCE CODE: import math def fact(k): if k<=1: return 1 else: return k*fact(k-1) step=int(input("How many terms : ")) x=int(input("Enter the value of x :")) sum=0 for i in range(step+1): sum+=(math.pow(-1,i)*math.pow(x,2*i+1))/fact(2*i+1) print("The result of sin",'(', x, ')', "is :", sum) 19.Write a program to display ASCII code of a character and vice versa. SOURCE CODE: var=True while var: choice=int(input("Press-1 to find the ordinal value of a character nPress-2 to find a character of a valuen")) if choice==1: ch=input("Enter a character : ") print(ord(ch)) elif choice==2: val=int(input("Enter an integer value: ")) print(chr(val)) else: print("You entered wrong choice") print("Do you want to continue? Y/N") option=input() if option=='y' or option=='Y': var=True else: var=False
  • 10. [Document title] Prof. K. Adisesha Page 10 SQL Program SQL PROGRAMS PART-B Exp A: CREATE A STUDENT DATABASE AND COMPUTE THE RESULT. 1) Create a student database and compute the result. Query 1:  Create table student(stud_id number(4), stud_name varchar2(20), Computer number(3), Maths number(3), Physics number(3), Chem number(3)); 2) Add record into the table for 5 students, using insert command. Query 2:  insert into student values('101','arun','69','70','55','90');  insert into student values('102','Sunny','39','50','58','67');  insert into student values('103','Prajwal','67','40','59','89');  insert into student values('104','Satish','20','30','56','45');  insert into student values('105','Rekha','19','70','89','40'); 3) Display the description of the fields in table using desc command. Query3:  desc table student;  desc student; 4) Display all records form the Student table using select command: Query4:  Select * from student; 5) Add to new fields to the table : *total number(3) FIELD NAME DATA TYPE StudentID Number(4) Studentname Varchar(20) Computer Number(3) Maths Number(3) Physics Number(3) Chem Number(3)
  • 11. [Document title] Prof. K. Adisesha Page 11 Query5:  Alter table student add (total number (3)); 6) Calculate total Marks. Query6:  Update student set total=Comp+Maths+Physics+Chem; 7) Find the min, max, sum, and average of the marks in a student marks table. Query7:  SELECT min(total) FROM student;  SELECT max(total) FROM student;  SELECT sum(total) FROM student;  SELECT avg(total) FROM student; 8) Add to new fields to the table: *percentage number(3) *result varchar2(10) Query8:  Alter table student add (percentage number (3), result varchar2(10)); (9) Calculate Percentage Marks. Query9:  Update student set percentage=total/4 where studentid>0; 10)Compute the result as "pass" or "fail" by checking if the student has scored more than 35 marks in each subject. Query10(a):  Update student set result='pass' where Comp>=35 and Maths>=35 and Physics>=35 and Chem>=35; Query 10(b):  Update student set result='fail' where Comp<35 or Maths<35 or Physics<35 or Chem<35; 11)Retrieve all the records of the table. Query 11:  Select * from student; 12) Retrieve only student_id and student_name of all the students. Query 12:
  • 12. [Document title] Prof. K. Adisesha Page 12  select student_id, student_name from student; 13) List the students who have the result as "pass". Query 13:  select * from student where result='pass'; 14)List the students who have the result as "fail". Query 14:  select * from student where result='fail'; 15)Count the number of students who have passed and failed.  Query 15(a): select count (*) from student where result='pass';  Query 15(b): select count (*) from student where result='fail'; Exp B: CONSIDER THE FOLOWING TABLE GAMES COMPUTE THE RESULT: Table: GAMES GCODE GAMENAME Type NUMBER PRIZE SCHEDULE 101 CaromBoard Indoor 2 5000 23-Jan-2019 102 Badminton Outdoor 2 12000 12-Dec-2019 103 TableTennis Indoor 4 8000 14-Feb-2019 104 Chess Indoor 2 9000 01-Sep-2019 105 Cricket Outdoor 4 25000 19-Mar-2019 Write SQL commands for the flowing statements: 1) Create a game database and compute the result. Query 1:  Create table games(gcode number(4), g_name varchar2(20), type varchar2(10),gnumber number(3), gprize number(10), schedule date); 2) Add record into the table games. Query 2: insert into game values(101,' CaromBoard',' Indoor ',2, 5000,'23-Jan-2019'); insert into game values(102,' Badminton ',' Outdoor ',2, 12000, '12-Dec-2019'); insert into game values(103,' TableTennis ',' Indoor ',4, 8000,'14-Feb-2019'); insert into game values(104,' Chess ',' Indoor ',2, 9000,'01-Sep-2019'); insert into game values(105,' Cricket ',' Outdoor ',4, 25000, '19-Mar-2019');
  • 13. [Document title] Prof. K. Adisesha Page 13 3) To display the name of all GAMES with their GCodes. Query 3: select gcodes, gamename from games; 4) To display details of those GAMES which are scheduled between 02-Mar- 2014 and 10-Dec-2019. Query 4: select * from games where scheduledate between ‘02-mar-2019' and '10-dec-2019'; 5) To display the content of the GAMES table in ascending order of Schedule Date. Query 5: select * from games order by scheduledate; 6)To display sum of Prize Money for each Type of GAMES. Query 6: select sum(prizemoney) from games order by type; (B) Give the output of the following SQL queries: 1) select count(distinct number) from games; OUTPUT 1: count(distinct number) ---------------------------------- 2 2) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES; OUTPUT 2: max(scheduledate) min(scheduledate) ---------------------------- -------------------------------- 23-jan-2016 12-dec-2019