0% found this document useful (0 votes)
6 views1 page

Python, Stack, and SQL Code Examples

The document contains Python code snippets for displaying words ending with 'm' and implementing a stack using a list. Additionally, it includes SQL queries for retrieving student and course information based on specific criteria. The queries cover selection, aggregation, and grouping operations in a database context.

Uploaded by

rohanmekala11
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)
6 views1 page

Python, Stack, and SQL Code Examples

The document contains Python code snippets for displaying words ending with 'm' and implementing a stack using a list. Additionally, it includes SQL queries for retrieving student and course information based on specific criteria. The queries cover selection, aggregation, and grouping operations in a database context.

Uploaded by

rohanmekala11
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

ANSWERS

Q1. Python program to display words ending with 'm'


f = open("[Link]", "r")
words = [Link]().split()
for w in words:
if [Link]('m'):
print(w)
[Link]()

Q2. Stack using List


stack = []
def push():
item = int(input("Enter element: "))
[Link](item)
def pop():
if len(stack)==0:
print("Stack Empty")
else:
print([Link]())

Q3. SQL Queries


a) SELECT Name, Age FROM Students S, Courses C WHERE S.Course_ID=C.Course_ID AND
Course_Name='Mathematics';

b) SELECT Course_Name, SUM(Fee) FROM Courses GROUP BY Course_Name;

c) SELECT Name FROM Students S, Courses C WHERE S.Course_ID=C.Course_ID AND


Gender='Male' AND Duration='3 years';

d) SELECT Course_Name, AVG(Age) FROM Students S, Courses C WHERE


S.Course_ID=C.Course_ID GROUP BY Course_Name;

You might also like