set 3

 

SET 3 1. # Program to write a string into a binary file and # count character frequency using dictionary import pickle # Input string text = input("Enter a string: ") # Writing string to binary file with open("comp.dat", "wb") as f: pickle.dump(text, f) # Reading string from binary file with open("comp.dat", "rb") as f: data = pickle.load(f) # Dictionary to store character count char_count = {} for ch in data: if ch in char_count: char_count[ch] += 1 else: char_count[ch] = 1 # Display result print("Character Frequency:") for key in char_count: print(key, ":", char_count[key]) SQl Query: Create Query : CREATE TABLE Book ( Book_Id VARCHAR(5) PRIMARY KEY, Book_Name VARCHAR(30), Author_Name VARCHAR(30), Publisher VARCHAR(20), Price INT, Type VARCHAR(15), Quantity INT ); Insert query: INSERT INTO Book VALUES ('C0001', 'Fast Cook', 'Lata Kapoor', 'EPB', 355, 'Cookery', 5); Queries: i. SELECT Book_Id, Book_Name, Quantity FROM Book WHERE Quantity > 0; ii. iii. iv. SELECT Book_Name, Price FROM Book WHERE Book_Name LIKE '%C++%; DELETE FROM Book WHERE Book_Id = 'T0002'; SELECT * FROM Book WHERE Book_Name LIKE 'T%';

Comments