PROGRAM:

OUTPUT:

3 Generate the following patterns using nested loop. Click here
3A Pattern-1
*
**
***
****
*****
Pattern-2
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Pattern-3
A
AB
ABC
ABCD
ABCDE
Programming in Python
1. To find average and grade for given marks. Click Here
2. To find the sale price of an item with a given cost and discount (%). Click Here
3. To calculate perimeter/circumference and area of shapes such as triangle, rectangle, square and circle. Click Here
4. To calculate Simple and Compound interest. Click Here
5. To calculate profit-loss for a given Cost and Sell Price. Click Here
6. To calculate EMI for Amount, Period and Interest. Click Here
7. To calculate tax - GST / Income Tax. Click Here
8. To find the largest and smallest numbers in a list. Click Here
9. To find the third largest/smallest number in a list. Click Here
10. To find the sum of squares of the first 100 natural numbers. Click Here
11. To print the first ‘n’ multiples of a given number. Click Here
12. To count the number of vowels in a user entered string. Click Here
13. To print the words starting with a particular alphabet in a user entered string. Click Here
14. To print the number of occurrences of a given alphabet in a given string. Click Here
15. Create a dictionary to store names of states and their capitals. Click Here video click here
16. Create a dictionary of students to store names and marks obtained in 5 subjects. Click Here video click here
17. To print the highest and lowest values in the dictionary. Click Here video click here
02. SQL Queries – one table / two tables. Click Here
Program
Output
program
#Menu Driven program to perform all the operations
#on a Binary file....
import pickle
def write():
f=open("StudentDetails.dat","wb")
record=[]
while True:
rno=int(input("Roll No:"))
name=input("Name:")
marks=int(input("Marks:"))
data=[rno,name,marks]
record.append(data)
ch=input("More(Y/N)?")
if ch in 'Nn':
break
pickle.dump(record,f)
print("Record Added..")
f.close()
def read():
print("Contents in a File...")
f=open("StudentDetails.dat","rb")
try:
while True:
s=pickle.load(f)
print(s)
for i in s:
print(i)
except Exception:
f.close()
def append():
f=open("StudentDetails.dat","rb+")
print("Append data in a File..")
Rec=pickle.load(f)
while True:
rno=int(input("Roll No:"))
name=input("Name:")
marks=int(input("Marks:"))
data=[rno,name,marks]
Rec.append(data)
ch=input("More(Y/N)?")
if ch in 'Nn':
break
f.seek(0)
pickle.dump(Rec,f)
print("Record Appended..")
f.close()
def search():
f=open("StudentDetails.dat","rb")
r=int(input("Enter roll no to be searched:"))
found=0
try:
while True:
s=pickle.load(f)
for i in s:
if i[0]==r:
print(i)
found=1
break
except EOFError:
f.close()
if found==0:
print("Sorry...No record Found..")
def update():
f=open("StudentDetails.dat","rb+")
r=int(input("Enter roll no whose details to be updated:"))
f.seek(0)
try:
while True:
rpos=f.tell()
s=pickle.load(f)
print(s)
for i in s:
if i[0]==r:
i[1]=input("New Name:")
i[2]=int(input("Updated Marks:"))
f.seek(rpos)
pickle.dump(s,f)
break
except Exception:
f.close()
def delete():
f=open("StudentDetails.dat","rb")
s=pickle.load(f)
f.close()
r=int(input("Enter roll no to be deleted:"))
f=open("StudentDetails.dat","wb")
print(s)
reclst=[]
for i in s:
if i[0]==r:
continue
reclst.append(i)
pickle.dump(reclst,f)
f.close()
#MainMenu
print("---------------------------------------------------")
print("1.Write Data in a Binary File..")
print("2.Read Data from a File..")
print("3.Append data in a File..")
print("4.Search Operation in a File..")
print("5.Update Data in a File..")
print("6.Delete Operation in a File..")
print("7.Exit..")
print("---------------------------------------------------")
while True:
ch=int(input("Enter your choice:"))
if ch==1:
write()
elif ch==2:
read()
elif ch==3:
append()
elif ch==4:
search()
elif ch==5:
update()
elif ch==6:
delete()
elif ch==7:
break
As per CBSE Practical List 2021-22
Term-1
1. Read a text file line by line and display each word separated by a #. click here Date:22-06-2021
2. Read a text file and display the number of vowels/consonants/uppercase/lowercase characters in the file. Click here Date:29-06-2021
3. Remove all the lines that contain the character 'a' in a file and write it to another file. Click here Date:06-07-2021
4. Create a binary file with name and roll number. Search for a given roll number and display the name, if not found display appropriate message. Click here Date:13-07-2021
5. Create a binary file with roll number, name and marks. Input a roll number and update the marks. Click here Date:20-07-2021
6. Write a random number generator that generates random numbers between 1 and 6 (simulates a dice). Click here Date: 27-07-2021
7. Write a Python program with function to count the number of lines in a text file ‘ 'STORY.TXT’ which is starting with an alphabet ‘A’ or 'a'. Click here date : 04-08-21
8. Write a Python program with method/function DISPLAYWORDS() to read lines from a text file STORY.TXT, and display those words, which are less than 4 characters. Click Here date : 11-08-21
9. Text Files Menu Driven Program: Click Here date : 19-08-21
Choice = 1. Read a text file line by line and display each word
04. Write a Python program to implement a queue using a list data-structure. Click Here
07. SQL Queries:-2 – Minimum 5 sets using one table / two tables. Click Here
Connectivity Programmes (Mysql with Python)
09. Find the total number of customers from each country in the table (customer ID, customer name, country) using group by( python interface through MYSQL). Click Here
10. INSERT, UPDATE, AND DELETE (PYTHON INTERFACE THROUGH MYSQL)ppt slides(RKS):ClickHere and Reference: INSERT, UPDATE, AND DELETE (PYTHON INTERFACE THROUGH MYSQL)video: Click Here