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

Practical Example Answers

The document contains various code snippets and SQL queries related to stack operations in Python, database manipulations in SQL for client and product tables, and file handling in Python. It includes examples of inserting, updating, and selecting data from different tables, as well as reading and writing to binary and text files. Each section provides a brief description of the expected output for the SQL queries and Python functions.
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)
2 views2 pages

Practical Example Answers

The document contains various code snippets and SQL queries related to stack operations in Python, database manipulations in SQL for client and product tables, and file handling in Python. It includes examples of inserting, updating, and selecting data from different tables, as well as reading and writing to binary and text files. Each section provides a brief description of the expected output for the SQL queries and Python functions.
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

Q1.

Python Program for Stack Operations

stack = [] def push(item): [Link](item) def pop(): if stack: return [Link]() else: return
"Stack is empty" def peek(): if stack: return stack[-1] else: return "Stack is empty" def display():
print(stack)

Q2. Client_Master SQL

(A) SELECT cname FROM Client_Master WHERE cname LIKE '_a%';


(B) UPDATE Client_Master SET cname='MANOJ SINGLA' WHERE clientno=6;
(C) Output: ARATRIKA DEY, MANIKA SINGLA
(D) Output: 3

Q3. Python Program for Binary File

import pickle def insert(): with open("[Link]","ab") as f: [Link](input("Enter data: "), f) def
display(): with open("[Link]","rb") as f: try: while True: print([Link](f)) except EOFError: pass

Q4. Books Table SQL

(A) SELECT book_name, price FROM Books_Master ORDER BY price ASC;


(B) UPDATE Books_Master SET price = price + 50 WHERE publishers='EPB';
(C) Output: Fast Cook, My First C++
(D) Output: 5

Q5. Python Program to Connect MySQL

import [Link] con = [Link](host="localhost", user="root", password="",


database="customersDB") cur = [Link]() [Link]("INSERT INTO customers VALUES
(8,'Amit',30,'Pune',9000)") [Link]("SELECT * FROM customers") for row in cur: print(row)
[Link]()

Q6. Customers Table SQL

(A) SELECT name FROM customers WHERE name LIKE '_a%';


(B) UPDATE customers SET name='Deepti' WHERE id=6;
(C) Output: Muffy
(D) Output shown with salary+500 for salaries <10000

Q7. Python Program for Text File

f = open("[Link]","w") [Link]("Where the mind is without fear...") [Link]() f = open("[Link]","r")


print([Link]()) [Link]()
Q8. Products Table SQL

(A) SELECT productname FROM Products WHERE productname LIKE 'C%';


(B) UPDATE Products SET price=40 WHERE productname='Chang';
(C) Output: Chais, Chang, Chef Anton's Cajun Seasoning, Chef Anton's Gumbo Mix
(D) Invalid condition (salary column not present)

You might also like