CBSE COMPUTER SCIENCE
Kanalga Telegram’da o‘tish
QUESTION BANK, REFERENCE BOOK, LAB MANUAL , WORKSHEET ETC., PYTHON TEXT BOOK AND REFERENCE BOOKS, 01. ASK QUESTIONS AT https://t.me/joinchat/FJ1noGs-64I0OWI1
Ko'proq ko'rsatish549
Obunachilar
Ma'lumot yo'q24 soatlar
Ma'lumot yo'q7 kunlar
Ma'lumot yo'q30 kunlar
Postlar arxiv
Current Position is 0
The content is Hel
Current Position is 3
The content is lo Wo
Current Position is 0
The content is Hel
Current Position is 3
The content is lo Wo
Current Position is 53
The content is
>>>
#FILE HANDLING : SEEK() AND TELL()in TEXT file
'''
tell() : Used to get the actual position of file object
seek() : Used to shift/change the position of file object
to required position.
Syntax :
f.seek(offset, [start_from])
offset tells how may number of bytes to move forward and start_from is optional, it tells from which place we want to start.
There are three possible values for start_from --
0 :beginning of file
1 :current position of file
2 :end of file
* If the argument start_from is not specified, by default it is 0
* The second parameter of the seek method is by default 0
* Reference point(start_from) at current position / end of file
cannot be set in text mode except when offset is equal to 0.
* Possitive index supported for only TEXT files...
Eg. seek(0,0)=seek(0), seek(0,1) = move to current position,
seek(0,2) = move to last position
* Negative index supported for only BINARY files...
'''
f1=open('demo.txt')
A=f1.tell()
print('Current Position is ',A)
B=f1.read(3)
print('The content is ',B)
A=f1.tell()
print('Current Position is ',A)
B=f1.read(5)
print('The content is ',B)
#File pointer move to Beginning of the file
f1.seek(0,0)
A=f1.tell()
print('Current Position is ',A)
B=f1.read(3)
print('The content is ',B)
#File pointer move to the current position from beginning
f1.seek(0,1)
A=f1.tell()
print('Current Position is ',A)
B=f1.read(5)
print('The content is ',B)
#File pointer move to the last position from beginning
f1.seek(0,2)
A=f1.tell()
print('Current Position is ',A)
B=f1.read(5)
print('The content is ',B)
f1.close()
S SHUNMUGA SUNDARAM, M.E, A.M.I.E, MISTE,. IAENGG, [06/01/2022 10:17 PM]
PYTHON : LIST-1 t.me/QuizBot?start=eowBkzeL
S SHUNMUGA SUNDARAM, M.E, A.M.I.E, MISTE,. IAENGG, [06/01/2022 10:18 PM]
PYTHON : LIST-2 t.me/QuizBot?start=k8DYZ3Oa
S SHUNMUGA SUNDARAM, M.E, A.M.I.E, MISTE,. IAENGG, [06/01/2022 10:18 PM]
PYTHON : LIST-3 t.me/QuizBot?start=Smn9ThxH
S SHUNMUGA SUNDARAM, M.E, A.M.I.E, MISTE,. IAENGG, [06/01/2022 10:38 PM]
List object-001 : https://forms.gle/ejQRg25vVc4ALRaX6
S SHUNMUGA SUNDARAM, M.E, A.M.I.E, MISTE,. IAENGG, [06/01/2022 10:38 PM]
Tuple Object-001 : https://forms.gle/Ku6mSpzqTXhRVJBo8
S SHUNMUGA SUNDARAM, M.E, A.M.I.E, MISTE,. IAENGG, [06/01/2022 10:38 PM]
String Object-001 : https://forms.gle/Yv6jhEF78TjAg5R59
S SHUNMUGA SUNDARAM, M.E, A.M.I.E, MISTE,. IAENGG, [06/01/2022 10:39 PM]
Do the above and send your score....
S SHUNMUGA SUNDARAM, M.E, A.M.I.E, MISTE,. IAENGG, [06/01/2022 10:45 PM]
Python Function-001 : https://forms.gle/jBRCbLw8bukPhzQy9
S SHUNMUGA SUNDARAM, M.E, A.M.I.E, MISTE,. IAENGG, [06/01/2022 10:45 PM]
Python Function-002 : https://forms.gle/tvu3GM6THFp5kU7w7
#Python with Mysql
import mysql.connector as mcr
cn = mcr.connect(host='127.0.0.1',user='root',password="admin")
cr = cn.cursor()
cr.execute("create database if not exists company")
cr.execute("use company")
cr.execute("create table if not exists employee(empno int(12),empname varchar(50),edept varchar(30),salary decimal(12,2))")
cn.commit()
choice=int(input("1. ADD RECORD 2. UPDATE RECORD 3.DELETE RECORD 4. SEARCH 5.DISPLAY 6.EXIT : "))
while choice!=0:
if choice==1: #INSERTING A RECORD
e = int(input("Enter Employee Number :"))
n = input("Enter Name :")
d = input("Enter Department :")
s = int(input("Enter Salary :"))
query="insert into employee values({},'{}','{}',{})".format(e,n,d,s)
cr.execute(query)
cn.commit()
print("A RECORD INSERTED...")
elif choice == 2: #UPDATING A RECORD
e=int(input("Enter employee number to be updated "))
s=int(input("Enter salary to be updated "))
query="update employee set salary={} where empno={}".format(s,e)
cr.execute(query)
print("A Record Updated ")
cn.commit()
elif choice == 3: #DELETING A RECORD
e=int(input("Enter employee number to be deleted"))
query="delete from employee where empno={}".format(e)
cr.execute(query)
print("Record(s) Deleted ")
cn.commit()
elif choice == 4: #SEARCHING A RECORD
e=int(input("Enter employee number to be searched"))
query="select * from employee where empno={}".format(e)
cr.execute(query)
result = cr.fetchall()
if cr.rowcount==0:
print("Record not found")
else:
print("EMPNO","NAME","DEPARTMENT","SALARY")
for row in result:
print(row[0],row[1],row[2],row[3])
cn.commit()
elif choice == 5: #DISPLAYING RECORDS
query="select * from employee"
cr.execute(query)
result = cr.fetchall()
print("EMPNO","NAME","DEPARTMENT","SALARY")
for row in result:
print(row[0],row[1],row[2],row[3])
cn.commit()
elif choice==6: #CLOSING DATABASE
cn.close()
print("File closed successfully...")
break
else:
print("Invalid Choice...")
choice=int(input("1. ADD RECORD 2. UPDATE RECORD 3.DELETE RECORD 4. SEARCH 5.DISPLAY 6.EXIT : "))
Computer_Science_Arihant_Class_12_Term_2_Sample_Papers_WWW_EXAMSAKHA.pdf54.20 MB
