0% found this document useful (0 votes)
8 views2 pages

Assignmen1 Binary File Modification

The document outlines a series of programming assignments focused on modifying binary files containing various data structures. Tasks include updating drink prices, changing user statuses, adjusting stock quantities, and modifying customer account balances and user phone numbers based on specific criteria. Each task requires writing functions to perform the specified updates in the respective binary files.

Uploaded by

Ritika Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Assignmen1 Binary File Modification

The document outlines a series of programming assignments focused on modifying binary files containing various data structures. Tasks include updating drink prices, changing user statuses, adjusting stock quantities, and modifying customer account balances and user phone numbers based on specific criteria. Each task requires writing functions to perform the specified updates in the respective binary files.

Uploaded by

Ritika Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ASSIGNMENT : MODIFICATION IN BINARY FILES

1. GIVEN THE STRUCTURE OF A DICTIONARY BELOW:


{ ‘DCODE’: DRINKCODE , ‘DNAME’: DRINKNAME ,
’DSIZE’: DRINKSIZE, ‘DPRICE’ : DRINKPRICE }
Assuming a pickled file “drinks.dat” is storing
records as objects of above type, Write a
function to INCREASE THE PRICE OF DRINK NAME
‘PEPSI’ of SIZE 2L BY RS. 10 in the file.

2. Given a binary file BOOK.DAT containing records


of LIST TYPE WITH following STRUCTURE:
[ uname, status,uid ]
Representing User Name, Status as ‘A’ for Active
and ‘I’ for inactive, and User Id
Write a function which changes the status of all
users with previous status as ‘I’ to ‘A’ in the
file.

3. Given a binary file STOCK.DAT containing


records of TUPLE TYPE WITH following STRUCTURE:
( ICODE, INAME, QTY_IN_STOCK, ICOST )
Representing ITEM CODE, ITEM NAME, QUANTITY IN
STOCK, AND ITEM COST
Write a function TO UPDATE THE QUANTTY IN STOCK
OF THE ITEM WHOSE CODE IS GIVEN BY THE USER BY
THE QUANTITY SOLD [ SUBTRACT QTY SOLD FROM
QTY_IN_STOCK ] IN THE FILE.
ICODE AND QTY_SOLD SHOULD BE PARAMETERS TO THE
FUNCTION.

4. Given a PICKLED file BANK.DAT containing records


OF CUSTOMERS AS OBJECTS of LIST TYPE WITH
following STRUCTURE:
[ACCOUNT_NO, NAME, BALANCE_AMT, TRANSACTION_TYPE]
Write a function which UPDATES THE BALANCE AMOUNT
OF THE CUSTOMER IN THE FILE WHOSE ACCOUNT NUMBER
IS GIVEN BY THE USER WITH THE GIVEN DEPOSIT

BY SARITA GUPTA, RLB SEC-14, IN NGR


AMOUNT/ WITHDRAWN AMOUNT ACCORDING TO TRANSACTION
TYPE AS ‘D’ FOR DEPOSIT AND ‘W’ FOR WITHDRAW.
ACCOUNT_NUMBER, TRANSACTION_TYPE AND AMOUNT
DEPOSITED OR WITHRAWN SHOULD BE PARAMETERS TO THE
FUNCTION.

5. Given a PICKLED file USER.DAT containing records


AS OBJECTS of dict TYPE WITH following STRUCTURE:
[ ‘ADHAAR_ID’: AADHAAR NUMBER, ‘NAME’: USER NAME,
‘PHONE’: PHONE NUMBER,’AREA’: AREA_NAME, ‘CITY’:
CITY-NAME }
Write a function which UPDATES THE PHONE NUMBER
OF ALL USERS OF LUCKNOW BY ADDING ‘0522’ BEFORE
IT, ADD ‘0512’ TO PHONE NUMBER OF ALL USERS OF
KANPUR, AND ‘+91’ TO PHONE NUMBER OF ALL OTHER
USERS.
ALSO REMOVE ALL ‘-‘ from AADHAR NUMBER OF ALL
USERS. [EXAMPLE : AADHAAR NUMBER ‘2313-5432-5467-
1213’ should be changed to ‘2313543254671213’]

BY SARITA GUPTA, RLB SEC-14, IN NGR

You might also like