CS- Practical (2023-24) - Copy (1)
CS- Practical (2023-24) - Copy (1)
Table: TRADES
TRADE CODE TNAME CITY
T01 Electronics Sales Mumbai
T02 Busy Store Corp Delhi
T03 Disp House Inc Chennai
1. Write a python program to remove all the line that contain the character
in a file and write it to another file.
2. Create a student Table and Insert Data to implement the following SQL
comments.
i. ALTER TABLE to add new attributes / modify data type /drop
attribute.
ii. UPDATE TABLE to modify data.
iii. ORDER BY to display data in ascending / descending order.
iv. Find the min, max, sum, count and average.
\
file = open("info.txt", "r")
print(file.read())
file.seek(0)
lines = file.readlines()
new_lines = []
new_lines.append(line)
file.close()
file.writelines(new_lines)
file.close()
content = fn.read()
print(content)
import mysql.connector
# Main program
def main():
roll_no = input("Enter the roll number of the student you want to search and delete: ")
if __name__ == "__main__":
main()
-- 1. Create Tables
CREATE TABLE ITEM (
item_code INT PRIMARY KEY,
item_name VARCHAR(100),
quantity INT,
price INT,
company VARCHAR(100),
trade_code VARCHAR(10)
);
-- 4. SQL Queries
-- 4.1 Display all items in ascending order of item names
SELECT * FROM ITEM
ORDER BY item_name ASC;
-- 4.2 Display item name and price where price is between 10000 and
20000
SELECT item_name, price FROM ITEM
WHERE price BETWEEN 10000 AND 20000;