Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
310 views2 pages

Q1 Write A Menu Driven Program To Implement The Following in Binary File Emp - Dat'

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

Q1 Write a menu driven program to implement the following in binary file ‘Emp.

dat’ :
1. WriteRec() function to write the Employee Records (id, name, salary) in a binary file name
“Emp.dat”
2. ReadRec_Salary() function to read all records from a binary file “Emp.dat” whose salary is
greater than 70000.
3. Read_RecName() function to display all records whose name starts with ‘S’.
4. ReadRecId() function to display all records whose Id is ‘101’ or ‘105’.
Q2 A table Student is created in the database School. The details of the table are given below.
`

StuID Name Class Total Grade

ST/12 Tanmay 12 499 A+

import mysql.connector as sqltor


mycon = sqltor.connect( _______, user = “root”, _________, database = ___________ ) #1
cursor = mycon.cursor( )
cursor.execute(______________________ ) #2
data = _________________ #3
for rec in data:
print ( rec )
_____________________ #4
mycon.close( )

a. Complete the statement #1 to write appropriate missing parameters and values.


b. Write the statement #2, to fetch Name, Class, Grade from table Student who have scored less than
400.
c. Complete the statement #3, to fetch all records from the resultset.
d. What statement you will write in place of statement #2 to insert one more record in table Student, as
well as in statement #4, to make your changes permanent in the table Student.
StuID Name Class Total Grade

ST/15 Amrit 12 496 A+


Q1 Write a menu driven Python program for implementing the following operations on the
text file, ‘Story.txt’.
1. WriteText(): It shall write user entered text into the text file.
2. Count(): It will count the number of “Me” or “My” words present in a text file
“STORY.TXT”.
3. Copy(): It shall copy all the lines from text file “Story.txt” to “target.txt” which starts
with “A”.
4. Count_Words() : It shall count the total number of words in your text file
Q2 Observe the following code and fill in the given blanks as directed:

import mysql.connector as mycon


mydb=mycon.connect(_______________________________________) # Statement 1
mycursor=mydb.___________ # Statement 2
mycursor.execute(__________________________________________) # Statement 3
row = mycursor.______________# Statement 4
print(row)

The partial code is given for displaying one record from the customer table created . The
customer table is given as following:

CustomerID CustomerName City BillAmt MobileNo

111 Abhishek Ahmedabad 1500 9999999999

222 Ram kumar Chennai 1501 8888888888

i. Write the parameters and values required to fill statement 1. The parameters
values are as follows:
Database Server User Pasword Database

Localhost Root SQL123 Customer

ii. Write function name to create cursor and fill in the gap for statement 2.
iii. Write a query to fill statement 3 to display all records from customer table.
iv. Write function to fill statement 4 to fetch one record from customer table.

You might also like