Practical12 032718
Practical12 032718
CLASS= XI
ROLL NO.= 17
1
INDEX
S.NO. TITLE Page no Teacher’s sign
1. Program to enter a string from user and 3.
performing various string functions
2. Program to enter the number of terms and 4.
to print the Fibonacci series
3. Program to find whether an inputted 5.
number from user is perfect square or not
4. Program to take Principal Amount, Time 5.
,Rate p. a from user and give the amount of
Simple Interest
5. Program to use statistics module to find 6.
mean and mode
6. Program to find the Surface Area and 6.
Volume of cylinder by taking radius and
height from user
7. Program to read the contents from file and 7.
adding to the text file
8. Program to add two numbers using text file 7.
9. Program to insert roll no. ,name and marks 8.
in binary file
10. Program to show the information inserted 9.
by user
11. Program to create a csv file by entering 9.
user_id and password
12. Program to drop column from table in SQL 10.
13. Program to create database in SQL using 11.
python and also showing the databases
using python
14. Program to get data in form of tuples in list 11.
using fetchall
15. Program to insert values in SQL table using 12.
python interfaces
16. Program on parameterized queries 12.
17. Parameterized query by getting input from 13.
user using old style
18. Program to implement stack operations 13.
using list
19. Random number generator that generates 14.
random numbers between 1 and 6
20. Student table and implement following 15.
command on the student table
2
3
PRO RAM TO ENTER A STRIN FROM USER AN PERFORMIN VARIOUS STRIN FUNCTIONS
4
PROGRAM TO ENTER THE NUMBER OF TERMS AND TO PRINT THE FIBONACCI SERIES
INPUT:
OUTPUT:
Fibonacci series up to 5 :
(0,)
(0, 1)
(0, 1, 1)
(0, 1, 1, 2)
(0, 1, 1, 2, 3)
5
PROGRAM TO FIND WHETHER AN INPUTTED NUMBER FROM USER IS A PERFECT SQUARE
OR NOT.
INPUT:
import math
num=int(input("Enter the number:"))
sqrt_num=math.sqrt(num)
if sqrt_num.is_integer():
print("The number is a perfect square")
else:
print("The number is not a perfect square")
OUTPUT: 1
OUTPUT: 2
PROGRAM TO TAKE PRINCIPAL AMOUNT ,TIME,RATE p.a. FROM USER AND GIVE THE
AMOUNT OF SIMPLE INTEREST
INPUT:
P=eval(input("Enter Principal:"))
T=eval(input("Enter time(in years):"))
R=eval(input("Enter the rate p.a:"))
SI=P*R*T/100
print('Rate=',R,'%p.a')
print("Simple interest = Rs",SI)
OUTPUT:
Enter Principal:1000
Enter time(in years):2
Enter the rate p.a:8
Rate= 8 %p.a
Simple interest = Rs 160.0
6
PROGRAM TO USE STATISTICS MODULE TO FIND MEAN AND MODE
INPUT:
import statistics
data=[2,3,3,4,4,4,5,5,5,5]
mean_value=statistics.mean(data)
mode_value=statistics.mode(data)
print("Mean:",mean_value)
print("Mode:",mode_value
OUTPUT:
Mean: 4
Mode: 5
PROGRAM TO FIND THE TOTAL SURFACE AREA AND VOLUME OF CYLINDER BY TAKING
RADIUS AND HEIGHT FROM USER
INPUT:
OUTPUT:1
OUPUT:2
7
PROGRAM TO READ THE CONTENTS FROM FILE AND ADDING TO THE TEXT FILE
INPUT:
f=open("NOTE.1.txt",'a+')
data=f.read()
print(data)
b=input("Type the string you want to add in file:")
f.write(b)
print("Data written to the file successfully")
f.close()
OUPUT:
Type the string you want to add in file: We are writting data to a text file
IN NOTEPA :
INPUT:
f=open("NOTE.1.txt",'a+')
data=f.read()
print(data)
b=input("Type the string you want to add in file:")
f.write(b)
print("Data written to the file successfully")
f.close()
OUTPUT:
IN NOTEPA :
8
PROGRAM TO INSERT ROLL NO,NAME NAD MARKS IN BINARY FILE
INPUT:
import pickle
def record():
f=open("bin.dat",'wb')
while True:
r=int(input("Enter Roll no.:"))
n=input("Enter name:")
m=float(input("Enter the marks:"))
data=[r,n,m]
pickle.dump(data,f)
choice=input("Do you want to enter more records(Y/N):")
if choice in 'Nn':
break
f.close()
record()
OUTPUT:
Enter name:priti
Enter name:Neena
IN CSV FILE:
9
PROGRAM TO SHOW THE INFORMATION INSERTED BY USER
INPUT:
import pickle
def read():
f=open("bin.dat",'rb')
try:
while True:
record=pickle.load(f)
print(record)
except EOFError:
f.close()
read()
OUTPUT:
INPUT:
import csv
def write():
f=open("BOOK2.csv",'w')
o=csv.writer(f)
o.writerow(["UserId","Password"])
while True:
id1=input("Enter user_id:")
pswd=input("Enter password:")
data=[id1,pswd]
o.writerow(data)
choice=input("Do you want to enter more records(Y/N):")
if choice in 'Nn':
break
f.close()
write()
OUPUT:
Enter user_id:priti
Enter password:8676
Enter user_id:Neena
10
Enter password:7784
IN EXCEL:
SQL TABLE:
SQL TABLE:
11
PROGRAM TO CREATE DATABASES IN SQL USING PYTHON AND ALSO SHOWING
THE DATABASES IN PYTHON
INPUT:
OUTPUT:
INPUT:
OUPUT:
INPUT:
12
OUTPUT:
IN SQL:
INPUT:
13
OUTPUT:
INPUT:
OUTPUT:
INPUT:
14
OUPUT:
INPUT:
15
OUTPUT:
INPUT:
OUTPUT:UPDATE
16
OUTPUT:ALTER
17