├── DBMS ├── Day 3 │ ├── Exercise 12 │ ├── Assignment 30 │ ├── Assignment 27 │ ├── Assignment 34 │ ├── Exercise 13 │ ├── Exercise 14 │ ├── Exercise 21 │ ├── Exercise 22 │ ├── Assignment 32 │ ├── Assignment 16 │ ├── Assignment 26 │ ├── Assignment 38 │ ├── Exercise 10 │ ├── Exercise 11 │ ├── Exercise 18 │ ├── Assignment 20 │ ├── Assignment 36 │ ├── Assignment 23 │ ├── Assignment 29 │ ├── Exercise 20 │ ├── Assignment 19 │ ├── Exercise 16 │ ├── Assignment 18 │ ├── Exercise 15 │ ├── Exercise 19 │ ├── Assignment 31 │ ├── Assignment 35 │ ├── Assignment 39 │ ├── Assignment 15 │ ├── Assignment 28 │ ├── Exercise 17 │ ├── Assignment 37 │ ├── Assignment 24 │ ├── Assignment 21 │ ├── Assignment 22 │ ├── Assignment 25 │ ├── Assignment 17 │ └── Assignment 33 ├── Day 2 │ ├── Assignment 12 │ ├── Exercise 7 │ ├── Assignment 10 │ ├── Assignment 11 │ ├── Assignment 9 │ ├── Exercise 9 │ ├── Assignment 14 │ ├── Assignment 3 │ ├── Assignment 6 │ ├── Exercise 8 │ ├── Exercise 6 │ ├── Exercise 3 │ ├── Assignment 5 │ ├── Exercise 4 │ ├── Assignment 8 │ ├── Assignment 2 │ ├── Assignment 13 │ ├── Assignment 7 │ ├── Assignment 4 │ └── Exercise 5 ├── Day 4 │ ├── Assignment 56 │ ├── Exercise 37 │ ├── Assignment 44 │ ├── Exercise 24 │ ├── Assignment 58 │ ├── Assignment 57 │ ├── Exercise 34 │ ├── Exercise 36 │ ├── Exercise 38 │ ├── Exercise 39 │ ├── Exercise 23 │ ├── Exercise 32 │ ├── Exercise 25 │ ├── Exercise 27 │ ├── Exercise 30 │ ├── Exercise 33 │ ├── Exercise 26 │ ├── Exercise 28 │ ├── Exercise 31 │ ├── Assignment 41 │ ├── Assignment 45 │ ├── Assignment 49 │ ├── Exercise 35 │ ├── Assignment 46 │ ├── Assignment 47 │ ├── Assignment 50 │ ├── Exercise 29 │ ├── Assignment 43 │ ├── Assignment 42 │ ├── Assignment 48 │ ├── Assignment 55 │ ├── Assignment 40 │ └── Assignment 51 ├── Day 6 │ ├── Exercise 59 │ ├── Assignment 99 │ ├── Exercise 64 │ ├── Assignment 93 │ ├── Exercise 65 │ ├── Assignment 96 │ ├── Assignment 102 │ ├── Assignment 98 │ ├── Exercise 60 │ ├── Assignment 100 │ ├── Assignment 105 │ ├── Assignment 94 │ ├── Exercise 63 │ ├── Exercise 61 │ ├── Assignment 103 │ ├── Assignment 104 │ ├── Assignment 106 │ ├── Assignment 95 │ └── Exercise 66 └── Day 5 │ ├── Assignment 67 │ ├── Assignment 68 │ ├── Assignment 71 │ ├── Exercise 44 │ ├── Exercise 55 │ ├── Exercise 47 │ ├── Exercise 49 │ ├── Assignment 69 │ ├── Assignment 82 │ ├── Exercise 43 │ ├── Exercise 48 │ ├── Exercise 45 │ ├── Exercise 54 │ ├── Assignment 77 │ ├── Exercise 58 │ ├── Assignment 72 │ ├── Assignment 73 │ ├── Exercise 46 │ ├── Assignment 84 │ ├── Exercise 51 │ ├── Exercise 41 │ ├── Assignment 74 │ ├── Assignment 76 │ ├── Exercise 40 │ ├── Assignment 75 │ ├── Exercise 57 │ ├── Exercise 53 │ ├── Assignment 85 │ ├── Exercise 56 │ ├── Exercise 42 │ ├── Assignment 78 │ ├── Exercise 50 │ ├── Exercise 52 │ ├── Assignment 70 │ ├── Assignment 81 │ ├── Assignment 83 │ ├── Assignment 79 │ └── Assignment 80 ├── OOP in Python ├── Day 1 │ ├── OOPR-Assgn-1 │ ├── OOPR-Exer-2 │ ├── OOPR-Assgn-4 │ ├── OOPR-Assgn-6 │ ├── OOPR-Assgn-2 │ ├── OOPR-Exer-3.py │ ├── OOPR-Assgn-3.py │ ├── OOPR-Exer-4.py │ ├── OOPR-Assgn-8.py │ ├── OOPR-Assgn-5.py │ └── OOPR-Assgn-9.py ├── Day 5 │ ├── OOPR-Assgn-28.md │ ├── OOPR-Exer-13.py │ ├── OOPR-Assgn-29.py │ ├── OOPR-Assgn-33.py │ ├── OOPR-Assgn-34.py │ ├── OOPR-Assgn-30.py │ ├── OOPR-Assgn-32.py │ └── OOPR-Assgn-31.py ├── Day 3 │ ├── OOPR-Assgn-14 │ ├── OOPR-Exer-8.py │ ├── OOPR-Assgn-15.py │ ├── OOPR-Assgn-19.py │ ├── OOPR-Assgn-20.py │ ├── OOPR-Exer-7.py │ ├── OOPR-Assgn-21.py │ ├── OOPR-Assgn-17.py │ ├── OOPR-Assgn-18.py │ ├── OOPR-Assgn-16.py │ └── OOPR-Assgn-22.py ├── Day 2 │ ├── OOPR-Exer-5 │ ├── OOPR-Assgn-13.py │ ├── OOPR-Exer-6.py │ ├── OOPR-Assgn-10.py │ ├── OOPR-Assgn-12.py │ └── OOPR-Assgn-11.py └── Day 4 │ ├── OOPR-Assgn-26.py │ ├── OOPR-Exer-12.py │ ├── OOPR-Assgn-24.py │ ├── OOPR-Assgn-25.py │ └── OOPR-Assgn-27.py ├── Programming Fundamental Using Python ├── Day 2 │ ├── PF-Exer-13.js │ ├── PF-Assgn-21.py │ ├── PF-Exer-14.py │ ├── PF-Exer-12.go │ ├── PF-Exer-9.js │ ├── PF-Assgn-15.py │ ├── PF-Exer-8.go │ ├── PF-Assgn-17.py │ ├── PF-Assgn-16.py │ ├── PF-Exer-11.py │ ├── PF-Exer-7.py │ ├── PF-Assgn-18.py │ ├── PF-Assgn-19.py │ ├── PF-Exer-10.py │ └── PF-Assgn-20.py ├── Day 9 │ ├── PF-Assgn-60.py │ ├── PF-Assgn-59.py │ ├── PF-Assgn-57.py │ ├── PF-Assgn-61.py │ └── PF-Assgn-58.py ├── Day 7 │ ├── PF-Exer-33.py │ ├── PF-Assgn-46.py │ ├── PF-Exer-34.py │ ├── PF-Assgn-49.py │ ├── PF-Exer-35.py │ ├── PF-Assgn-50.py │ ├── PF-Assgn-47.py │ └── PF-Assgn-48.py ├── Day 1 │ ├── PF-Assgn-4.py │ └── PF-Assgn-3.py ├── Day 8 │ ├── PF-Exer-40.py │ ├── PF-Exer-38.py │ ├── PF-Exer-39.py │ ├── PF-Assgn-54.py │ ├── PF-Assgn-53.py │ ├── PF-Exer-41.py │ ├── PF-Assgn-52.py │ ├── PF-Exer-36.py │ ├── PF-Assgn-56.py │ └── PF-Assgn-55.py ├── Day 4 │ ├── JS-Exer-25.js │ ├── PF-Exer-24.go │ ├── PF-Exer-22.py │ ├── PF-Assgn-31.py │ ├── PF-Assgn-30.py │ ├── PF-Assgn-33.py │ ├── PF-Assgn-29.py │ ├── PF-Exer-23.py │ └── PF-Assgn-32.py ├── Day 5 │ ├── PF-Exer-29.py │ ├── PF-Assgn-34.py │ ├── PF-Assgn-36.py │ ├── PF-Assgn-38.py │ ├── PF-Exer-28.py │ ├── PF-Exer-26.py │ ├── PF-Assgn-35.py │ ├── PF-Assgn-37.py │ ├── PF-Exer-27.py │ └── PF-Assgn-39.py ├── Day 3 │ ├── PF-Exer-15.py │ ├── PF-Exer-16.js │ ├── PF-Exer-18.py │ ├── PF-Assgn-22.py │ ├── PF-Assgn-24.py │ ├── PF-Assgn-27.py │ ├── PF-Assgn-26.py │ ├── PF-Assgn-28.py │ └── PF-Assgn-23.py └── Day 6 │ ├── PF-Assgn-44.py │ ├── PF-Assgn-40.py │ ├── PF-Assgn-43.py │ ├── PF-Exer-30.py │ ├── PF-Exer-32.py │ ├── PF-Assgn-41.py │ └── PF-Assgn-42.py ├── README.md └── DataStructures and Algorithms using Python └── Day 1 └── DSA-Exer-1.py /DBMS/Day 3/Exercise 12: -------------------------------------------------------------------------------- 1 | select * from product 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 12: -------------------------------------------------------------------------------- 1 | ALTER TABLE CITY DROP(CITY); 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Exercise 7: -------------------------------------------------------------------------------- 1 | alter table Player drop (ContactNo) 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 30: -------------------------------------------------------------------------------- 1 | select distinct itemtype from item 2 | -------------------------------------------------------------------------------- /OOP in Python/Day 1/OOPR-Assgn-1: -------------------------------------------------------------------------------- 1 | Customer,item,employee 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 10: -------------------------------------------------------------------------------- 1 | ALTER TABLE Supplier DROP (Emailid) 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 27: -------------------------------------------------------------------------------- 1 | select itemcode,descr,price from item 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 34: -------------------------------------------------------------------------------- 1 | insert into city(city)values('Mysore') 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 13: -------------------------------------------------------------------------------- 1 | select prodid,price,category from product 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 14: -------------------------------------------------------------------------------- 1 | select distinct category from product 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 21: -------------------------------------------------------------------------------- 1 | delete from SaleDetail where saleid=1004 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 22: -------------------------------------------------------------------------------- 1 | delete from saledetail where quantity>5 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 11: -------------------------------------------------------------------------------- 1 | CREATE TABLE CITY (CITY VARCHAR2(20) UNIQUE) 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 9: -------------------------------------------------------------------------------- 1 | ALTER TABLE SUPPLIER ADD CITY VARCHAR2(10) 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Exercise 9: -------------------------------------------------------------------------------- 1 | alter table Player modify PName varchar2(50) 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 32: -------------------------------------------------------------------------------- 1 | select distinct itemtype,category from item 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 14: -------------------------------------------------------------------------------- 1 | ALTER TABLE ADDRESS MODIFY STATE VARCHAR2(20) 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 3: -------------------------------------------------------------------------------- 1 | alter table Shopper modify mobileno varchar2(15) 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 6: -------------------------------------------------------------------------------- 1 | alter table Store rename column Name to StoreName 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Exercise 8: -------------------------------------------------------------------------------- 1 | alter table Player rename column PId to PlayerId 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 56: -------------------------------------------------------------------------------- 1 | SELECT DESCR FROM ITEM WHERE LENGTH(DESCR)>15 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 16: -------------------------------------------------------------------------------- 1 | insert into article values('A1001','Mouse',500,0,'C') 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 26: -------------------------------------------------------------------------------- 1 | select distinct designation,salary from empdetails 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 38: -------------------------------------------------------------------------------- 1 | select itemtype,descr,price from item where price>4000 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 10: -------------------------------------------------------------------------------- 1 | INSERT INTO SALESMAN VALUES(11,'Elizabeth','London') 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 11: -------------------------------------------------------------------------------- 1 | insert into Product values(110,'Bat',50,'Sports',NULL) 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 18: -------------------------------------------------------------------------------- 1 | update product set discount=25 where category='Sports' 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 37: -------------------------------------------------------------------------------- 1 | SELECT PRODID, PDESC, PRICE FROM Product ORDER BY PDESC 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Exercise 6: -------------------------------------------------------------------------------- 1 | Alter table Player add(MatchesPlayed number,MatchesWon number) 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 20: -------------------------------------------------------------------------------- 1 | select descr,price from item where descr like '%Hard disk' 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 36: -------------------------------------------------------------------------------- 1 | insert into Article values('A1002','Keyboard',1000,10,'B') 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 23: -------------------------------------------------------------------------------- 1 | select roid,location from retailoutlet where managerid is NULL 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 29: -------------------------------------------------------------------------------- 1 | select itemcode,descr,price from item where descr like '_r%' 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 20: -------------------------------------------------------------------------------- 1 | update salesman set sname='Jenny',location='Bristol' where sid=3 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 44: -------------------------------------------------------------------------------- 1 | SELECT ITEMCODE FROM ITEM WHERE ABS(QTYONHAND - REORDERLEVEL)>50 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 24: -------------------------------------------------------------------------------- 1 | SELECT PRODID,SUBSTR(PDESC,1,5) PDESC_FIVE, CATEGORY FROM Product 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 19: -------------------------------------------------------------------------------- 1 | insert into supplier values('S501','Avaya Ltd',9012345678,'Mysore') 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 16: -------------------------------------------------------------------------------- 1 | select prodid,pdesc,category,discount from product where pdesc is NULL 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 58: -------------------------------------------------------------------------------- 1 | SELECT TO_CHAR(SYSDATE,'Mon/dd/yyyy Day') AS CURRENTDATE FROM DUAL 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 18: -------------------------------------------------------------------------------- 1 | insert into bill values(1001,'Loyal World',101,'A1001',1000,'20-OCT-15',2) 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 15: -------------------------------------------------------------------------------- 1 | select prodid,pdesc,category,discount from product where category='Apparel' 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 19: -------------------------------------------------------------------------------- 1 | update product set price =50 where category='Apparel' and pdesc='Trouser' 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 57: -------------------------------------------------------------------------------- 1 | SELECT SUBSTR(ROID,2) AS "Numeric Part" FROM RETAILSTOCK GROUP BY ROID 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 34: -------------------------------------------------------------------------------- 1 | SELECT CONCAT(SNAME,CONCAT(' is from ', LOCATION)) "RESULT" FROM SalesMan 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 36: -------------------------------------------------------------------------------- 1 | SELECT PRODID, PDESC, PRICE FROM Product ORDER BY PRICE DESC, PRODID DESC 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 38: -------------------------------------------------------------------------------- 1 | SELECT LOCATION, COUNT(SID) "NUMBER_SMAN" FROM Salesman GROUP BY LOCATION 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 39: -------------------------------------------------------------------------------- 1 | SELECT CATEGORY FROM PRODUCT GROUP BY (CATEGORY) HAVING COUNT(PRODID) > 1 2 | -------------------------------------------------------------------------------- /DBMS/Day 6/Exercise 59: -------------------------------------------------------------------------------- 1 | SELECT SALEID,SLDATE FROM SALE WHERE SLDATE=(SELECT MAX(SLDATE) FROM SALE) 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 31: -------------------------------------------------------------------------------- 1 | select orderid,quotationid,status,pymtdate from orders where pymtdate is NULL 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 35: -------------------------------------------------------------------------------- 1 | insert into address values(350,'Electronics City','Mysore',570018,'Karnataka') 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 39: -------------------------------------------------------------------------------- 1 | select designation,salary from empdetails where salary between 2500 and 5000 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 23: -------------------------------------------------------------------------------- 1 | select prodid,pdesc,category from product where lower(category)='electronics' 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 32: -------------------------------------------------------------------------------- 1 | SELECT SALEID, ROUND(MONTHS_BETWEEN(SYSDATE,SLDATE),1) AS "MONTH_AGED" FROM Sale 2 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 99: -------------------------------------------------------------------------------- 1 | SELECT ENAME FROM EMP WHERE SAL= 2 | ( 3 | SELECT MAX(SAL) FROM EMP 4 | ) 5 | -------------------------------------------------------------------------------- /DBMS/Day 2/Exercise 3: -------------------------------------------------------------------------------- 1 | create table Player(PId number primary key,PName varchar2(20) NOT NULL, Ranking number) 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 25: -------------------------------------------------------------------------------- 1 | select count(saleid) SALE_COUNT from sale where MONTHS_BETWEEN(sysdate,sldate)<=40 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 27: -------------------------------------------------------------------------------- 1 | SELECT PRODID, CATEGORY, PRICE, DISCOUNT FROM Product ORDER BY CATEGORY DESC, PRICE 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 15: -------------------------------------------------------------------------------- 1 | insert into shopper values(101,'Mark Jane','Male',1234567890,'Allen Street, New York') 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 28: -------------------------------------------------------------------------------- 1 | select quotationid,sname from quotation where qstatus='Accepted' or qstatus='Rejected' 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Exercise 17: -------------------------------------------------------------------------------- 1 | select prodid,pdesc,category,discount from product where category='Apparel' AND discount>5 2 | -------------------------------------------------------------------------------- /DBMS/Day 6/Exercise 64: -------------------------------------------------------------------------------- 1 | SELECT SNAME FROM SALESMAN S WHERE NOT EXISTS(SELECT SID FROM SALE S1 WHERE S1.SID=S.SID) 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 37: -------------------------------------------------------------------------------- 1 | select quotationid,qdate,quotedprice from quotation where quotedprice between 1401 AND 2149 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 24: -------------------------------------------------------------------------------- 1 | select orderid,quotationid,status from orders where orderdate between '1-Dec 2014' AND '1-Jan-2015' 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 21: -------------------------------------------------------------------------------- 1 | select quotationid,sname,itemcode,quotedprice,qdate,qstatus from quotation where qstatus <> 'Accepted' 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 22: -------------------------------------------------------------------------------- 1 | select designation,salary from empdetails where designation='Manager' OR designation='Billing Staff' 2 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 25: -------------------------------------------------------------------------------- 1 | select itemcode,descr,price from item where category='B' AND descr like '%Shirt' or descr like '%Skirt' 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 30: -------------------------------------------------------------------------------- 1 | select prodid,sum(quantity) qty_sold from saledetail where quantity>1 group by prodid having count(*)>1 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 33: -------------------------------------------------------------------------------- 1 | SELECT ROUND(AVG(PRICE), 2) "Avg", MIN(PRICE) "Min", MAX(PRICE) "Max", COUNT(PRODID) "Total" FROM Product 2 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 67: -------------------------------------------------------------------------------- 1 | SELECT E.ENAME, E.SAL, D.DNAME 2 | FROM EMP E INNER JOIN DEPT D 3 | ON E.DEPTNO=D.DEPTNO AND E.SAL>2000 4 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 68: -------------------------------------------------------------------------------- 1 | SELECT E.ENAME, D.DNAME 2 | FROM EMP E INNER JOIN DEPT D 3 | ON E.DEPTNO=D.DEPTNO AND E.JOB='MANAGER' 4 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 17: -------------------------------------------------------------------------------- 1 | insert into store(storename,location,managername)values('Loyal World','Infy Campus, Mysore','Rohan Kumar') 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 26: -------------------------------------------------------------------------------- 1 | select NVL(pdesc,'No Description') PDESC,discount from product 2 | 3 | No expected answer for this question 4 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 71: -------------------------------------------------------------------------------- 1 | SELECT I.ITEMCODE, I.DESCR, Q.SNAME 2 | FROM ITEM I INNER JOIN QUOTATION Q 3 | ON I.ITEMCODE = Q.ITEMCODE 4 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 44: -------------------------------------------------------------------------------- 1 | SELECT ID, ENAME, DEPT, E.COMPID, MAKE 2 | FROM EMPLOYEE E INNER JOIN COMPUTER C 3 | ON E.COMPID = C.COMPID 4 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 55: -------------------------------------------------------------------------------- 1 | SELECT E.ID, E.ENAME, E.DEPT, C.MODEL 2 | FROM EMPLOYEE E FULL OUTER JOIN COMPUTER C 3 | ON E.COMPID=C.COMPID 4 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 93: -------------------------------------------------------------------------------- 1 | SELECT ITEMCODE, ITEMTYPE, DESCR, CATEGORY FROM ITEM WHERE ITEMCODE IN (SELECT ITEMCODE FROM PURCHASEBILL) 2 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 5: -------------------------------------------------------------------------------- 1 | CREATE TABLE STORE(NAME VARCHAR2(20) PRIMARY KEY,LOCATION VARCHAR2(30) NOT NULL,MANAGERNAME VARCHAR2(30) UNIQUE) 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 28: -------------------------------------------------------------------------------- 1 | SELECT PRODID, CATEGORY, DISCOUNT FROM Product WHERE CATEGORY IN ('Sports', 'Apparel') ORDER BY CATEGORY, DISCOUNT 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 31: -------------------------------------------------------------------------------- 1 | SELECT PRODID, PDESC, PRICE AS "Old_Price", ROUND(PRICE*0.775,2) AS "New_Price" FROM Product WHERE CATEGORY='Sports' 2 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 47: -------------------------------------------------------------------------------- 1 | SELECT S1.SALEID, S1.SLDATE 2 | FROM Sale S1, Salesman S2 3 | WHERE S1.SID = S2.SID 4 | AND S2.Location = 'London' 5 | -------------------------------------------------------------------------------- /DBMS/Day 3/Assignment 33: -------------------------------------------------------------------------------- 1 | select empid, salary as "Current Salary",salary*1.1 as "New Salary",salary*0.1 as "Incremented Amount" from empdetails 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 41: -------------------------------------------------------------------------------- 1 | SELECT TO_CHAR(QDATE, 'Month') MONTH, COUNT(QUOTATIONID)QUOTATIONCOUNT FROM QUOTATION GROUP BY TO_CHAR(QDATE, 'Month') 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 45: -------------------------------------------------------------------------------- 1 | SELECT ITEMCODE, AVG(QTYAVAILABLE) "Average Quantity" FROM RETAILSTOCK GROUP BY ITEMCODE HAVING AVG(QTYAVAILABLE)<75 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 49: -------------------------------------------------------------------------------- 1 | SELECT JOB, AVG(SAL) "Average Salary" FROM EMP WHERE JOB IN ('MANAGER', 'ANALYST') GROUP BY JOB HAVING AVG(SAL)>1500 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 35: -------------------------------------------------------------------------------- 1 | SELECT TO_CHAR(TO_DATE('Jan/10/2015', 'MON/DD/YYYY'), 'Month') MONTH, TO_NUMBER('2,50,000', '9,99,999') AMOUNT FROM DUAL 2 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 49: -------------------------------------------------------------------------------- 1 | SELECT S1.SNAME, S2.SALEID 2 | FROM Salesman S1 FULL OUTER JOIN Sale S2 3 | ON S1.SID=S2.SID 4 | ORDER BY S1.SNAME DESC 5 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 46: -------------------------------------------------------------------------------- 1 | SELECT PYMTMODE, COUNT(*) PYMTCOUNT FROM ORDERS WHERE TO_CHAR(PYMTDATE, 'YYYY')<'2015' GROUP BY PYMTMODE HAVING COUNT(*)>1 2 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 69: -------------------------------------------------------------------------------- 1 | SELECT D.DNAME 2 | FROM EMP E, DEPT D 3 | WHERE D.DEPTNO = E.DEPTNO AND SAL>1500 4 | GROUP BY D.DNAME HAVING COUNT(*)>1 5 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 82: -------------------------------------------------------------------------------- 1 | SELECT E.EMPID, E.EMPNAME, R.ROID, R.LOCATION 2 | FROM RETAILOUTLET R LEFT OUTER JOIN EMPDETAILS E 3 | ON R.ROID=E.WORKSIN 4 | -------------------------------------------------------------------------------- /DBMS/Day 6/Exercise 65: -------------------------------------------------------------------------------- 1 | SELECT SNAME FROM SALESMAN S WHERE EXISTS (SELECT * FROM SALE S1 WHERE S.SID=S1.SID AND TO_CHAR(S1.SLDATE, 'MM-YY')='06-15') 2 | -------------------------------------------------------------------------------- /OOP in Python/Day 1/OOPR-Exer-2: -------------------------------------------------------------------------------- 1 | Classname: 2 | Employee 3 | 4 | Attributes: 5 | age 6 | salary 7 | name 8 | 9 | Method: 10 | __init__() 11 | -------------------------------------------------------------------------------- /OOP in Python/Day 5/OOPR-Assgn-28.md: -------------------------------------------------------------------------------- 1 | ![ass28](https://user-images.githubusercontent.com/34470884/99036050-f6c77e00-25a6-11eb-989a-1fa513a32302.png) 2 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 43: -------------------------------------------------------------------------------- 1 | SELECT 'S' TYPE , SID ID, SNAME DETAILS FROM Salesman 2 | UNION ALL 3 | SELECT 'P' TYPE , PRODID ID, CATEGORY DETAILS FROM Product 4 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 48: -------------------------------------------------------------------------------- 1 | SELECT S1.SID, S1.SNAME, S1.LOCATION 2 | FROM SALESMAN S1 INNER JOIN SALESMAN S2 3 | ON S1.LOCATION=S2.LOCATION AND S1.SID<>S2.SID 4 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Assgn-14: -------------------------------------------------------------------------------- 1 | ClassName: Parrot 2 | 3 | Attributes: name,color,uniqque_number, couter->static 4 | 5 | Method: __init__(name,color) 6 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 47: -------------------------------------------------------------------------------- 1 | SELECT SNAME, AVG(QUOTEDPRICE) "Average quoted price" FROM QUOTATION WHERE QSTATUS='Closed' GROUP BY SNAME HAVING AVG(QUOTEDPRICE)>500 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 50: -------------------------------------------------------------------------------- 1 | SELECT JOB, DEPTNO, AVG(SAL) AS "AVGSALARY" FROM EMP WHERE DEPTNO IN (10,20) AND SAL>2000 GROUP BY JOB, DEPTNO HAVING AVG(SAL)>2500 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Exercise 29: -------------------------------------------------------------------------------- 1 | SELECT TO_CHAR(SLDATE, 'Month') AS MONTH, COUNT(*) AS NUMBER_SALE FROM SALE GROUP BY TO_CHAR(SLDATE, 'Month') ORDER BY COUNT(*) DESC 2 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 45: -------------------------------------------------------------------------------- 1 | SELECT ID, ENAME, E.COMPID, MAKE 2 | FROM EMPLOYEE E INNER JOIN COMPUTER c 3 | ON E.COMPID=C.COMPID AND MODEL IN ('Precision','Edge') 4 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 54: -------------------------------------------------------------------------------- 1 | SELECT E.ENAME, E.DEPT, NVL(C.MODEL,'Not allocated') "MODEL" 2 | FROM EMPLOYEE E LEFT OUTER JOIN COMPUTER C 3 | ON E.COMPID=C.COMPID 4 | -------------------------------------------------------------------------------- /DBMS/Day 2/Exercise 4: -------------------------------------------------------------------------------- 1 | create table Tournament(TId INTEGER primary key,TName varchar2(30) not null,StartDt date not null, EndDt date not null,Prize INTEGER not null) 2 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 77: -------------------------------------------------------------------------------- 1 | SELECT Q.SNAME, Q.QUOTATIONID 2 | FROM QUOTATION Q, ORDERS O 3 | WHERE Q.QUOTATIONID=O.QUOTATIONID 4 | AND O.DELIVEREDDATE-O.ORDERDATE<=5 5 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 58: -------------------------------------------------------------------------------- 1 | SELECT P1.PRODID, P1.CATEGORY, P1. PRICE 2 | FROM PRODUCT P1 INNER JOIN PRODUCT P2 3 | ON P1.PRICE=P2.PRICE WHERE P1.PRODID <> P2.PRODID 4 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 43: -------------------------------------------------------------------------------- 1 | SELECT EMPID, SALARY "Current Salary", ROUND(SALARY*1.2,2) "New Salary", SALARY*0.2 "Incremented Amount" FROM EmpDetails WHERE Designation='Manager' 2 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 72: -------------------------------------------------------------------------------- 1 | SELECT C.CUSTID "Customer Id", C.CUSTNAME "Customer Name" 2 | FROM CUSTOMER C INNER JOIN EMPDETAILS E 3 | ON C.CUSTNAME=E.EMPNAME AND C.EMAILID=E.EMAILID 4 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 73: -------------------------------------------------------------------------------- 1 | SELECT I.ITEMCODE, I.DESCR, I.CATEGORY, Q.QUOTEDPRICE 2 | FROM ITEM I INNER JOIN QUOTATION Q 3 | ON I.ITEMCODE=Q.ITEMCODE WHERE Q.QSTATUS = 'Accepted' 4 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 46: -------------------------------------------------------------------------------- 1 | SELECT DEPT, COUNT(C.COMPID) "NUMBER OF COMPUTERS" 2 | FROM EMPLOYEE E INNER JOIN COMPUTER C 3 | ON E.COMPID = C.COMPID AND MAKE='Dell' 4 | GROUP BY DEPT 5 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 84: -------------------------------------------------------------------------------- 1 | SELECT C1.CUSTID, C1.CUSTNAME 2 | FROM CUSTOMER C1 INNER JOIN CUSTOMER C2 3 | ON C1.CUSTID <> C2.CUSTID 4 | WHERE C1.ADDRESS=C2.ADDRESS 5 | ORDER BY C1.ADDRESS 6 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 8: -------------------------------------------------------------------------------- 1 | CREATE TABLE Supplier( 2 | Supplierid VARCHAR2(6) PRIMARY KEY, 3 | Name VARCHAR2(30), 4 | ContactNo VARCHAR2(15) NOT NULL, 5 | Emailid VARCHAR2(30) 6 | ); 7 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 51: -------------------------------------------------------------------------------- 1 | SELECT S2.SALEID, S3.PRODID, S1.SID, S1.SNAME FROM SALE S2 INNER JOIN SALESMAN S1 ON S1.SID=s2.SID INNER JOIN SALEDETAIL S3 ON S2.SALEID=S3.SALEID ORDER BY SNAME DESC 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 42: -------------------------------------------------------------------------------- 1 | SELECT ORDERID, ROUND(MONTHS_BETWEEN(PYMTDATE, ORDERDATE),2) "No of Months" FROM ORDERS WHERE ROUND(MONTHS_BETWEEN(PYMTDATE, ORDERDATE),2)>0.1 AND STATUS='Delivered'; 2 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 48: -------------------------------------------------------------------------------- 1 | SELECT ITEMTYPE, CATEGORY, ROUND(AVG(PRICE),2) "AVG_PRICE" FROM ITEM WHERE ITEMTYPE IN ('FMCG','Computer') GROUP BY CATEGORY, ITEMTYPE HAVING ROUND(AVG(PRICE),2) < 2000; 2 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 41: -------------------------------------------------------------------------------- 1 | SELECT PRODID, PDESC, CATEGORY, DISCOUNT FROM PRODUCT WHERE DISCOUNT<10 2 | UNION ALL 3 | SELECT PRODID, PDESC, CATEGORY, DISCOUNT FROM PRODUCT WHERE CATEGORY = 'Sports' 4 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 55: -------------------------------------------------------------------------------- 1 | SELECT ORDERID "ORDER ID", STATUS "ORDER STATUS", 2 | CASE 3 | WHEN PYMTMODE IS NULL THEN 'Payment yet not done' 4 | ELSE PYMTMODE 5 | END "PAYMENT MODE" 6 | FROM ORDERS 7 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 74: -------------------------------------------------------------------------------- 1 | SELECT R1.ROID, I.DESCR, I.ITEMTYPE, R2.UNITPRICE 2 | FROM ITEM I,RETAILOUTLET R1,RETAILSTOCK R2 3 | WHERE I.ITEMCODE=R2.ITEMCODE AND R1.ROID=R2.ROID AND R2.UNITPRICE>1500 4 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 76: -------------------------------------------------------------------------------- 1 | SELECT I.ITEMCODE, I.DESCR 2 | FROM ITEM I,QUOTATION Q 3 | WHERE I.ITEMCODE=Q.ITEMCODE 4 | AND I.PRICE=Q.QUOTEDPRICE 5 | GROUP BY I.ITEMCODE, I.DESCR 6 | HAVING COUNT(*)>1 7 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 96: -------------------------------------------------------------------------------- 1 | SELECT ITEMCODE, DESCR, PRICE FROM ITEM WHERE PRICE = 2 | ( 3 | SELECT MAX(PRICE) FROM ITEM WHERE PRICE< 4 | ( 5 | SELECT MAX(PRICE) FROM ITEM 6 | ) 7 | ) 8 | -------------------------------------------------------------------------------- /OOP in Python/Day 1/OOPR-Assgn-4: -------------------------------------------------------------------------------- 1 | Classname: Vehicle 2 | 3 | Attributes: premiun_amount, vehicle_cost, vehicle_id, vehicle_type 4 | 5 | Methods: __init__(), calculate_premium(), display_vehicle_details() 6 | -------------------------------------------------------------------------------- /OOP in Python/Day 2/OOPR-Exer-5: -------------------------------------------------------------------------------- 1 | ClassName: Vehicle 2 | 3 | Attributes: fuel_left, mileage 4 | 5 | Method: __init__(), identify_distance_that_can_be_travelled(), identify_distance_travelled(initial_fuel) 6 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 40: -------------------------------------------------------------------------------- 1 | SELECT SID, SNAME, LOCATION FROM Salesman WHERE SNAME LIKE '%e%' AND LOCATION LIKE '%o%' 2 | UNION ALL 3 | SELECT SID, SNAME, LOCATION FROM Salesman WHERE SNAME LIKE '%a%' AND LOCATION LIKE '%a%' 4 | -------------------------------------------------------------------------------- /OOP in Python/Day 1/OOPR-Assgn-6: -------------------------------------------------------------------------------- 1 | ClassName: Instructor 2 | 3 | Attributes: technology_skills, avg_feedback, experience, instructor_name 4 | 5 | Methods: __init__(), check_eligibility(), allocate_course(technology) 6 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 75: -------------------------------------------------------------------------------- 1 | SELECT Q.ITEMCODE, Q.SNAME, SUM(O.QTYORDERED) TOTALQUANTITY 2 | FROM QUOTATIOn Q, ORDERS O 3 | WHERE Q.QUOTATIONID=O.QUOTATIONID 4 | GROUP BY Q.ITEMCODE,Q.SNAME 5 | HAVING SUM(O.QTYORDERED) >=100 6 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 2: -------------------------------------------------------------------------------- 1 | create table Shopper 2 | (Shopperid number primary key, 3 | Shoppername varchar2(20) not null, 4 | gender char(6) 5 | check(gender in ('Male','Female')), 6 | MobileNo integer not null, 7 | address varchar2(50) 8 | ) 9 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Exer-13.js: -------------------------------------------------------------------------------- 1 | //PF-Exer-13 2 | num1=5 3 | num2=5 4 | 5 | //Write your code here 6 | if(num1==num2){ 7 | console.log(num1+num2) 8 | } 9 | else { 10 | console.log(2*(num2+num1)) 11 | } 12 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 13: -------------------------------------------------------------------------------- 1 | CREATE TABLE Address( 2 | HouseNo NUMBER, 3 | Street VARCHAR2(30), 4 | city VARCHAR2(20) REFERENCES City(city), 5 | zip NUMBER(6) CHECK(zip>=0), 6 | State VARCHAR2(5), 7 | CONSTRAINT address_pk PRIMARY KEY(HouseNo, Street, City) 8 | ); 9 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 57: -------------------------------------------------------------------------------- 1 | ELECT x.SID, x.SNAME FROM 2 | (SELECT s3.SID, S3.SNAME FROM Salesman S3) x 3 | LEFT OUTER JOIN 4 | (SELECT S1.SID, S1.SNAME FROM Salesman S1 INNER JOIN Sale S2 ON S1.SID=S2.SID GROUP BY S1.SID,S1.SNAME) y 5 | ON 6 | y.SID = x.SID 7 | WHERE y.SID IS NULL 8 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 102: -------------------------------------------------------------------------------- 1 | SELECT I.ITEMCODE, I.DESCR, Q.QDATE 2 | FROM ITEM I, QUOTATION Q 3 | WHERE I.ITEMCODE=Q.ITEMCODE 4 | AND Q.QUOTEDPRICE < 5 | ( 6 | SELECT MAX(QUOTEDPRICE) FROM QUOTATION Q1 7 | WHERE Q1.QDATE=Q.QDATE 8 | AND Q1.QUOTATIONID<>Q.QUOTATIONID 9 | ) 10 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 53: -------------------------------------------------------------------------------- 1 | SELECT S1.LOCATION, P1.CATEGORY, SUM(S3.QUANTITY) "Total Quantity" 2 | FROM SALE S2 INNER JOIN SALESMAN S1 ON S1.SID=s2.SID 3 | INNER JOIN SALEDETAIL S3 ON S2.SALEID=S3.SALEID 4 | INNER JOIN PRODUCT P1 ON S3.PRODID = P1.PRODID 5 | GROUP BY S1.LOCATION, P1.CATEGORY 6 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 98: -------------------------------------------------------------------------------- 1 | SELECT ENAME, JOB FROM EMP WHERE EMPNO IN 2 | ( 3 | SELECT EMPNO FROM VEHICLE V, EMPVEHICLE EV WHERE EV.VEHICLEID=V.VEHICLEID 4 | ) 5 | 6 | More shorthand version: 7 | SELECT ENAME, JOB FROM EMP WHERE EMPNO IN 8 | ( 9 | SELECT EMPNO FROM EMPVEHICLE 10 | ) 11 | -------------------------------------------------------------------------------- /OOP in Python/Day 1/OOPR-Assgn-2: -------------------------------------------------------------------------------- 1 | Customer: 2 | Attributes:customer_name, bill_amount 3 | Methods: purchases(),pays_bill(amount) 4 | 5 | Item: 6 | Attributes: item_id, description, price_per_unit 7 | Methods: 8 | 9 | Employee: 10 | Attributes: designation, emp_name 11 | Methods: 12 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 85: -------------------------------------------------------------------------------- 1 | SELECT C.CUSTNAME, P.BILLAMOUNT 2 | FROM CUSTOMER C, PURCHASEBILL P 3 | WHERE C.CUSTID=P.CUSTID 4 | AND P.BILLAMOUNT>5000 5 | 6 | Didnot solve Optional Assignments from 86 onwards. 7 | The assignments seem similar to the previous mandatory exercises and assignments, 8 | hence skipped them. 9 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 56: -------------------------------------------------------------------------------- 1 | SELECT E1.ID, E1.ENAME, E2.ID MGRID, E2.ENAME MGRNAME, C1.MODEL E_MODEL, C2.MODEL M_MODEL 2 | FROM EMPLOYEE E1 INNER JOIN EMPLOYEE E2 3 | ON E1.MANAGER=E2.ID AND E2.COMPID IS NOT NULL 4 | INNER JOIN COMPUTER C1 ON 5 | C1.COMPID = E1.COMPID 6 | INNER JOIN COMPUTER C2 ON 7 | C2.COMPID = E2.COMPID 8 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 40: -------------------------------------------------------------------------------- 1 | SELECT DISTINCT ITEMTYPE, 2 | CASE 3 | WHEN PRICE BETWEEN 0 AND 499 THEN 'Cheap' 4 | WHEN PRICE BETWEEN 500 AND 1999 THEN 'Affordable' 5 | WHEN PRICE BETWEEN 2000 AND 4999 THEN 'Expensive' 6 | WHEN PRICE>=500 THEN 'Very Expensive' 7 | END AS CLASSIFICATION 8 | FROM ITEM ORDER BY ITEMTYPE 9 | -------------------------------------------------------------------------------- /DBMS/Day 4/Assignment 51: -------------------------------------------------------------------------------- 1 | SELECT EMPID, EMPNAME, SALARY, 2 | CASE DESIGNATION 3 | WHEN 'Administrator' THEN SALARY * 1.10 4 | WHEN 'Manager' THEN SALARY * 1.05 5 | WHEN 'Billing Staff' THEN SALARY * 1.2 6 | WHEN 'Security' THEN SALARY * 1.25 7 | ELSE SALARY * 1.02 8 | END "increased salary" 9 | FROM EmpDetails 10 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 42: -------------------------------------------------------------------------------- 1 | Method - 1: 2 | SELECT PRODID, PDESC, CATEGORY, DISCOUNT FROM PRODUCT WHERE DISCOUNT<10 3 | UNION 4 | SELECT PRODID, PDESC, CATEGORY, DISCOUNT FROM PRODUCT WHERE CATEGORY = 'Sports' 5 | 6 | Method - 2: 7 | SELECT PRODID, PDESC, CATEGORY, DISCOUNT FROM PRODUCT WHERE DISCOUNT<10 OR CATEGORY = 'Sports' 8 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 78: -------------------------------------------------------------------------------- 1 | SELECT NVL(E.EMPNAME,'No Manager') EMPNAME, I.CATEGORY, SUM(R2.QTYAVAILABLE) TOTALQUANTITY 2 | FROM RETAILOUTLET R1 INNER JOIN RETAILSTOCK R2 ON R1.ROID=R2.ROID 3 | LEFT OUTER JOIN EMPDETAILS E 4 | ON R1.MANAGERID=E.EMPID 5 | INNER JOIN ITEM I 6 | ON I.ITEMCODE=R2.ITEMCODE 7 | GROUP BY E.EMPNAME, I.CATEGORY 8 | -------------------------------------------------------------------------------- /DBMS/Day 6/Exercise 60: -------------------------------------------------------------------------------- 1 | SELECT SNAME FROM SALESMAN WHERE SID IN (SELECT SID FROM Sale GROUP BY SID HAVING COUNT(SALEID)>=2) 2 | 3 | Note: If we used equality operator(=) 4 | instead of IN we get logical error, 5 | Reason being, the inner query can return multiple rows, 6 | which is supported by IN operators, but not by '=' 7 | operator 8 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Assgn-21.py: -------------------------------------------------------------------------------- 1 | #PF-Tryout 2 | 3 | def generate_next_date(day,month,year): 4 | #Start writing your code here 5 | next_day=day+1 6 | next_month=month 7 | next_year=year 8 | print(next_day,"-",next_month,"-",next_year) 9 | 10 | 11 | generate_next_date(22,3,2011) 12 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Exer-14.py: -------------------------------------------------------------------------------- 1 | #PF-Tryout 2 | #Start writing your code here 3 | score = 0 4 | 5 | if 80<=score<=100 : 6 | print("A") 7 | elif 73<=score<=79 : 8 | print("B") 9 | elif 65<=score<=72 : 10 | print("C") 11 | elif 0<=score<=64 : 12 | print("D") 13 | else: 14 | print("Z") 15 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 7: -------------------------------------------------------------------------------- 1 | CREATE TABLE Bill( 2 | BillNo NUMBER PRIMARY KEY, 3 | StoreName VARCHAR2(20) REFERENCES Store(StoreName), 4 | Shopperid NUMBER REFERENCES Shopper(ShopperId), 5 | ArCode CHAR(5) REFERENCES Article(ArCode), 6 | Amount NUMBER, 7 | BillDate DATE, 8 | Quantity NUMBER(4) DEFAULT 1 CHECK(Quantity>0) 9 | ); 10 | -------------------------------------------------------------------------------- /DBMS/Day 2/Assignment 4: -------------------------------------------------------------------------------- 1 | CREATE TABLE Article( 2 | ArCode CHAR(5) CONSTRAINT arcode_article_pk PRIMARY KEY, 3 | CHECK(ArCode LIKE 'A%'), 4 | ArName VARCHAR2(30) CONSTRAINT article_name NOT NULL, 5 | Rate NUMBER(8,2), 6 | Quantity NUMBER(4) DEFAULT 0, 7 | CHECK(Quantity >=0), 8 | Class CHAR(1) CONSTRAINT Artice_class_ch CHECK(Class IN('A', 'B', 'C')) 9 | ) 10 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 50: -------------------------------------------------------------------------------- 1 | SELECT S1.SID, S1.SNAME, SUM(P1.PRICE*S3.QUANTITY) TAMOUNT, SUM((P1.PRICE*S3.QUANTITY)*P1.DISCOUNT/100) TDISCOUNT 2 | FROM SALE S2 INNER JOIN SALESMAN S1 ON S1.SID=s2.SID 3 | INNER JOIN SALEDETAIL S3 ON S2.SALEID=S3.SALEID 4 | INNER JOIN PRODUCT P1 ON S3.PRODID = P1.PRODID 5 | GROUP BY S1.SID, S1.SNAME 6 | ORDER BY SUM(P1.PRICE*S3.QUANTITY) DESC 7 | -------------------------------------------------------------------------------- /OOP in Python/Day 2/OOPR-Assgn-13.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-13 2 | #Start writing your code here 3 | 4 | class Classroom: 5 | classroom_list=[] 6 | 7 | @staticmethod 8 | def search_classroom(class_room): 9 | for room in Classroom.classroom_list: 10 | if class_room.lower()==room.lower(): 11 | return "Found" 12 | return -1 13 | -------------------------------------------------------------------------------- /OOP in Python/Day 1/OOPR-Exer-3.py: -------------------------------------------------------------------------------- 1 | #OOPR-Exer-3 2 | #Start writing your code here 3 | 4 | 5 | class Employee: 6 | def __init__(self): 7 | self.name=None 8 | self.age=None 9 | self.salary=None 10 | 11 | print("Employee Details: Name: "+name+" Age: "+str(age)+ " Salary: "+str(salary)) 12 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 9/PF-Assgn-60.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-60 2 | def remove_duplicates(value): 3 | #start writing your code here 4 | l=[] 5 | temp=[] 6 | for i in value: 7 | l.append(i) 8 | for i in l: 9 | if i not in temp: 10 | temp.append(i) 11 | return "".join(temp) 12 | 13 | print(remove_duplicates("11223445566666ababzzz@@@123#*#*")) 14 | -------------------------------------------------------------------------------- /DBMS/Day 2/Exercise 5: -------------------------------------------------------------------------------- 1 | CREATE TABLE Match( 2 | MId INTEGER PRIMARY KEY, 3 | TId INTEGER REFERENCES Tournament(TournamentId), 4 | Player1 INTEGER REFERENCES Player(PlayerId), 5 | Player2 INTEGER REFERENCES Player(PlayerId), 6 | MatchDt DATE NOT NULL, 7 | Winner INTEGER REFERENCES Player(PlayerId), 8 | Score VARCHAR2(30) NOT NULL, 9 | CONSTRAINT playler_id_ck CHECK(Player1 <> Player2) 10 | ) 11 | -------------------------------------------------------------------------------- /DBMS/Day 5/Exercise 52: -------------------------------------------------------------------------------- 1 | SELECT S1.SID, S1.SNAME, NVL(SUM(P1.PRICE*S3.QUANTITY),0) TAMOUNT, NVL(SUM((P1.PRICE*S3.QUANTITY)*P1.DISCOUNT/100),0) TDISCOUNT 2 | FROM SALESMAN S1 LEFT OUTER JOIN SALE S2 ON S1.SID=s2.SID 3 | LEFT OUTER JOIN SALEDETAIL S3 ON S2.SALEID=S3.SALEID 4 | LEFT OUTER JOIN PRODUCT P1 ON S3.PRODID = P1.PRODID 5 | GROUP BY S1.SID, S1.SNAME 6 | ORDER BY SUM(P1.PRICE*S3.QUANTITY) DESC 7 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 7/PF-Exer-33.py: -------------------------------------------------------------------------------- 1 | #PF-Tryout 2 | 3 | def guess_number(number_in_mind): 4 | import random 5 | i=random.randrange(1,11) 6 | print(i) 7 | if inumber_in_mind: 10 | print ('Number is high') 11 | else: 12 | print ('You have got it right!!!') 13 | 14 | guess_number(4) 15 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 1/PF-Assgn-4.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-4 2 | #This verification is based on string match. 3 | #Day 1 4 | principal=7800 5 | rate_of_interest=7.7 6 | time=26 7 | interest=0 8 | 9 | #Start writing your code from here 10 | #Populate the variable: interest 11 | interest=(principal*rate_of_interest*time)/100 12 | 13 | 14 | #Do not modify the below print statement for verification to work 15 | print(interest) 16 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 70: -------------------------------------------------------------------------------- 1 | Step 1: Fetch all the employee no's (including NULL) an their vehicle ids 2 | SELECT E.EMPNO, EV.VEHICLEID FROM EMP E 3 | LEFT OUTER JOIN EMPVEHICLE EV 4 | ON E.EMPNO = EV.EMPNO 5 | 6 | Step 2: fetch all the vehicle names from the vehcile no's 7 | SELECT E.ENAME, V.VEHICLENAME FROM EMP E 8 | LEFT OUTER JOIN EMPVEHICLE EV 9 | ON E.EMPNO = EV.EMPNO 10 | LEFT OUTER JOIN VEHICLE V 11 | ON EV.VEHICLEID = V.VEHICLEID 12 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 100: -------------------------------------------------------------------------------- 1 | Fetch the empno from EmpVehicle that share same vehcile: 2 | SELECT EV1.EMPNO FROM EMPVEHICLE EV1, EMPVEHICLE EV2 WHERE EV1.VEHICLEID=EV2.VEHICLEID AND 3 | EV1.EMPNO<>EV2.EMPNO 4 | GROUP BY EV1.EMPNO 5 | 6 | Step2: 7 | SELECT EMPNO, ENAME FROM EMP WHERE EMPNO IN ( 8 | SELECT EV1.EMPNO FROM EMPVEHICLE EV1, EMPVEHICLE EV2 WHERE EV1.VEHICLEID=EV2.VEHICLEID AND 9 | EV1.EMPNO<>EV2.EMPNO 10 | GROUP BY EV1.EMPNO 11 | ) 12 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 8/PF-Exer-40.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python lambda expression for calculating sum of two numbers and find out whether the sum is divisible by 10 or not. 3 | ''' 4 | 5 | #PF-Exer-40 6 | #This verification is based on string match. 7 | 8 | num1=20 9 | num2=30 10 | 11 | div = lambda x,y:x+y 12 | 13 | if(div(num1,num2)%10)==0: 14 | print("Divisible by 10") 15 | else: 16 | print("Not Divisible by 10") 17 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Exer-8.py: -------------------------------------------------------------------------------- 1 | #OOPR-Exer-8 2 | class Juggler: 3 | def __init__(self,name): 4 | self.__name=name 5 | 6 | def juggles(self,jugglingitem): 7 | #write the code to make the juggler juggle 8 | print(self.__name+" is juggling with "+self.JugglingItem) 9 | 10 | class JugglingItem: 11 | def __init__(self,name): 12 | self.__name=name 13 | 14 | def get_name(self): 15 | return self.__name 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Hey there! 2 | 3 | I am Sudarshan Tadage and this repository consist of solution of InfyTQ python course. 4 | InfyTQ is best platform provided by Infosys to learn python. My request to all of you please dont copy and paste solution directly from here, first try it yourself and just refer these solutions in case of any doubt. 5 | For quiz exercise and assignments from Day 1 and Day 6 visit below link: 6 | https://youtu.be/5nxoUhpu6cU 7 | 8 | All the Best 9 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 4/JS-Exer-25.js: -------------------------------------------------------------------------------- 1 | /* 2 | Write a Java Script function, find_sum() that accepts an integer, n and returns the sum of first, n numbers. 3 | Invoke the function and display the sum of first n numbers. 4 | */ 5 | 6 | //JS-Exer-25 7 | 8 | //Start writing your code here 9 | function find_sum(n){ 10 | var sum=0; 11 | for(i=1;i<=n;i++){ 12 | sum=sum+i; 13 | } 14 | console.log(sum); 15 | } 16 | find_sum(6) 17 | -------------------------------------------------------------------------------- /OOP in Python/Day 4/OOPR-Assgn-26.py: -------------------------------------------------------------------------------- 1 | Class Book 2 | 3 | Attributes: author, name, code, price, year 4 | 5 | Methods: __init__(author,name,code,price,year) 6 | get_author_details() 7 | 8 | 9 | 10 | Class Author 11 | 12 | Attributes: name, age, country 13 | 14 | Methods: __init__(name,age,country) 15 | write_books() 16 | attend_press_meetings() 17 | 18 | 19 | Relationship : Book Has a Author 20 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 105: -------------------------------------------------------------------------------- 1 | The payroll department requires the details of those employees 2 | who are getting the highest salary --> MAX(SAL) 3 | in each designation. -> Outer Query's Designation must match the inner query 4 | Display empid, empname, designation and salary as per the given requirement. 5 | 6 | SELECT E1.EMPID, E1.EMPNAME, E1.DESIGNATION, E1.SALARY 7 | FROM EMPDETAILS E1 8 | WHERE E1.SALARY = 9 | ( 10 | SELECT MAX(SALARY) 11 | FROM EMPDETAILS E2 12 | WHERE E2.DESIGNATION=E1.DESIGNATION 13 | ) 14 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Exer-12.go: -------------------------------------------------------------------------------- 1 | //PF-Exer-12 2 | //This verification is based on string match. 3 | //Day 2 4 | package main 5 | import ("fmt") 6 | func main(){ 7 | //Write your program logic here 8 | var Num1 int = 3; 9 | var Num2 int = 4; 10 | var Num3 int = 1; 11 | if(Num1>Num3 && Num1>Num2){ 12 | fmt.Println(Num1); 13 | }else if(Num2>Num1 && Num2>Num3){ 14 | fmt.Println(Num2); 15 | }else{ 16 | fmt.Println(Num3) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 94: -------------------------------------------------------------------------------- 1 | Find the min quoted price: 2 | SELECT MIN(QUOTEDPRICE) FROM QUOTATION 3 | 4 | Find the corresponding distinct itemcodes: 5 | SELECT DISTINCT ITEMCODE FROM QUOTATION WHERE QUOTEDPRICE = (SELECT MIN(QUOTEDPRICE) FROM QUOTATION) 6 | 7 | Find the type in item table corresponding to the itemcode obained in step 2: 8 | SELECT ITEMCODE, ITEMTYPE, DESCR, CATEGORY FROM ITEM WHERE ITEMCODE = (SELECT DISTINCT ITEMCODE FROM QUOTATION WHERE QUOTEDPRICE = (SELECT MIN(QUOTEDPRICE) FROM QUOTATION WHERE QSTATUS='Rejected')) 9 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Exer-9.js: -------------------------------------------------------------------------------- 1 | //PF-Exer-9 2 | 3 | noOfFlightsTakeOff=100 4 | noOfFlightsLanded=110 5 | seatingCapacityTakeOff=150 6 | seatingCapacityLanded=185 7 | totalCookies=0 8 | 9 | //Write your code here 10 | //Populate the variable: totalCookies 11 | takeoff=noOfFlightsTakeOff*seatingCapacityTakeOff 12 | landed=(noOfFlightsLanded*seatingCapacityLanded)//2 13 | totalCookies=2*(takeoff+landed) 14 | 15 | //Do not modify the below print statement for verification to work 16 | console.log(totalCookies) 17 | -------------------------------------------------------------------------------- /DBMS/Day 6/Exercise 63: -------------------------------------------------------------------------------- 1 | SELECT SID, SNAME, LOCATION 2 | FROM SALESMAN 3 | WHERE SID IN (SELECT SID FROM 4 | (SELECT S1.SID, SUM(((P.PRICE*S2.QUANTITY)*((100-P.DISCOUNT)/100))) TOTALAMOUNT FROM SALE S1, SALEDETAIL S2, PRODUCT P WHERE S1.SALEID=S2.SALEID AND S2.PRODID = P.PRODID GROUP BY S1.SID ORDER BY S1.SID) 5 | WHERE TOTALAMOUNT> 6 | (SELECT SUM(SUM(((P.PRICE*S2.QUANTITY)*((100-P.DISCOUNT)/100)))/SUM(S2.QUANTITY)) TOTALAMOUNT FROM SALE S1, SALEDETAIL S2, PRODUCT P WHERE S1.SALEID=S2.SALEID AND S2.PRODID = P.PRODID GROUP BY S1.SID) 7 | ) 8 | -------------------------------------------------------------------------------- /OOP in Python/Day 1/OOPR-Assgn-3.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-3 2 | #Start writing your code here 3 | 4 | class Customer: 5 | def __init__(self): 6 | self.customer_name="Sudarshan" 7 | self.bill_amount=0 8 | 9 | def pays_bill(self,amount): 10 | print(self.customer_name+" pays bill amount of Rs. "+str(amount)) 11 | 12 | def purchases(self): 13 | self.bill_amount=500 14 | bill=self.bill_amount-self.bill_amount*5/100 15 | self.pays_bill(bill) 16 | 17 | 18 | c1=Customer() 19 | c1.purchases() 20 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 4/PF-Exer-24.go: -------------------------------------------------------------------------------- 1 | //Write a Go function, find_square() that accepts an integer number, n and returns the square of n. 2 | //Invoke the function and display the square of the number. 3 | 4 | //PF-Exer-24 5 | //This verification is based on string match. 6 | 7 | package main 8 | 9 | import ("fmt") 10 | 11 | func find_square(n int) { 12 | var square int =0 13 | square=n*n 14 | fmt.Println(square) 15 | } 16 | 17 | func main() { 18 | //Write your program logic here 19 | var n int=3 20 | find_square(n) 21 | } 22 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 5/PF-Exer-29.py: -------------------------------------------------------------------------------- 1 | #PF-Exer-29 2 | def merge_lists(list1,list2): 3 | #Write your logic here 4 | new_merge_list=list1+list2 5 | return new_merge_list 6 | def sort_list(merged_list): 7 | #Write your logic here 8 | merged_list=sorted(merged_list) 9 | return merged_list 10 | 11 | #Provide different values for list1 and list2 and test your program 12 | merged_list=merge_lists(list1=[1,2,3,4,1] ,list2=[2,3,4,5,4,6]) 13 | print(merged_list) 14 | sorted_merged_list=sort_list(merged_list) 15 | print(sorted_merged_list) 16 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Assgn-15.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-15 2 | #Start writing your code here 3 | class Parrot: 4 | __counter=7000 5 | def __init__(self,name,color): 6 | self.__name=name 7 | self.__color=color 8 | self.__unique_number=Parrot.__counter+1 9 | 10 | Parrot.__counter = Parrot.__counter + 1 11 | 12 | def get_name(self): 13 | return self.__name 14 | 15 | def get_color(self): 16 | return self.__color 17 | 18 | def get_unique_number(self): 19 | return self.__unique_number 20 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Assgn-15.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-15 2 | 3 | def find_product(num1,num2,num3): 4 | product=0 5 | #write your logic here 6 | if(num1!=7 and num2!=7 and num3!=7): 7 | product=num3*num1*num2 8 | elif(num1==7 and num2!=7 and num3!=7): 9 | product=num3*num2 10 | elif(num1!=7 and num2==7 and num3!=7): 11 | product=num3 12 | else: 13 | product=-1 14 | return product 15 | 16 | #Provide different values for num1, num2, num3 and test your program 17 | product=find_product(7,6,2) 18 | print(product) 19 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 3/PF-Exer-15.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a Python program to find the sum of digits of a given number. E.g. Sum of number 123 will be 6 3 | ''' 4 | 5 | #PF-Exer-15 6 | def find_sum_of_digits(number): 7 | sum_of_digits=0 8 | #Write your logic here 9 | while(number>0): 10 | rem=number%10 11 | sum_of_digits+=rem 12 | number=number//10 13 | return sum_of_digits 14 | 15 | #Provide different values for number and test your program 16 | sum_of_digits=find_sum_of_digits(123) 17 | print("Sum of digits:",sum_of_digits) 18 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 3/PF-Exer-16.js: -------------------------------------------------------------------------------- 1 | //Write a JavaScript program to find and display least common multiple of two whole numbers. 2 | //Least Common Multiple of two numbers, say num1 and num2, is the smallest positive number that is divisible by both num1 and num2. 3 | 4 | 5 | //PF-Exer-16 6 | 7 | num1=5 8 | num2=10 9 | 10 | //Write your code here 11 | if(num2>num1){ 12 | i = num2 13 | while(i%num1!=0){ 14 | i+=num2 15 | } 16 | } 17 | else { 18 | i=num1 19 | while(i%num2!=0){ 20 | i+=num1 21 | } 22 | } 23 | console.log(i) 24 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 81: -------------------------------------------------------------------------------- 1 | Important points to note: 2 | Given: 3 | 1) For each item -> requires left outer join 4 | 2) Specific Outlet ONLY -> use AND Operator 5 | 3) If no stock display N.A. -> requires NVL() 6 | 7 | SELECT I.ITEMCODE, I.DESCR, NVL(TO_CHAR(R.QTYAVAILABLE), 'N.A.') AS "QTYAVAILABLE" 8 | FROM ITEM I LEFT OUTER JOIN RETAILSTOCK R 9 | ON I.ITEMCODE=R.ITEMCODE AND R.ROID='R1001' 10 | 11 | NVL Function doesnot accept data of different data types. 12 | R.QTYAVAILABLE is NUMBER while 'N.A.' is char datatype. 13 | Hence we convert using TO_CHAR(R.QTYAVAILABLE) and use NVL(TO_CHAR(R.QTYAVAILABLE), 'N.A.') 14 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 83: -------------------------------------------------------------------------------- 1 | Given, 2 | 1) ..of those employees who work in same retail outlet where George works... -> Self join 3 | 2) Do not display George in result -> operator: <> 4 | 5 | SELECT E1.EMPNAME, E1.DESIGNATION, E1.EMAILID 6 | FROM EMPDETAILS E1 INNER JOIN EMPDETAILS E2 7 | ON E1.WORKSIN=E2.WORKSIN 8 | WHERE E2.EMPNAME='George' 9 | AND E1.EMPNAME <> 'George' 10 | 11 | E1 should be the final output table that doesnot contain the name 'George' 12 | To fetch the retail outlet where George works we take another similar table E2 with only one tuple of George 13 | and match it with the worksin with other employees. 14 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Exer-8.go: -------------------------------------------------------------------------------- 1 | //PF-Exer-8 2 | //This verification is based on string match. 3 | 4 | package main 5 | import ("fmt") 6 | func main(){ 7 | var finalFee float32 8 | //Write your program logic here 9 | //Populate the variable: finalFee 10 | var marks float32= 70 11 | var percent float32 = marks/2 12 | var extrafees float32 = 1500 13 | var fees float32 = 25000 14 | var sc float32 = (fees * percent)/100 15 | finalFee = (fees - sc)+extrafees 16 | //Do not modify the below print statement for verification to work 17 | fmt.Println(finalFee) 18 | } 19 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 3/PF-Exer-18.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Given a list of integer values. Write a python program to check whether it contains same number in adjacent position. 3 | Display the count of such adjacent occurrences. 4 | ''' 5 | 6 | #PF-Exer-18 7 | 8 | def get_count(num_list): 9 | count=0 10 | 11 | # Write your logic 12 | for i in range(0,len(num_list)-1): 13 | if num_list[i]==num_list[i+1]: 14 | count=count+1 15 | 16 | return count 17 | 18 | #provide different values in list and test your program 19 | num_list=[1,1,5,100,-20,-20,6,0,0] 20 | print(get_count(num_list)) 21 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 5/PF-Assgn-34.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python function, find_pairs_of_numbers() which accepts a list of positive integers with no repetitions and returns count of pairs 3 | of numbers in the list that adds up to n. The function should return 0, if no such pairs are found in the list. 4 | ''' 5 | 6 | #PF-Assgn-34 7 | def find_pairs_of_numbers(num_list,n): 8 | count=0 9 | for i in num_list: 10 | s=n-i 11 | if s in num_list: 12 | count+=1 13 | return count//2 14 | 15 | num_list=[3, 4, 1, 8, 5, 9, 0, 6] 16 | n=9 17 | print(find_pairs_of_numbers(num_list,n)) 18 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 1/PF-Assgn-3.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-3 2 | #This verification is based on string match. 3 | mileage=12 4 | amount_per_litre=40 5 | distance_one_way=190 6 | per_head_cost=0 7 | divisible_by_five=False 8 | 9 | #Start writing your code from here 10 | #Populate the variables: per_head_cost and divisible_by_five 11 | total_distance=distance_one_way*2 12 | petrol = (total_distance/mileage)*amount_per_litre 13 | per_head_cost = petrol/4 14 | if per_head_cost%5==0: 15 | divisible_by_five=True 16 | #Do not modify the below print statements for verification to work 17 | print(per_head_cost) 18 | print(divisible_by_five) 19 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 7/PF-Assgn-46.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python function, nearest_palindrome() which accepts a number and returns the nearest palindrome greater than the given number. 3 | ''' 4 | 5 | #PF-Assgn-46 6 | 7 | def nearest_palindrome(number): 8 | #start writitng your code here 9 | number=number+1 10 | for i in range(number,number+1000): 11 | sum=0 12 | temp=i 13 | while(i>0): 14 | rem=i%10 15 | sum=sum*10+rem 16 | i=i//10 17 | if sum==temp: 18 | return temp 19 | break 20 | number=111 21 | print(nearest_palindrome(number)) 22 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Assgn-17.py: -------------------------------------------------------------------------------- 1 | #PF-Tryout 2 | 3 | def find_new_salary(current_salary,job_level): 4 | # write your logic here 5 | if(job_level==3): 6 | new_salary=current_salary+((current_salary*15)/100) 7 | elif(job_level==4): 8 | new_salary=current_salary+((current_salary*7)/100) 9 | elif job_level==5: 10 | new_salary=current_salary+((current_salary*5)/100) 11 | else: 12 | new_salary=current_salary 13 | return new_salary 14 | 15 | # provide different values for current_salary and job_level and test yor program 16 | new_salary=find_new_salary(15000,3) 17 | print(new_salary) 18 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 5/PF-Assgn-36.py: -------------------------------------------------------------------------------- 1 | '''Write a python function, create_largest_number(), which accepts a list of numbers and returns the largest number possible by concatenating 2 | the list of numbers. 3 | Note: Assume that all the numbers are two digit numbers. 4 | ''' 5 | 6 | #PF-Assgn-36 7 | def create_largest_number(number_list): 8 | l=[] 9 | for i in range (0,len(number_list)): 10 | m=max(number_list) 11 | l.insert(i,str(m)) 12 | number_list.remove(m) 13 | s=int("".join(l)) 14 | return s 15 | number_list=[23,94,55] 16 | largest_number=create_largest_number(number_list) 17 | print(largest_number) 18 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 9/PF-Assgn-59.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-59 2 | def check_perfect_number(number): 3 | 4 | num=[] 5 | for i in range(1,number): 6 | if number%i==0: 7 | num.append(i) 8 | total=sum(num) 9 | if number==total and number!=0: 10 | return True 11 | else: 12 | return False 13 | def check_perfectno_from_list(no_list): 14 | perfect=[] 15 | for i in no_list: 16 | result=check_perfect_number(i) 17 | if result: 18 | perfect.append(i) 19 | return perfect 20 | 21 | 22 | perfectno_list=check_perfectno_from_list([87, 76, 567, 99, 0]) 23 | print(perfectno_list) 24 | -------------------------------------------------------------------------------- /DBMS/Day 6/Exercise 61: -------------------------------------------------------------------------------- 1 | Step 1: Find the minimum quantity (which will be a single row) 2 | SELECT MIN(SUM(QUANTITY)) FROM SALEDETAIL GROUP BY PRODID) 3 | 4 | Step 2: Find the product Ids that have minimum quantity: 5 | SELECT PRODID FROM SALEDETAIL GROUP BY PRODID HAVING SUM(QUANTITY) = (SELECT MIN(SUM(QUANTITY)) FROM SALEDETAIL GROUP BY PRODID) 6 | 7 | Step 3: Using the prod ids fetched in the previous step, 8 | relate these prod ids with the prod ids from the product table 9 | and display the description: 10 | SELECT PRODID, PDESC FROM PRODUCT WHERE PRODID IN (SELECT PRODID FROM SALEDETAIL GROUP BY PRODID HAVING SUM(QUANTITY) = (SELECT MIN(SUM(QUANTITY)) FROM SALEDETAIL GROUP BY PRODID)) 11 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 8/PF-Exer-38.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python lambda expression for the following: 3 | 4 | 1. Find the modulo of two numbers and add it to the difference of the same two numbers. 5 | 2. Find the square root of a number using math library built-in function. 6 | 3. Find the square root of a number without using built-in function. 7 | ''' 8 | 9 | #PF-Exer-38 10 | #This verification is based on string match. 11 | import math 12 | num1=36 13 | num2=7 14 | num3=18 15 | 16 | calc = lambda x,y:(x%y + x-y) 17 | print(calc(num1,num2)) 18 | 19 | square_root = lambda x:math.sqrt(x) 20 | print(square_root(num3)) 21 | 22 | square_root2= lambda x:x**(1/2) 23 | print(square_root2(num3)) 24 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 3/PF-Assgn-22.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a Python program to generate the next 15 leap years starting from a given year. Populate the leap years into a list and display the 3 | list. 4 | ''' 5 | 6 | #PF-Assgn-22 7 | def find_leap_years(given_year): 8 | 9 | # Write your logic here 10 | list_of_leap_years=[] 11 | leap =[] 12 | for i in range(given_year,given_year+64): 13 | if i%400==0 and i%100!=0: 14 | leap.append(i) 15 | elif i%4==0 and i%100!=0: 16 | leap.append(i) 17 | list_of_leap_years=leap[:15] 18 | return list_of_leap_years 19 | 20 | 21 | list_of_leap_years=find_leap_years(2002) 22 | print(list_of_leap_years) 23 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 6/PF-Assgn-44.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python function find_duplicates(), which accepts a list of numbers and returns another list containing all the duplicate values in 3 | the input list. If there are no duplicate values, it should return an empty list. 4 | 5 | ''' 6 | 7 | #PF-Assgn-44 8 | 9 | def find_duplicates(list_of_numbers): 10 | #start writing your code here 11 | temp=[] 12 | for i in list_of_numbers: 13 | if list_of_numbers.count(i)>1: 14 | if i not in temp: 15 | temp.append(i) 16 | return temp 17 | 18 | list_of_numbers=[1,2,2,3,3,3,4,4,4,4] 19 | list_of_duplicates=find_duplicates(list_of_numbers) 20 | print(list_of_duplicates) 21 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 8/PF-Exer-39.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python lambda expression for calculating simple interest. 3 | If simple interest is greater than 1000, display as “Platinum Member”, otherwise “Gold Member”. 4 | 5 | Use the below formula to calculate the simple interest. 6 | simple_interest=(principal_amount*duration in years*rate_of_interest)/100 7 | ''' 8 | 9 | #PF-Exer-39 10 | #This verification is based on string match. 11 | 12 | principal_amount=4000 13 | duration=12 14 | rate_of_interest=13 15 | 16 | simple_interest =lambda x,y,z:(x*y*z)/100 17 | 18 | if(simple_interest(principal_amount,duration,rate_of_interest)>1000): 19 | print("Platinum Member") 20 | else: 21 | print("Gold Member") 22 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 6/PF-Assgn-40.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a recursive function, is_palindrome() to find out whether a string is a palindrome or not. The function should return true, if it is 3 | a palindrome. Else it should return false. 4 | 5 | Note- Perform case insensitive operations wherever necessary. 6 | ''' 7 | 8 | #PF-Assgn-40 9 | def is_palindrome(word): 10 | word.lower() 11 | if word[::-1].lower()==word.lower(): 12 | return True 13 | else: 14 | return False 15 | 16 | #Provide different values for word and test your program 17 | result=is_palindrome("Mam") 18 | if(result): 19 | print("The given word is a Palindrome") 20 | else: 21 | print("The given word is not a Palindrome") 22 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 4/PF-Exer-22.py: -------------------------------------------------------------------------------- 1 | #PF-Exer-22 2 | 3 | def generate_ticket(airline,source,destination,no_of_passengers): 4 | ticket_number_list=[] 5 | #Write your logic here 6 | num=101 7 | src=source[:3] 8 | dest=destination[:3] 9 | for i in range(0,no_of_passengers): 10 | ticket_number_list.append(airline+":"+src+":"+dest+":"+str(num)) 11 | num=num+1 12 | #Use the below return statement wherever applicable 13 | if len(ticket_number_list)>4: 14 | ticket_number_list=ticket_number_list[-5:] 15 | return ticket_number_list 16 | 17 | #Provide different values for airline,source,destination,no_of_passengers and test your program 18 | print(generate_ticket("AI","Bangalore","London",7)) 19 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 4/PF-Assgn-31.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a function, check_palindrome() to check whether the given string is a palindrome or not. The function should return true if it is a palindrome else it should return false. 3 | 4 | Note: Initialize the string with various values and test your program. Assume that all the letters in the given string are all of the same case. Example: MAN, civic, WOW etc. 5 | ''' 6 | 7 | #PF-Assgn-31 8 | def check_palindrome(word): 9 | #Remove pass and write your logic here 10 | if word[::-1]==word: 11 | return True 12 | else: 13 | return False 14 | status=check_palindrome("mom") 15 | if(status): 16 | print("word is palindrome") 17 | else: 18 | print("word is not palindrome") 19 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 103: -------------------------------------------------------------------------------- 1 | Identify purchase bills in which -> Lets assign PURCHASEBILL 'P' table to the outer query 2 | the bill amount is less than or equal to -> P.BILLAMOUNT<= 3 | the average bill amount -> AVG(P1.billamount) (lets assign PURCHASEBILL 'P1' to the inner query) 4 | of all the items -> GROUP BY () 5 | purchased in the same retail outlet. -> P1.ROID=P.ROID (The ROID which refers to the outer query must be the same as the inner query) 6 | and GROUP BY function must group item prices as per ROID 7 | 8 | Display billid and itemcode for the same. 9 | 10 | SELECT P.BILLID, P.ITEMCODE 11 | FROM PURCHASEBILL P 12 | WHERE P.BILLAMOUNT<= 13 | ( 14 | SELECT AVG(P1.BILLAMOUNT) 15 | FROM PURCHASEBILL P1 16 | WHERE P1.ROID=P.ROID 17 | GROUP BY ROID 18 | ) 19 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 6/PF-Assgn-43.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python function find_smallest_number() which accepts a number n and returns the smallest number having n divisors. 3 | Handle the possible errors in the code written inside the function. 4 | ''' 5 | 6 | #PF-Assgn-43 7 | 8 | def find_smallest_number(num): 9 | #start writing your code here 10 | for i in range(1,num*10): 11 | #count=0 12 | l=[] 13 | for j in range(1,i+1): 14 | if i%j==0: 15 | l.append(j) 16 | #count+=1 17 | if len(l)==num: 18 | return i 19 | 20 | num=16 21 | print("The number of divisors :",num) 22 | result=find_smallest_number(num) 23 | print("The smallest number having",num," divisors:",result) 24 | -------------------------------------------------------------------------------- /DataStructures and Algorithms using Python/Day 1/DSA-Exer-1.py: -------------------------------------------------------------------------------- 1 | #DSA-Exer-1 2 | 3 | def update_mark_list(mark_list, new_element, pos): 4 | #Write your logic here 5 | mark_list.insert(pos,new_element) 6 | return mark_list 7 | 8 | def find_mark(mark_list,pos1,pos2): 9 | '''Remove pass and write your logic here to return a list containing 10 | the marks at pos1 and pos2 respectively.''' 11 | m_list=[] 12 | m_list.append(mark_list[pos1]) 13 | m_list.append(mark_list[pos2]) 14 | return m_list 15 | 16 | #Provide different values for the variables and test your program 17 | mark_list=[89,78,99,76,77,72,88,99] 18 | new_element=69 19 | pos=2 20 | pos1=5 21 | pos2=8 22 | print(update_mark_list(mark_list, new_element, pos)) 23 | print(find_mark(mark_list, pos1, pos2)) 24 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Assgn-16.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-16 2 | def make_amount(rupees_to_make,no_of_five,no_of_one): 3 | five_needed=0 4 | one_needed=0 5 | five_needed = int(rupees_to_make/5) 6 | one_needed = rupees_to_make%5 7 | if five_needed <= no_of_five and one_needed <= no_of_one: 8 | print("No. of Five needed :", five_needed) 9 | print("No. of One needed :", one_needed) 10 | elif five_needed > no_of_five: 11 | total = no_of_five*5 12 | one_needed = rupees_to_make - total 13 | if one_needed <= no_of_one: 14 | print("No. of Five needed :", no_of_five) 15 | print("No. of One needed :", one_needed) 16 | else: 17 | print(-1) 18 | else: 19 | print(-1) 20 | 21 | make_amount(30,4,5) 22 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 79: -------------------------------------------------------------------------------- 1 | Step 1: Fetch Locations, customer types and quantity 2 | SELECT R1.LOCATION, C.CUSTTYPE, P.QUANTITY 3 | FROM RETAILOUTLET R1, PURCHASEBILL P, CUSTOMER C 4 | WHERE R1.ROID=P.ROID AND C.CUSTID=P.CUSTID 5 | 6 | Step 2: Group data together as per location and customer type 7 | SELECT R1.LOCATION, C.CUSTTYPE, SUM(P.QUANTITY) 8 | FROM RETAILOUTLET R1, PURCHASEBILL P, CUSTOMER C 9 | WHERE R1.ROID=P.ROID AND C.CUSTID=P.CUSTID 10 | GROUP BY R1.LOCATION, C.CUSTTYPE 11 | 12 | Step 3: Apply Filters 13 | SELECT R1.LOCATION, C.CUSTTYPE, SUM(P.QUANTITY) TOTALQUANTITY 14 | FROM RETAILOUTLET R1, PURCHASEBILL P, CUSTOMER C, ITEM I 15 | WHERE R1.ROID=P.ROID 16 | AND C.CUSTID=P.CUSTID 17 | AND I.ITEMCODE=P.ITEMCODE 18 | AND C.GENDER='M' 19 | AND I.ITEMTYPE IN ('Apparels','Computer') 20 | GROUP BY R1.LOCATION, C.CUSTTYPE 21 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Exer-11.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python program that displays a message as follows for a given number: 3 | a. If it is a multiple of three, display "Zip" 4 | b. If it is a multiple of five, display "Zap". 5 | c. If it is a multiple of both three and five, display "Zoom". 6 | d. If it does not satisfy any of the above given conditions, display "Invalid". 7 | ''' 8 | 9 | #PF-Exer-11 10 | def display(num): 11 | message="" 12 | #write your logic here 13 | if(num%3==0 and num%5==0): 14 | message="zoom" 15 | elif(num%5==0): 16 | message="zap" 17 | elif(num%3==0): 18 | message="zip" 19 | else: 20 | message="Invalid" 21 | return message 22 | 23 | #Provide different values for num and test your program 24 | message=display(9) 25 | print(message) 26 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 5/PF-Assgn-38.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python function, check_double(number) which accepts a whole number and returns True if it satisfies the given conditions. 3 | 4 | 1. The number and its double should have exactly the same number of digits. 5 | 2. Both the numbers should have the same digits ,but in different order. 6 | Otherwise it should return False. 7 | 8 | Example: If the number is 125874 and its double, 251748, contain exactly the same digits, but in a different order. 9 | ''' 10 | 11 | #PF-Assgn-38 12 | 13 | def check_double(number): 14 | double=2*number 15 | s1="".join(str(number)) 16 | s2="".join(str(double)) 17 | s3=sorted(s1) 18 | s4=sorted(s2) 19 | if s3==s4: 20 | return True 21 | else: 22 | return False 23 | 24 | print(check_double(106)) 25 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 7/PF-Exer-34.py: -------------------------------------------------------------------------------- 1 | ''' 2 | We have ‘N’ flavors of toppings that can be added to a coffee. For example chocolate, hazelnut, vanilla, Irish and so on. 3 | 4 | Write a function that takes the number of available flavors as input and returns the total number of different ways we can have our coffee. 5 | Note that we can have coffee without any toppings or with different combination of toppings. 6 | ''' 7 | 8 | 9 | #PF-Exer-34 10 | 11 | def find_number_of_combination(number_of_flavours): 12 | total_combination=0 13 | #write your logic here 14 | total_combination=2**number_of_flavours 15 | return total_combination 16 | 17 | 18 | #Provide different values for number_of_flavours and test your program 19 | number_of_combination=find_number_of_combination(4) 20 | print(number_of_combination) 21 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 7/PF-Assgn-49.py: -------------------------------------------------------------------------------- 1 | ''' 2 | In a fair coin we have an equal chance (50%) of either getting a ‘head’ or ‘tail’. That is if we toss the coin a large number of times 3 | we would observe head approximately 50% of the time. Write a program to implement a biased coin toss where the chance of getting a head 4 | is 70% (and tail 30%). That is if we invoke the program 1000 times we should see the head randomly approximately 700 times. 5 | ''' 6 | 7 | #PF-Tryout 8 | #Start writing your code here 9 | import random 10 | 11 | def biased_flip(prob_true): 12 | return random.random() SELECT Q1.SNAME (Outer query : QUOTATION Q1) 4 | the quotation for an item --> 5 | with the quoted price, less than --> Q1.QUOTEDPRICE< 6 | the maximum quoted price submitted by all other suppliers, 7 | --> MAX(Q2.QUOTEDPRICE)(inner query: QUOTATION Q2) 8 | GROUP BY(Q2.ITEMCODE) 9 | for the same item. --> Q2.ITEMCODE = Q1.ITEMCODE 10 | 11 | Display sname, itemcode and item description for the identified supplier. 12 | Do not display duplicate records. --> USe DISTINCT 13 | 14 | 15 | SELECT DISTINCT Q1.SNAME, Q1.ITEMCODE, I.DESCR 16 | FROM QUOTATION Q1, ITEM I 17 | WHERE Q1.ITEMCODE=I.ITEMCODE 18 | AND Q1.QUOTEDPRICE< 19 | ( 20 | SELECT MAX(Q2.QUOTEDPRICE) 21 | FROM QUOTATION Q2 22 | WHERE Q2.ITEMCODE=Q1.ITEMCODE 23 | AND Q2.SNAME<>Q1.SNAME 24 | GROUP BY (Q2.ITEMCODE) 25 | ) 26 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Exer-7.py: -------------------------------------------------------------------------------- 1 | #PF-Exer-7 2 | 3 | def calculate_total_ticket_cost(no_of_adults, no_of_children): 4 | total_ticket_cost=0 5 | #Write your logic here 6 | adult=37550 7 | child=adult/3 8 | service_ad = (adult*7)/100 9 | service_ch = (child*7)/100 10 | ticket_cost_ad=adult + service_ad 11 | ticket_cost_ch=child + service_ch 12 | final_cost_ad = ticket_cost_ad-((ticket_cost_ad*10)/100) 13 | final_cost_ch = ticket_cost_ch-((ticket_cost_ch*10)/100) 14 | cost_ad = no_of_adults*final_cost_ad 15 | cost_ch = no_of_children*final_cost_ch 16 | total_ticket_cost=cost_ch+cost_ad 17 | return total_ticket_cost 18 | 19 | 20 | #Provide different values for no_of_adults, no_of_children and test your program 21 | total_ticket_cost=calculate_total_ticket_cost(3,1) 22 | print("Total Ticket Cost:",total_ticket_cost) 23 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 106: -------------------------------------------------------------------------------- 1 | Display the customer id and customer name of those customers --> SELECT C.CUSTID, C.CUSTNAME FROM CUSTOMER C 2 | who have not purchased at all -> NOT EXISTS 3 | from any retail outlet. 4 | --> Here we need to have some reference to the retail outlet. 5 | Hence we use the tables Customer and PurchaseBill 6 | to identify which customers have purchased an item from a retail outlet. 7 | Hence, we get 8 | 9 | ___________________________________ 10 | METHOD-1: 11 | SELECT C.CUSTID, C.CUSTNAME 12 | FROM CUSTOMER C 13 | WHERE NOT EXISTS 14 | ( 15 | SELECT CUSTID 16 | FROM PURCHASEBILL P 17 | WHERE C.CUSTID=P.CUSTID 18 | ) 19 | ___________________________________ 20 | METHOD-2: 21 | SELECT C.CUSTID, C.CUSTNAME 22 | FROM CUSTOMER C 23 | WHERE C.CUSTID NOT IN 24 | ( 25 | SELECT CUSTID 26 | FROM PURCHASEBILL P 27 | WHERE C.CUSTID=P.CUSTID 28 | ) 29 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 6/PF-Exer-30.py: -------------------------------------------------------------------------------- 1 | ''' 2 | The python function, find_average() given below, is written to accept a list of marks and return the average marks. On execution, the 3 | program is resulting in an error. 4 | 5 | 1: Add code to handle the exception occurring in the code. 6 | 7 | 2: Make the necessary correction in the program to remove the error. 8 | 9 | 3: Make the following changes in the code, execute, observe the results. Add code to handle the errors occurring in each case. 10 | 11 | ''' 12 | 13 | #PF-Exer-30 14 | 15 | def find_average(mark_list): 16 | try: 17 | total=0 18 | for i in range(0, len(mark_list)): 19 | total+=mark_list[i] 20 | marks_avg=total/len(mark_list) 21 | return marks_avg 22 | except: 23 | print("some error occur") 24 | m_list=[1,2,3,4] 25 | print("Average marks:", find_average(m_list)) 26 | -------------------------------------------------------------------------------- /DBMS/Day 5/Assignment 80: -------------------------------------------------------------------------------- 1 | Important: Given -> all items of type 'FMCG' 2 | For this, we will fetch all the items belonging to type 'FMCG' and apply left outer join. 3 | SELECT I.ITEMCODE, I.DESCR, P.BILLAMOUNT 4 | FROM ITEM I LEFT OUTER JOIN PURCHASEBILL P 5 | ON I.ITEMCODE=P.ITEMCODE 6 | WHERE ITEMTYPE='FMCG' 7 | 8 | Final Query: 9 | SELECT I.ITEMCODE, I.DESCR, NVL(P.BILLAMOUNT,0) BILLAMOUNT, NVL(C.CUSTID,0) CUSTID 10 | FROM ITEM I LEFT OUTER JOIN PURCHASEBILL P 11 | ON I.ITEMCODE=P.ITEMCODE 12 | LEFT OUTER JOIN CUSTOMER C 13 | ON C.CUSTID=P.CUSTID 14 | WHERE ITEMTYPE='FMCG' 15 | 16 | NOTE: 17 | This query gives partial output: 18 | SELECT I.ITEMCODE, I.DESCR, NVL(P.BILLAMOUNT,0) BILLAMOUNT, NVL(C.CUSTID,0) CUSTID 19 | FROM ITEM I, PURCHASEBILL P, CUSTOMER C 20 | WHERE I.ITEMCODE=P.ITEMCODE 21 | AND C.CUSTID=P.CUSTID 22 | AND ITEMTYPE='FMCG' 23 | 24 | The above query doesnot map the itemcodes with NULL values. 25 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 4/PF-Assgn-30.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Given a string containing uppercase characters (A-Z), compress the string using Run Length encoding. Repetition of character has to be replaced by storing the length of that run. 3 | 4 | Write a python function which performs the run length encoding for a given String and returns the run length encoded String. 5 | ''' 6 | 7 | #PF-Assgn-30 8 | 9 | def encode(message): 10 | st=message+"0" 11 | l=[] 12 | count=1 13 | #Remove pass and write your logic here 14 | for i in range(0,len(st)-1): 15 | if st[i]==st[i+1]: 16 | count=count+1 17 | else: 18 | l.append(str(count)) 19 | l.append(st[i]) 20 | count=1 21 | s="".join(l) 22 | return s 23 | #Provide different values for message and test your program 24 | encoded_message=encode("ABBBBCCCCCCCCAB") 25 | print(encoded_message) 26 | -------------------------------------------------------------------------------- /OOP in Python/Day 4/OOPR-Exer-12.py: -------------------------------------------------------------------------------- 1 | #OOPR-Exer-12 2 | #Start writing your code here 3 | 4 | class Rider: 5 | def __init__(self,trained_status,experience): 6 | self.__trained_status=trained_status 7 | self.__experience=experience 8 | 9 | def rides_vehicle(self): 10 | print("Rider rides vehicle") 11 | 12 | 13 | class BikeRider(Rider): 14 | def __init__(self,trained_status,experience,race_license): 15 | super().__init__(trained_status,experience) 16 | self.__race_license=race_license 17 | 18 | def rides_in_dome(self): 19 | print("Bike Rider rides in dome") 20 | 21 | class CycleRider(Rider): 22 | def rides_blindfolded(self): 23 | print("Cycle rider rides blind folded") 24 | 25 | 26 | c=CycleRider(True,10) 27 | c.rides_vehicle() 28 | c.rides_blindfolded() 29 | b=BikeRider(True,20,False) 30 | b.rides_in_dome() 31 | -------------------------------------------------------------------------------- /OOP in Python/Day 2/OOPR-Exer-6.py: -------------------------------------------------------------------------------- 1 | #OOPR-Exer-6 2 | #Start writing your code here 3 | 4 | class Vehicle: 5 | def __init__(self): 6 | self.fuel_left=None 7 | self.mileage=None 8 | self.initial_fuel=10 9 | 10 | def identify_distance_that_can_be_travelled(self): 11 | if self.fuel_left>5: 12 | self.fuel=self.fuel_left-5 13 | self.distance=self.fuel*self.mileage 14 | return self.distance 15 | else: 16 | return 0 17 | 18 | def identify_distance_travelled(self,initial_fuel): 19 | self.initial_fuel=initial_fuel 20 | self.fuel=self.initial_fuel-self.fuel_left 21 | self.distance=self.fuel*self.mileage 22 | return self.distance 23 | 24 | v1=Vehicle() 25 | v1.mileage=50 26 | v1.fuel_left=7 27 | print(v1.identify_distance_that_can_be_travelled()) 28 | print(v1.identify_distance_travelled(20)) 29 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Assgn-18.py: -------------------------------------------------------------------------------- 1 | #PF-Tryout 2 | 3 | def convert_currency(amount_needed_inr,current_currency_name): 4 | current_currency_amount=0 5 | #write your logic here 6 | if current_currency_name=="Euro": 7 | current_currency_amount=amount_needed_inr*0.01417 8 | elif current_currency_name=="British Pound": 9 | current_currency_amount=amount_needed_inr*0.0100 10 | elif current_currency_name=="Australian Dollar": 11 | current_currency_amount=amount_needed_inr*0.02140 12 | elif current_currency_name=="Canadian Dollar": 13 | current_currency_amount=amount_needed_inr*0.02027 14 | return current_currency_amount 15 | 16 | 17 | #Provide different values for amount_needed_inr,current_currency_name and test your program 18 | currency_needed=convert_currency(3500,"British Pound") 19 | if(currency_needed!= -1): 20 | print(currency_needed ) 21 | else: 22 | print("Invalid currency name") 23 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 4/PF-Assgn-33.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python program to display all the common characters between two strings. Return -1 if there are no matching characters. 3 | 4 | Note: Ignore blank spaces if there are any. Perform case sensitive string comparison wherever necessary. 5 | 6 | ''' 7 | 8 | 9 | #PF-Assgn-33 10 | 11 | def find_common_characters(msg1,msg2): 12 | #Remove pass and write your logic here 13 | msg11=msg1.replace(" ","") 14 | msg21=msg2.replace(" ","") 15 | l=[] 16 | s=[] 17 | for i in msg11: 18 | if i in msg21: 19 | l.append(i) 20 | for x in l: 21 | if x not in s: 22 | s.append(x) 23 | if len(s)>0: 24 | return "".join(s) 25 | else: 26 | return -1 27 | #Provide different values for msg1,msg2 and test your program 28 | msg1="moto" 29 | msg2="moto" 30 | common_characters=find_common_characters(msg1,msg2) 31 | print(common_characters) 32 | -------------------------------------------------------------------------------- /OOP in Python/Day 2/OOPR-Assgn-10.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-10 2 | 3 | class CallDetail: 4 | def __init__(self,phoneno,called_no,duration,call_type): 5 | self.__phoneno=phoneno 6 | self.__called_no=called_no 7 | self.__duration=duration 8 | self.__call_type=call_type 9 | 10 | 11 | 12 | class Util: 13 | def __init__(self): 14 | self.list_of_call_objects=None 15 | 16 | def parse_customer(self,list_of_call_string): 17 | self.list_of_call_objects=[] 18 | for each_call in list_of_call_string: 19 | call_detail_list=each_call.split(",") 20 | a=CallDetail(call_detail_list[0],call_detail_list[1],call_detail_list[2],call_detail_list[3]) 21 | self.list_of_call_objects.append(a) 22 | 23 | call='9990000001,9330000001,23,STD' 24 | call2='9990000001,9330000002,54,Local' 25 | call3='9990000001,9330000003,6,ISD' 26 | 27 | list_of_call_string=[call,call2,call3] 28 | Util().parse_customer(list_of_call_string) 29 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 7/PF-Exer-35.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python program which displays the count of the names that matches a given pattern from a list of names provided. 3 | 4 | Consider the pattern characters to be: 5 | 6 | 1. "_ at" where "_" can be one occurrence of any character 7 | 8 | 2. "%at%" where "%" can have zero or any number of occurrences of a character 9 | 10 | ''' 11 | 12 | #PF-Exer-35 13 | 14 | def count_names(name_list): 15 | count1=0 16 | count2=0 17 | 18 | #start writing your code here 19 | #Populate the variables: count1 and count2 20 | for i in name_list: 21 | if len(i)==3: 22 | if i.find("at")==1: 23 | count1=count1+1 24 | if i.find("at")>=0: 25 | count2=count2+1 26 | print("_at -> ",count1) 27 | print("%at% -> ",count2) 28 | 29 | 30 | #Provide different names in the list and test your program 31 | name_list=["Hat","Cat","rabbit","matter"] 32 | count_names(name_list) 33 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 3/PF-Assgn-24.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python function to check whether three given numbers can form the sides of a triangle. 3 | Hint : Three numbers can be the sides of a triangle if none of the numbers are greater than or equal to the sum of the other two numbers. 4 | ''' 5 | 6 | #PF-Assgn-24 7 | def form_triangle(num1,num2,num3): 8 | #Do not change the messages provided below 9 | success="Triangle can be formed" 10 | failure="Triangle can't be formed" 11 | a = num1+num2 12 | b = num1+num3 13 | c = num3+num2 14 | #Write your logic here 15 | if a>num3 and b>num2 and c>num1: 16 | return success 17 | else: 18 | return failure 19 | #Use the following messages to return the result wherever necessary 20 | #return success 21 | #return failure 22 | 23 | #Provide different values for the variables, num1, num2, num3 and test your program 24 | num1=8 25 | num2=5 26 | num3=15 27 | print(form_triangle(num1, num2, num3)) 28 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 3/PF-Assgn-27.py: -------------------------------------------------------------------------------- 1 | import turtle # allows us to use the turtles library 2 | wn = turtle.Screen() # creates a graphics window 3 | wn.setup(500,500) # set window dimension 4 | 5 | alex = turtle.Turtle() # create a turtle named alex 6 | alex.shape("turtle") # alex looks like a turtle 7 | 8 | ''' 9 | alex.color("black") # alex has a color 10 | alex.right(60) # alex turns 60 degrees right 11 | alex.left(60) # alex turns 60 degrees left 12 | alex.circle(50) # draws a circle of radius 50 13 | #draws circles 14 | for counter in range(1,3): 15 | alex.circle(20*counter) 16 | ''' 17 | l=["green","red","blue"] 18 | alex.color("green") 19 | for i in l: 20 | alex.color(i) 21 | alex.circle(20) 22 | for counter in range(10,40,10): 23 | alex.circle(20+counter) 24 | alex.right(120) 25 | alex.right(120) 26 | 27 | #Write the logic to create the given pattern 28 | #Refer the statements given above to draw the pattern 29 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 8/PF-Assgn-54.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python function, check_anagram() which accepts two strings and returns True, if one string is an anagram of another string. 3 | Otherwise returns False. 4 | 5 | The two strings are considered to be an anagram if they contain repeating characters but none of the characters repeat at the same position. 6 | The length of the strings should be the same. 7 | ''' 8 | 9 | #PF-Assgn-54 10 | def check_anagram(data1,data2): 11 | #start writing your code here 12 | l1=[] 13 | l2=[] 14 | for i in data1.lower(): 15 | l1.append(i) 16 | for i in data2.lower(): 17 | l2.append(i) 18 | c=0 19 | if len(data1)==len(data2): 20 | for i in range(0,len(data1)): 21 | if l1[i] in l2 and l1[i]!=l2[i]: 22 | c=c+1 23 | else: 24 | return False 25 | if len(data1)==c: 26 | return True 27 | else: 28 | return False 29 | 30 | print(check_anagram("About","table")) 31 | -------------------------------------------------------------------------------- /OOP in Python/Day 2/OOPR-Assgn-12.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-12 2 | #Start writing your code here 3 | 4 | 5 | class Bill: 6 | def __init__(self,bill_id,patient_name): 7 | self.__bill_id=bill_id 8 | self.__patient_name=patient_name 9 | self.__bill_amount=0 10 | 11 | def get_bill_id(self): 12 | return self.__bill_id 13 | 14 | def get_patient_name(self): 15 | return self.__patient_name 16 | 17 | def get_bill_amount(self): 18 | return self.__bill_amount 19 | 20 | def calculate_bill_amount(self, consultation_fees, quantity_list,price_list): 21 | for i in range(len(quantity_list)): 22 | self.__bill_amount+= (quantity_list[i]*price_list[i]) 23 | 24 | self.__bill_amount+=consultation_fees 25 | 26 | print(self.__bill_id) 27 | print(self.__patient_name) 28 | print(self.__bill_amount) 29 | 30 | b=Bill(1,'Sudarshan') 31 | b.calculate_bill_amount(200,[2,4,6],[100,100,500]) 32 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 4/PF-Assgn-29.py: -------------------------------------------------------------------------------- 1 | ''' 2 | The road transport corporation (RTC) of a city wants to know whether a particular bus-route is running on profit or loss. 3 | 4 | Assume that the following information are given: 5 | Price per litre of fuel = 70 6 | Mileage of the bus in km/litre of fuel = 10 7 | Price(Rs) per ticket = 80 8 | 9 | The bus runs on multiple routes having different distance in kms and number of passengers. 10 | Write a function to calculate and return the profit earned (Rs) in each route. Return -1 in case of loss. 11 | ''' 12 | 13 | #PF-Assgn-29 14 | def calculate(distance,no_of_passengers): 15 | ticket=no_of_passengers*80 16 | mile=(distance)/10 17 | fuel=mile*70 18 | earning=ticket-fuel 19 | if earning>0: 20 | return earning 21 | else: 22 | return -1 23 | 24 | #Remove pass and write your logic here 25 | 26 | 27 | 28 | #Provide different values for distance, no_of_passenger and test your program 29 | distance=20 30 | no_of_passengers=50 31 | print(calculate(distance,no_of_passengers)) 32 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Assgn-19.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-19 2 | 3 | def calculate_bill_amount(food_type,quantity_ordered,distance_in_kms): 4 | bill_amount=0 5 | amt=0 6 | #write your logic here 7 | if quantity_ordered>0 and distance_in_kms>0 : 8 | if food_type == "n" or food_type == "v": 9 | return -1 10 | if food_type =="N": 11 | amt=150 12 | elif food_type=="V": 13 | amt=120 14 | bill_amt=amt*quantity_ordered 15 | if distance_in_kms<4: 16 | dist_amt=0 17 | bill_amount=bill_amt 18 | elif 3<=distance_in_kms<=6: 19 | dist_amt=(distance_in_kms-3)*3 20 | bill_amount=bill_amt+dist_amt 21 | else: 22 | dist_amt1=((distance_in_kms-6)*6)+9 23 | bill_amount=bill_amt+dist_amt1 24 | else: 25 | bill_amount=-1 26 | return bill_amount 27 | 28 | #Provide different values for food_type,quantity_ordered,distance_in_kms and test your program 29 | bill_amount=calculate_bill_amount("v",2,8) 30 | print(bill_amount) 31 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 7/PF-Assgn-50.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write python function, sms_encoding() which accepts a sentence and converts it into an abbreviated sentence to be sent as SMS and returns 3 | the abbreviated sentence. 4 | 5 | Rules are as follows: 6 | a. Spaces are to be retained as is 7 | b. Each word should be encoded separately 8 | 1. If a word has only vowels then retain the word as is 9 | ` 2. If a word has a consonant (at least 1) then retain only those consonants 10 | 11 | Note: Assume that the sentence would begin with a word and there will be only a single space between the words 12 | ''' 13 | 14 | #PF-Assgn-50 15 | vowels=["a","e","i","o","u","A","E","I","O","U"] 16 | def sms_encoding(data): 17 | #start writing your code here 18 | word=data.split() 19 | l=[] 20 | for i in word: 21 | temp=[] 22 | v=[] 23 | for value in i: 24 | if value not in vowels: 25 | temp.append(value) 26 | if len(temp)==0: 27 | temp.append(i) 28 | l.append("".join(temp)) 29 | return " ".join(l) 30 | 31 | 32 | data="I will not repeat mistakes" 33 | print(sms_encoding(data)) 34 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 3/PF-Assgn-26.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python program to solve a classic ancient Chinese puzzle. 3 | 4 | We count 35 heads and 94 legs among the chickens and rabbits in a farm. How many rabbits and how many chickens do we have? 5 | ''' 6 | 7 | 8 | #PF-Assgn-26 9 | 10 | def solve(heads,legs): 11 | error_msg="No solution" 12 | chicken_count=0 13 | rabbit_count=0 14 | 15 | #Start writing your code here 16 | #Populate the variables: chicken_count and rabbit_count 17 | if heads==(legs//2): 18 | chicken_count=heads 19 | elif heads==(legs//4): 20 | rabbit_count=heads 21 | elif legs%2==0: 22 | rabbit_count=(legs//2)-heads 23 | chicken_count=heads-rabbit_count 24 | else: 25 | print(error_msg) 26 | 27 | # Use the below given print statements to display the output 28 | # Also, do not modify them for verification to work 29 | if chicken_count>0 or rabbit_count>0: 30 | if chicken_count<=heads and rabbit_count<=heads: 31 | print(chicken_count,rabbit_count) 32 | else: 33 | print(error_msg) 34 | 35 | #Provide different values for heads and legs and test your program 36 | #solve(38,131) 37 | solve(20,10) 38 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 3/PF-Assgn-28.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python program which finds the maximum number from num1 to num2 (num2 inclusive) based on the following rules. 3 | 4 | 1. Always num1 should be less than num2 5 | 2. Consider each number from num1 to num2 (num2 inclusive). Populate the number into a list, if the below conditions are satisfied 6 | a. Sum of the digits of the number is a multiple of 3 7 | b. Number has only two digits 8 | c. Number is a multiple of 5 9 | 3. Display the maximum element from the list 10 | In case of any invalid data or if the list is empty, display -1. 11 | ''' 12 | 13 | 14 | 15 | #PF-Assgn-28 16 | 17 | def find_max(num1, num2): 18 | max_num=-1 19 | 20 | l=[max_num] 21 | # Write your logic here 22 | if num1t2: 23 | #print("Team1") 24 | return "Team1" 25 | elif t2>t1: 26 | return "Team2" 27 | else: 28 | return "Tie" 29 | #Invoke the function with each of the print statements given below 30 | print(find_winner_of_the_day("Team1","Team2","Team2","Team1","Team2")) 31 | #print(find_winner_of_the_day("Team1","Team2","Team1","Team2")) 32 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 6/PF-Exer-32.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Consider that the human tower is to be performed on a stage and the stage has a maximum weight limit. 3 | 4 | Write a python program to find the maximum number of people at the base level such that the total weight of tower does not exceed the 5 | maximum weight limit of the stage. 6 | 7 | Assume that: 8 | 1. Each person weighs 50 kg 9 | 2. There will always be odd number of men at the base level of the human tower. 10 | ''' 11 | 12 | #PF-Exer-32 13 | 14 | def human_pyramid(no_of_people): 15 | if no_of_people==1: 16 | return 50 17 | else: 18 | return no_of_people*50+human_pyramid(no_of_people-2) 19 | def find_maximum_people(max_weight): 20 | no_of_people=0 21 | sum=0 22 | l=[] 23 | weight=max_weight//50 24 | if weight%2==0: 25 | weight=weight-1 26 | for i in range(1,weight+1,2): 27 | res=human_pyramid(i) 28 | if res>max_weight: 29 | no_of_people=i-2 30 | break 31 | if res==max_weight: 32 | no_of_people=i 33 | return no_of_people 34 | 35 | #Provide different values for max_weight and test your program 36 | max_people=find_maximum_people(1250) 37 | print(max_people) 38 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 4/PF-Exer-23.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Represent a small bilingual (English-Swedish) glossary given below as a Python dictionary 3 | 4 | {"merry":"god", "christmas":"jul", "and":"och", "happy":"gott", "new":"nytt", "year":"ar"} 5 | 6 | and use it to translate your Christmas wishes from English into Swedish. 7 | 8 | That is, write a python function translate() that accepts the bilingual dictionary and a list of English words (your Christmas wish) and returns a list of equivalent Swedish words. 9 | ''' 10 | 11 | #PF-Exer-23 12 | def translate(bilingual_dict,english_words_list): 13 | #Write your logic here 14 | swedish_words_list=[] 15 | for key in english_words_list: 16 | for k in bilingual_dict: 17 | if key==k: 18 | swedish_words_list.append(bilingual_dict[key]) 19 | return swedish_words_list 20 | 21 | 22 | bilingual_dict= {"merry":"god", "christmas":"jul", "and":"och", "happy":"gott", "new":"nytt", "year":"ar"} 23 | english_words_list=["merry","christmas"] 24 | print("The bilingual dict is:",bilingual_dict) 25 | print("The english words are:",english_words_list) 26 | 27 | swedish_words_list=translate(bilingual_dict, english_words_list) 28 | print("The equivalent swedish words are:",swedish_words_list) 29 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Exer-10.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | wn = turtle.Screen() # creates a graphics window 3 | wn.setup(540,508) # set window dimension 4 | 5 | alex = turtle.Turtle() # create a turtle named alex 6 | alex.shape("turtle") # alex looks like a turtle 7 | alex.color("blue") # alex has a color 8 | 9 | ''' 10 | alex.backward(50) # alex moves 50 positions backward 11 | alex.forward(50) # alex moves 50 positions forward 12 | alex.right(60) # alex turns 60 degrees right 13 | alex.left(60) # alex turns 60 degrees left 14 | alex.write("Hello") # alex says "Hello" 15 | ''' 16 | destination = input() 17 | #Write the logic to take the turtle to its destination 18 | #Refer the statements given above to draw the pattern 19 | if(destination == "south") : 20 | alex.right(90) 21 | alex.forward(250) 22 | 23 | elif(destination =="north"): 24 | alex.left(90) 25 | alex.forward(250) 26 | elif(destination =="west"): 27 | alex.right(180) 28 | alex.forward(265) 29 | elif(destination =="east"): 30 | alex.forward(195) 31 | else: 32 | alex.write("Looks like you have typed wrong destination") 33 | #Provide different values and test your program 34 | destination="south" 35 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 9/PF-Assgn-57.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-57 2 | def check_prime(number): 3 | factor = 2 4 | while factor * factor <= int(number): 5 | if int(number) % factor == 0: 6 | return False 7 | factor+=1 8 | return True 9 | 10 | def rotations(num): 11 | answer = [] 12 | final=[] 13 | rotation = str(num) 14 | while not rotation in answer: 15 | answer.append(rotation) 16 | rotation = rotation[1:] + rotation[0] 17 | for i in answer: 18 | final.append(int(i)) 19 | return final 20 | 21 | 22 | def get_circular_prime_count(limit): 23 | all_circulations = [2] 24 | ret = [] 25 | for num in range(3, limit, 2): 26 | if check_prime(num): 27 | check = 0 28 | if rotations(num): 29 | circulations = rotations(num) 30 | for circulation in circulations: 31 | if not check_prime(circulation): 32 | check += 1 33 | if not check: 34 | all_circulations.extend(circulations) 35 | final = sorted(list(set(all_circulations))) 36 | for i in final: 37 | if i<=limit: 38 | ret.append(i) 39 | return len(ret) 40 | 41 | print(get_circular_prime_count(20)) 42 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 8/PF-Assgn-53.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Assume that a poem is given. Write the regular expressions for the following: 3 | 1. Print how many times the letter 'v' appears in the poem. 4 | 2. Remove all the newlines from the poem and print the poem in a single line. 5 | 3. If a word has 'ch' or 'co', replace it with 'Ch' or 'Co'. 6 | 4. If the pattern has characters 'ai' or 'hi', replace the next three characters with *\*. 7 | ''' 8 | 9 | #PF-Assgn-53 10 | #This verification is based on string match. 11 | 12 | poem=''' 13 | It takes strength for being certain, 14 | It takes courage to have doubt. 15 | It takes strength for challenging alone, 16 | It takes courage to lean on another. 17 | It takes strength for loving other souls, 18 | It takes courage to be loved. 19 | It takes strength for hiding our own pain, 20 | It takes courage to help if it is paining for someone.''' 21 | 22 | #Note: Triple quotes can be used to enclose Strings which has lines of text. 23 | import re 24 | #Write your logic here for question 1 25 | count=0 26 | for i in poem: 27 | if i == "v": 28 | count=count+1 29 | print(count) 30 | print() 31 | print(re.sub(r"\n",r" ",poem)) 32 | 33 | #print() 34 | print(re.sub(r"ch",r"Ch",re.sub(r"co",r"Co",poem))) 35 | 36 | #print() 37 | print(re.sub(r"ai...",r"ai*/*",re.sub(r"hi...",r"hi*/*",poem))) 38 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 5/PF-Exer-26.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a Python function to find all the Strong numbers in a given list of numbers. 3 | Write another function to find and return the factorial of a number. Use it to solve the problem. 4 | 5 | Example: 6 | A number is considered to be a Strong number if sum of the factorial of its digits is equal to the number itself. 7 | 145 is a Strong number as 1! + 4! + 5! = 145. 8 | ''' 9 | 10 | #PF-Exer-26 11 | def factorial(number): 12 | #remove pass and write your logic to find and return the factorial of given number 13 | if number==0 or number==1: 14 | fact=1 15 | else: 16 | fact=number*factorial(number-1) 17 | return fact 18 | def find_strong_numbers(num_list): 19 | #remove pass and write your logic to find and return the list of strong numbers from the given list 20 | l=[] 21 | for i in num_list: 22 | temp=i 23 | if i==0: 24 | temp=1 25 | sum=0 26 | while(temp): 27 | rem=temp%10 28 | sum=sum+factorial(rem) 29 | temp=temp//10 30 | if sum==i: 31 | l.append(i) 32 | else: 33 | pass 34 | return l 35 | num_list=[145,375,100,2,10,40585,0] 36 | strong_num_list=find_strong_numbers(num_list) 37 | print(strong_num_list) 38 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 8/PF-Exer-41.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a higher order function, sum_all() to calculate the sum of elements in a list. 3 | sum_all() – It accepts a list and calculates the sum of the elements in the list based on the conditions being checked in the lambda expressions passed to it. 4 | Only those values satisfying the condition should be included in the sum. 5 | 6 | Write the following lambda expressions. 7 | 1. greater: To check whether a given number is greater than 10. 8 | 2. divide: To check whether a given number is divisible by 10 and not greater than 100. 9 | 3. range_of_values: To check whether a given number is between 25 and 50 (Both inclusive). 10 | ''' 11 | 12 | #PF-Exer-41 13 | #This verification is based on string match. 14 | 15 | def sum_all(function, data): 16 | sum=0 17 | for i in data: 18 | if (function(i)): 19 | sum=sum+i 20 | return sum 21 | 22 | 23 | list_of_nos=[100,200,300,500,1040] 24 | 25 | greater = lambda x:x>10 26 | 27 | divide = lambda x:x%10==0 and x<=100 28 | 29 | range_of_values = lambda x:x in range(25,51) 30 | 31 | 32 | #Use the below given print statements to display the output 33 | # Also, do not modify them for verification to work 34 | print(sum_all(greater,list_of_nos)) 35 | print(sum_all(divide,list_of_nos)) 36 | print(sum_all(range_of_values,list_of_nos)) 37 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Assgn-19.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-19 2 | #Start writing your code here 3 | destination_list=["Mumbai","Pune","Chennai","Kolkata"] 4 | 5 | class Ticket: 6 | counter=0 7 | 8 | def __init__(self,passenger_name,source,destination): 9 | self.__passenger_name=passenger_name 10 | self.__source=source 11 | self.__destination=destination 12 | self.__ticket_id=None #Ticket.counter+1 13 | 14 | def validate_source_destination(self): 15 | if self.__source.title()=="Delhi": 16 | if self.__destination.title() in destination_list: 17 | return True 18 | return False 19 | 20 | def generate_ticket(self): 21 | Ticket.counter += 1 22 | if self.validate_source_destination(): 23 | if Ticket.counter<10: 24 | self.__ticket_id=self.__source[0]+self.__destination[0]+"0"+str(Ticket.counter) 25 | else: 26 | self.__ticket_id=self.__source[0]+self.__destination[0]+str(Ticket.counter) 27 | 28 | def get_ticket_id(self): 29 | return self.__ticket_id 30 | 31 | def get_passenger_name(self): 32 | return self.__passenger_name 33 | 34 | def get_source(self): 35 | return self.__source 36 | 37 | def get_destination(self): 38 | return self.__destination 39 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 7/PF-Assgn-47.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python function, encrypt_sentence() which accepts a message and encrypts it based on rules given below and returns the encrypted 3 | message. 4 | Words at odd position -> Reverse It 5 | Words at even position -> Rearrange the characters so that all consonants appear before the vowels and their order should not change 6 | 7 | Note: 8 | 9 | 1. Assume that the sentence would begin with a word and there will be only a single space between the words. 10 | 2. Perform case sensitive string operations wherever necessary. 11 | ''' 12 | 13 | #PF-Assgn-47 14 | def encrypt_sentence(sentence): 15 | #start writing your code here 16 | sentence=sentence.split(" ") 17 | l=[] 18 | v=["a","e","i","o","u","A","E","I","O","U"] 19 | for index,value in enumerate(sentence): 20 | # print(value) 21 | if index%2==0: 22 | s=value[::-1] 23 | l.insert(index,s) 24 | else: 25 | c=[] 26 | for i in value: 27 | if i not in v: 28 | c.append(i) 29 | for j in value: 30 | if j in v: 31 | c.append(j) 32 | d="".join(c) 33 | l.insert(index,d) 34 | return l 35 | 36 | sentence="The sun rises in the east" 37 | encrypted_sentence=encrypt_sentence(sentence) 38 | print(encrypted_sentence) 39 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 6/PF-Assgn-41.py: -------------------------------------------------------------------------------- 1 | ''' 2 | A 10-substring of a number is a substring of its digits that sum up to 10. 3 | 4 | For example, the 10-substrings of the number 3523014 are: 5 | 3523014, 3523014, 3523014, 3523014 6 | 7 | Write a python function, find_ten_substring(num_str) which accepts a string and returns the list of 10-substrings of that string. 8 | 9 | Handle the possible errors in the code written inside the function. 10 | ''' 11 | 12 | #PF-Assgn-41 13 | def find_ten_substring(num_str): 14 | final=[] 15 | temp=[] 16 | for index,value in enumerate(list(num_str)): 17 | l=[] 18 | temp=[] 19 | for i in range(index,len(num_str)): 20 | l.append(int(num_str[i])) 21 | s=sum(l) 22 | if s < 10: 23 | continue 24 | elif s==10: 25 | for value in l: 26 | temp.append(str(value)) 27 | sum_string = "".join(temp) 28 | final.append(sum_string) 29 | if i!=(len(num_str)-1): 30 | if num_str[i+1]=='0': 31 | temp=[] 32 | continue 33 | break 34 | elif s>10: 35 | break 36 | return final 37 | num_str="2825302" 38 | print("The number is:",num_str) 39 | result_list=find_ten_substring(num_str) 40 | print(result_list) 41 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 8/PF-Assgn-52.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Consider sample data as follows: sample_data=range(1,11) 3 | 4 | 5 | Create two functions: odd() and even() 6 | The function even() returns a list of all the even numbers from sample_data 7 | The function odd() returns a list of all the odd numbers from sample_data 8 | 9 | 10 | Create a function sum_of_numbers() which will accept the sample data and/or a function. 11 | If a function is not passed, the sum_of_numbers() should return the sum of all the numbers from sample_data 12 | If a function is passed, the sum_of_numbers() should return the sum of numbers returned from the function passed. 13 | ''' 14 | 15 | #PF-Assgn-52 16 | 17 | #This verification is based on string match. 18 | 19 | def sum_of_numbers(list_of_num,filter_func=None): 20 | num_sum=0 21 | if filter_func!=None: 22 | num_sum=sum(filter_func(list_of_num)) 23 | else: 24 | num_sum=sum(list_of_num) 25 | return num_sum 26 | 27 | def even(data): 28 | even_no=[] 29 | for num in data: 30 | if num%2==0: 31 | even_no.append(num) 32 | return even_no 33 | def odd(data): 34 | odd_no=[] 35 | for num in data: 36 | if num%2!=0: 37 | odd_no.append(num) 38 | return odd_no 39 | sample_data = range(1,11) 40 | 41 | #print(sum_of_numbers(sample_data,odd)) 42 | print(sum_of_numbers(sample_data,even)) 43 | #print(sum_of_numbers(sample_data,None)) 44 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Assgn-20.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-20 2 | #Start writing your code here 3 | 4 | class Applicant: 5 | __application_dict={"A":0,"B":0,"C":0} 6 | __applicant_id_count=1000 7 | 8 | def __init__(self,applicant_name): 9 | self.__applicant_name=applicant_name 10 | self.__applicant_id=None 11 | self.__job_band=None 12 | 13 | def generate_applicant_id(self): 14 | Applicant.__applicant_id_count+=1 15 | self.__applicant_id = Applicant.__applicant_id_count 16 | 17 | 18 | def apply_for_job(self,job_band): 19 | if Applicant.__application_dict[job_band]==5: 20 | return -1 21 | else: 22 | Applicant.__application_dict[job_band]+=1 23 | self.generate_applicant_id() 24 | self.__job_band=job_band 25 | 26 | @staticmethod 27 | def get_application_dict(): 28 | return Applicant.application_dict() 29 | 30 | def get_applicant_id(self): 31 | return self.__applicant_id 32 | 33 | def get_applicant_name(self): 34 | return self.__applicant_name 35 | 36 | def get_job_band(self): 37 | return self.__job_band 38 | 39 | 40 | 41 | a=Applicant("Jack") 42 | a.apply_for_job("C") 43 | a.apply_for_job("C") 44 | a.apply_for_job("C") 45 | a.apply_for_job("C") 46 | print(a.apply_for_job("C")) 47 | print(a.get_applicant_id()) 48 | #job_band-Aapplicant_name-Jack(Method invoked 5 times) 49 | -------------------------------------------------------------------------------- /DBMS/Day 6/Assignment 95: -------------------------------------------------------------------------------- 1 | The management would like to know the details of the items 2 | which has maximum quoted price 3 | amongst the quotations that have status as 'Closed' or 'Rejected'. 4 | 5 | Display itemcode and descr of those items. 6 | 7 | Filter Closed and Rejected Quotations. 8 | SELECT * FROM QUOTATION WHERE QSTATUS IN ('Rejected','Closed') 9 | 10 | Find maximum price of those quotations. 11 | SELECT MAX(QUOTEDPRICE) MAXI FROM QUOTATION WHERE QSTATUS IN ('Rejected','Closed') 12 | 13 | Fetch the itemcode of the quoation. 14 | SELECT ITEMCODE FROM QUOTATION WHERE QUOTEDPRICE= (SELECT MAX(QUOTEDPRICE) MAXI FROM QUOTATION WHERE QSTATUS IN ('Rejected','Closed')) 15 | 16 | Display the details of the fetched item. 17 | SELECT ITEMCODE, DESCR FROM ITEM WHERE ITEMCODE IN (SELECT DISTINCT ITEMCODE FROM QUOTATION WHERE QUOTEDPRICE = (SELECT MAX(QUOTEDPRICE) MAXI FROM QUOTATION WHERE QSTATUS IN ('Rejected','Closed'))) 18 | 19 | However, the following query doesnt show logical error: 20 | 21 | SELECT ITEMCODE, DESCR FROM ITEM WHERE ITEMCODE IN 22 | ( 23 | SELECT DISTINCT ITEMCODE FROM QUOTATION WHERE QUOTEDPRICE = 24 | ( 25 | SELECT MAX(QUOTEDPRICE) FROM QUOTATION WHERE QSTATUS IN ('Rejected','Closed') 26 | ) 27 | AND QSTATUS IN ('Rejected','Closed') 28 | ) 29 | It is important that we also filter the 2nd inner query because max(price) from rejected and closed quotations 30 | can also be the price for Accepted Quotation. Hence care must be taken that the quoation belongs only 31 | and only to rejected and closed quotations. 32 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 9/PF-Assgn-61.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-61 2 | import re 3 | def validate_name(name): 4 | #Start writing your code here 5 | if 0=0 and self.__marks<=100: 13 | return True 14 | else: 15 | return False 16 | 17 | def validate_age(self): 18 | if self.__age>20: 19 | return True 20 | else: 21 | return False 22 | 23 | def check_qualification(self): 24 | if self.validate_marks() and self.validate_age(): 25 | if self.__marks>=65: 26 | return True 27 | return False 28 | 29 | def set_student_id(self): 30 | global Student_id_counter 31 | self.__student_id=Student_id_counter 32 | Student_id_counter=Student_id_counter+1 33 | 34 | def get_student_id(self): 35 | return self.__student_id 36 | 37 | def set_marks(self,marks): 38 | self.__marks=marks 39 | 40 | def get_marks(self): 41 | return self.__marks 42 | 43 | def set_age(self,age): 44 | self.__age=age 45 | 46 | def get_age(self): 47 | return self.__age 48 | 49 | 50 | s1=Student() 51 | s1.set_student_id() 52 | #print(s1.get_student_id()) 53 | s1.set_age(21) 54 | #print(s1.get_student_age()) 55 | s1.set_marks(65) 56 | #print(s1.get_student_marks()) 57 | print(s1.check_qualification()) 58 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 5/PF-Assgn-35.py: -------------------------------------------------------------------------------- 1 | ''' 2 | A teacher is in the process of generating few reports based on the marks scored by the students of her class in a project based assessment. 3 | Assume that the marks of her 10 students are available in a tuple. The marks are out of 25. 4 | 5 | 6 | Write a python program to implement the following functions: 7 | 8 | 1. find_more_than_average(): Find and return the percentage of students who have scored more than the average mark of the class. 9 | 2. generate_frequency(): Find how many students have scored the same marks. For example, how many have scored 0, how many have scored 1, 10 | how many have scored 3….how many have scored 25. The result should be populated in a list and returned. 11 | 3. sort_marks(): Sort the marks in the increasing order from 0 to 25. The sorted values should be populated in a list and returned. 12 | ''' 13 | 14 | #PF-Assgn-35 15 | 16 | #Global variable 17 | list_of_marks=(12,18,25,24,2,5,18,20,20,21) 18 | 19 | def find_more_than_average(): 20 | sum=0 21 | count=0 22 | for i in list_of_marks: 23 | sum+=i 24 | avg=sum/len(list_of_marks) 25 | for i in list_of_marks: 26 | if i>avg: 27 | count+=1 28 | per=(count*100)/len(list_of_marks) 29 | return per 30 | def sort_marks(): 31 | sorted_marks=sorted(list_of_marks) 32 | return sorted_marks 33 | def generate_frequency(): 34 | l=[] 35 | for i in range(0,26): 36 | l.append(list_of_marks.count(i)) 37 | return l 38 | 39 | print(find_more_than_average()) 40 | print(generate_frequency()) 41 | print(sort_marks()) 42 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 4/PF-Assgn-32.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Care hospital wants to know the medical speciality visited by the maximum number of patients. Assume that the patient id of the patient along with the medical speciality visited by the patient is stored in a list. The details of the medical specialities are stored in a dictionary as follows: 3 | { 4 | "P":"Pediatrics", 5 | "O":"Orthopedics", 6 | "E":"ENT 7 | } 8 | 9 | Write a function to find the medical speciality visited by the maximum number of patients and return the name of the speciality. 10 | Also write the pytest test cases to test the program. 11 | 12 | Note: 13 | 1. Assume that there is always only one medical speciality which is visited by maximum number of patients. 14 | ` 2. Perform case sensitive string comparison wherever necessary. 15 | ''' 16 | 17 | 18 | #PF-Assgn-32 19 | def max_visited_speciality(patient_medical_speciality_list,medical_speciality): 20 | # write your logic here 21 | l=[] 22 | for i in range(0,len(patient_medical_speciality_list),2): 23 | l.append(patient_medical_speciality_list[i]) 24 | i1=patient_medical_speciality_list.index(max(l)) 25 | for k,v in medical_speciality.items(): 26 | if k==patient_medical_speciality_list[i1+1]: 27 | speciality=v 28 | return speciality 29 | 30 | #provide different values in the list and test your program 31 | patient_medical_speciality_list=[101,"O",102,"E",302,"P",305,"P",401,"E",656,"O",987,"E"] 32 | medical_speciality={"P":"Pediatrics","O":"Orthopedics","E":"ENT"} 33 | speciality=max_visited_speciality(patient_medical_speciality_list,medical_speciality) 34 | print(speciality) 35 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 9/PF-Assgn-58.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-58 2 | #***************************************************** 3 | #copy this code in solution class in eclipse 4 | #***************************************************** 5 | def validate_credit_card_number(card_number): 6 | #start writing your code here 7 | card=str(card_number) 8 | l=[] 9 | if len(card)==16: 10 | for i in card[-2::-2]: 11 | n=int(i)*2 12 | if n>9: 13 | n1=n%10+n//10 14 | l.append(n1) 15 | else: 16 | l.append(n) 17 | return (sum(l)+sum(list(map(int,card[-1::-2]))))%10==0 18 | else: 19 | return False 20 | 21 | card_number= 5239512608615007 22 | result=validate_credit_card_number(card_number) 23 | if(result): 24 | print("credit card number is valid") 25 | else: 26 | print("credit card number is invalid") 27 | 28 | 29 | #***************************************************************** 30 | #copy this code in eclipse test class and execute it. 31 | #***************************************************************** 32 | import pytest 33 | from src.solution import validate_credit_card_number 34 | 35 | def test_card_1(): 36 | result=validate_credit_card_number(1456734512345698) 37 | assert result== False 38 | 39 | def test_card_2(): 40 | result=validate_credit_card_number(4539869650133101) 41 | assert result== True 42 | 43 | def test_card_3(): 44 | result=validate_credit_card_number(1456734512345698) 45 | assert result==False 46 | 47 | def test_card_4(): 48 | result=validate_credit_card_number(5239512608615007) 49 | assert result== True 50 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 7/PF-Assgn-48.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python function, find_correct() which accepts a dictionary and returns a list as per the rules mentioned below. 3 | The input dictionary will contain correct spelling of a word as key and the spelling provided by a contestant as the value. 4 | 5 | The function should identify the degree of correctness as mentioned below: 6 | CORRECT, if it is an exact match 7 | ALMOST CORRECT, if no more than 2 letters are wrong 8 | WRONG, if more than 2 letters are wrong or if length (correct spelling versus spelling given by contestant) mismatches. 9 | 10 | and return a list containing the number of CORRECT answers, number of ALMOST CORRECT answers and number of WRONG answers. 11 | Assume that the words contain only uppercase letters and the maximum word length is 10. 12 | ''' 13 | 14 | #PF-Assgn-48 15 | 16 | def find_correct(word_dict): 17 | #start writing your code here 18 | correct,almost,wrong=0,0,0 19 | for key,value in word_dict.items(): 20 | if key==value: 21 | correct=correct+1 22 | else: 23 | if len(key)!=len(value): 24 | wrong=wrong+1 25 | continue 26 | incorrect=0 27 | for i in range(min([len(key),len(value)])): 28 | if key[i]!=value[i]: 29 | incorrect=incorrect+1 30 | if incorrect>2: 31 | wrong=wrong+1 32 | break 33 | if 0 SELECT S.SID, S.SNAME, S.LOCATION 2 | of those salesmen -> FROM SALESMAN S WHERE S.SID IN () 3 | who have total sales amount -> SUM(individual salesamount) 4 | greater than -> '>' 5 | average total sales amount -> SUM(individual-salesamount)/SUM(total-quantity) 6 | of their location -> location-wise 'GROUP BY location' 7 | calculated per salesman. 8 | 9 | SELECT PRODID FROM PRODUCT P, SALEDETAIL S1, SALE S2 WHERE SUM(individual salesamount)>SUM(individual-salesamount)/SUM(total-quantity) 10 | 11 | _____________________________________________________________________ 12 | SELECT SM.SID, SNAME, LOCATION FROM SALESMAN SM 13 | INNER JOIN SALE S ON S.SID = SM.SID GROUP BY SM.SID, SNAME, LOCATION 14 | HAVING Sum(AMOUNT)> 15 | (SELECT MIN(SUM(AMOUNT)) FROM SALE SI INNER JOIN SALESMAN SMI 16 | ON SI.SID = SMI.SID GROUP BY SI.SID) + 2000; 17 | _____________________________________________________________________ 18 | SELECT SM.SID, SNAME FROM SALESMAN SM 19 | INNER JOIN SALE S ON S.SID = SM.SID 20 | WHERE LOCATION = 'London' 21 | GROUP BY SM.SID, SNAME 22 | HAVING SUM(AMOUNT) < 23 | (SELECT AVG(SUM(AMOUNT)) FROM SALE GROUP BY SID); 24 | ___ _____ _____ _____ _______ _______ _______ ____ 25 | Calculates the average amount of sales done based on each salesman's total sale amount. 26 | Displays SID and SNAME of salesmen whose total amount of sale is lesser than the average 27 | amount of sale calculated and who belongs to city 'London'. 28 | 29 | _______ 30 | Step 1: Select every in 31 | SELECT S.SID, SUM((S1.Quantity*P.PRICE)*((100-P.DISCOUNT)/100)) Totalquantity FROM SALE S,SALEDETAIL S1, PRODUCT P WHERE S1.SALEID=S.SALEID AND S1.PRODID=P.PRODID GROUP BY S.SID ORDER BY S.SID 32 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Exer-7.py: -------------------------------------------------------------------------------- 1 | #OOPR-Exer-7 2 | #Start writing your code here 3 | 4 | class Ticket: 5 | counter=0 6 | 7 | def __init__(self,passenger_name,source,destination): 8 | self.__passenger_name=passenger_name 9 | self.__source=source 10 | self.__destination=destination 11 | self.__ticket_id=None 12 | 13 | def validate_source_destination(self): 14 | dest=['Mumbai','Pune','Chennai','Kolkata'] 15 | if self.__source.lower()=="delhi": 16 | if self.__destination.title() in dest: 17 | return True 18 | else: 19 | return False 20 | else: 21 | return False 22 | 23 | 24 | def generate_ticket(self): 25 | Ticket.counter +=1 26 | if self.validate_source_destination(): 27 | if Ticket.counter<10: 28 | self.__ticket_id=self.__source[0]+self.__destination[0]+'0'+str(Ticket.counter) 29 | else: 30 | self.__ticket_id=self.__source[0]+self.__destination[0]+str(Ticket.counter) 31 | 32 | def get_ticket_id(self): 33 | return self.__ticket_id 34 | 35 | def get_passenger_name(self): 36 | return self.__passenger_name 37 | 38 | def get_source(self): 39 | return self.__source 40 | 41 | def get_destination(self): 42 | return self.__destination 43 | 44 | 45 | t=Ticket("Sudarshan","Delhi","Mumbai") 46 | Ticket.counter=9 47 | t.generate_ticket() 48 | print(t.get_ticket_id()) 49 | print(t.get_passenger_name()) 50 | print(t.get_source()) 51 | print(t.get_destination()) 52 | t.generate_ticket() 53 | print(t.get_ticket_id()) 54 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Assgn-21.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-21 2 | class Patient: 3 | def __init__(self,patient_id,patient_name,list_of_lab_test_ids): 4 | self.__patient_id=patient_id 5 | self.__patient_name=patient_name 6 | self.__list_of_lab_test_ids=list_of_lab_test_ids 7 | self.__lab_test_charge=0 8 | def get_patient_id(self): 9 | return self.__patient_id 10 | def get_patient_name(self): 11 | return self.__patient_name 12 | def get_list_of_lab_test_ids(self): 13 | return self.__list_of_lab_test_ids 14 | def get_lab_test_charge(self): 15 | return self.__lab_test_charge 16 | def calculate_lab_test_charge(self): 17 | for test in self.__list_of_lab_test_ids: 18 | if LabTestRepository.get_test_charge(test)>0: 19 | self.__lab_test_charge += LabTestRepository.get_test_charge(test) 20 | 21 | 22 | class LabTestRepository: 23 | __list_of_hospital_lab_test_ids=["L101","L102","L103","L104"] 24 | __list_of_lab_test_charge=[2020,1750.50,5700,1320.50] 25 | @staticmethod 26 | def get_test_charge(lab_test_id): 27 | if lab_test_id in LabTestRepository.__list_of_hospital_lab_test_ids: 28 | I1=LabTestRepository.__list_of_hospital_lab_test_ids.index(lab_test_id) 29 | return LabTestRepository.__list_of_lab_test_charge[I1] 30 | else: 31 | return -1 32 | 33 | lab_test_list1=["L104"] 34 | patient1=Patient(1010,"Sam",lab_test_list1) 35 | patient1.calculate_lab_test_charge() 36 | print("Patient id:",patient1.get_patient_id(),"\nPatient name:",patient1.get_patient_name(),"\nPatient's test ids:",patient1.get_list_of_lab_test_ids(), "\nTotal lab test charge:",patient1.get_lab_test_charge()) 37 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 5/PF-Assgn-37.py: -------------------------------------------------------------------------------- 1 | ''' 2 | A teacher is conducting a camp for a group of five children. Based on their performance and behavior during the camp, the teacher rewards 3 | them with chocolates. 4 | 5 | Write a Python function to 6 | 7 | 1. Find the total number of chocolates received by all the children put together. 8 | Assume that each child is identified by an id and it is stored in a tuple and the number of chocolates given to each child is stored in a 9 | list. 10 | 2. The teacher also rewards a child with few extra chocolates for his/her best conduct during the camp. 11 | a. If the number of extra chocolates is less than 1, an error message "Extra chocolates is less than 1", should be displayed. 12 | b. If the given child Id is invalid, an error message "Child id is invalid" should be displayed. Otherwise, the extra chocolates provided for 13 | the child must be added to his/her existing number of chocolates and display the list containing the total number of chocolates received by 14 | each child. 15 | ''' 16 | 17 | 18 | #PF-Assgn-37 19 | 20 | #Global variables 21 | child_id=(10,20,30,40,50) 22 | chocolates_received=[12,5,3,4,6] 23 | 24 | def calculate_total_chocolates(): 25 | return sum(chocolates_received) 26 | def reward_child(child_id_rewarded,extra_chocolates): 27 | if extra_chocolates<1: 28 | print("Extra chocolates is less than 1") 29 | elif child_id_rewarded not in child_id: 30 | print("Child id is invalid") 31 | else: 32 | i=child_id.index(child_id_rewarded) 33 | ch = chocolates_received[i]+extra_chocolates 34 | chocolates_received[i]=ch 35 | print(chocolates_received) 36 | 37 | 38 | print(calculate_total_chocolates()) 39 | reward_child(20,2) 40 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 5/PF-Exer-27.py: -------------------------------------------------------------------------------- 1 | #PF-Tryout 2 | 3 | account_list=[1001,1002,1003,1004,1005] 4 | balance_list=[2500,10000,7000,1500,500] 5 | amount=1000 6 | account_number=1003 7 | transaction_type="Withdraw" 8 | 9 | flag=None 10 | if(transaction_type=="Withdraw"): 11 | for index in range(0,len(account_list)): 12 | if(account_list[index]==account_number): 13 | flag=True 14 | value=index 15 | if(flag==True): 16 | balance=balance_list[value] 17 | new_balance=balance-amount 18 | if(new_balance >= 500): 19 | balance_list[value]=new_balance 20 | print("Transaction completed successfully") 21 | print("Balance Amount :", new_balance) 22 | else: 23 | print("Insufficient Balance") 24 | else: 25 | print("Invalid Account number") 26 | 27 | elif(transaction_type=="Deposit"): 28 | for index in range(0,len(account_list)): 29 | if(account_list[index]==account_number): 30 | flag=True 31 | value=index 32 | if(flag==True): 33 | balance=balance_list[value] 34 | new_balance=balance+amount 35 | balance_list[value]=new_balance 36 | print("Transaction completed successfully") 37 | print("Balance Amount :", new_balance) 38 | else: 39 | print("Invalid Account number") 40 | elif(transaction_type=="Balance Enquiry"): 41 | for index in range(0,len(account_list)): 42 | if(account_list[index]==account_number): 43 | flag=True 44 | value=index 45 | if(flag==True): 46 | balance=balance_list[value] 47 | print(balance) 48 | else: 49 | print("Invalid Account number") 50 | else: 51 | print("Invalid Transaction Type") 52 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 3/PF-Assgn-23.py: -------------------------------------------------------------------------------- 1 | ''' 2 | ARS Gems Store sells different varieties of gems to its customers. 3 | 4 | Write a Python program to calculate the bill amount to be paid by a customer based on the list of gems and quantity purchased. Any purchase with a total bill amount above Rs.30000 is entitled for 5% discount. If any gem required by the customer is not available in the store, then consider total bill amount to be -1. 5 | 6 | Assume that quantity required by the customer for any gem will always be greater than 0. 7 | 8 | Perform case-sensitive comparison wherever applicable. 9 | ''' 10 | 11 | #PF-Assgn-23https://infytq.infosys.com/fastrack/Generic/PF/page/184#question 12 | def calculate_bill_amount(gems_list, price_list, reqd_gems,reqd_quantity): 13 | bill_amount=0 14 | #Write your logic here 15 | for gem in reqd_gems: 16 | if gem in gems_list: 17 | i1=gems_list.index(gem) 18 | i2=reqd_gems.index(gem) 19 | bill_amount=bill_amount+(reqd_quantity[i2]*price_list[i1]) 20 | if bill_amount>30000: 21 | bill_amount=bill_amount - ((bill_amount*5)/100) 22 | else: 23 | return -1 24 | return bill_amount 25 | 26 | #List of gems available in the store 27 | gems_list=["Emerald","Ivory","Jasper","Ruby","Garnet"] 28 | 29 | #Price of gems available in the store. gems_list and price_list have one-to-one correspondence 30 | price_list=[1760,2119,1599,3920,3999] 31 | 32 | #List of gems required by the customer 33 | reqd_gems=["Ivory","Emed","Garnet"] 34 | 35 | #Quantity of gems required by the customer. reqd_gems and reqd_quantity have one-to-one correspondence 36 | reqd_quantity=[3,10,12] 37 | 38 | bill_amount=calculate_bill_amount(gems_list, price_list, reqd_gems, reqd_quantity) 39 | print(bill_amount) 40 | -------------------------------------------------------------------------------- /OOP in Python/Day 1/OOPR-Assgn-5.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-5 2 | #Start writing your code here 3 | 4 | def check_type(type): 5 | vehicle_type=['Two Wheeler', 'Four Wheeler'] 6 | if type not in vehicle_type: 7 | return 0 8 | return 1 9 | class Vehicle: 10 | def __init__(self): 11 | self.__vehicle_cost=None 12 | self.__vehicle_id=None 13 | self.__vehicle_type=None 14 | self.__premium_amount=None 15 | 16 | def set_vehicle_id(self,vehicle_id): 17 | self.__vehicle_id=vehicle_id 18 | def set_vehicle_type(self,vehicle_type): 19 | if check_type(vehicle_type): 20 | self.__vehicle_type=vehicle_type 21 | else: 22 | return "invalid Vehicle DETAILS" 23 | def set_vehicle_cost(self,vehicle_cost): 24 | self.__vehicle_cost=vehicle_cost 25 | def get_vehicle_id(self): 26 | return self.__vehicle_id 27 | def get_vehicle_type(self): 28 | return self.__vehicle_type 29 | def get_vehicle_cost(self): 30 | return self.__vehicle_cost 31 | def set_premium_amount(self,premium_amount): 32 | self.__premium_amount=premium_amount 33 | def get_premium_amount(self): 34 | return self.__premium_amount 35 | 36 | def calculate_premium(self): 37 | if self.__vehicle_type=="Two Wheeler": 38 | self.__premium_amount=self.__vehicle_cost*2/100 39 | elif self.__vehicle_type=="Four Wheeler": 40 | self.__premium_amount=self.__vehicle_cost*6/100 41 | else: 42 | print("Invalid Vehicle Type") 43 | 44 | def display_vehicle_details(self): 45 | print(self.__premium_amount) 46 | 47 | v1 = Vehicle() 48 | #v1.set_vehicle_id=10 49 | v1.set_vehicle_type("Two Wheeler") 50 | v1.set_vehicle_cost(105000) 51 | v1.calculate_premium() 52 | v1.display_vehicle_details() 53 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 6/PF-Assgn-42.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Given a number n, write a program to find the sum of the largest prime factors of each of nine consecutive numbers starting from n. 3 | g(n) = f(n) + f(n+1) + f(n+2) + f(n+3) + f(n+4) + f(n+5) + f(n+6) + f(n+7) + f(n+8) 4 | where, g(n) is the sum and f(n) is the largest prime factor of n 5 | 6 | For example, 7 | g(10)=f(10)+f(11)+f(12)+f(13)+f(14)+f(15)+f(16)+f(17)+f(18) 8 | =5 + 11 + 3 + 13 + 7 + 5 + 2 + 17 + 3 9 | =66 10 | ''' 11 | #PF-Assgn-42 12 | def find_factors(num): 13 | #Accepts a number and returns the list of all the factors of a given number 14 | factors = [] 15 | for i in range(2,(num+1)): 16 | if(num%i==0): 17 | factors.append(i) 18 | return factors 19 | 20 | def is_prime(num, i): 21 | #Accepts the number num and num/2 --> i and returns True if the number is prime ,else returns False 22 | if(i==1): 23 | return True 24 | elif(num%i==0): 25 | return False; 26 | else: 27 | return(is_prime(num,i-1)) 28 | 29 | def find_largest_prime_factor(list_of_factors): 30 | #Accepts the list of factors and returns the largest prime factor 31 | list_of_factors.sort(reverse=True) 32 | for fact in list_of_factors: 33 | if is_prime(fact,int(fact/2)): 34 | return fact 35 | return 1 36 | def find_f(num): 37 | #Accepts the number and returns the largest prime factor of the number 38 | if is_prime(num,num/2): 39 | return num 40 | else: 41 | l=find_factors(num) 42 | return find_largest_prime_factor(l) 43 | def find_g(num): 44 | #Accepts the number and returns the sum of the largest prime factors of the 9 consecutive numbers starting from the given number 45 | sum=0 46 | for i in range(num,num+9): 47 | sum=sum+find_f(i) 48 | return sum 49 | #Note: Invoke function(s) from other function(s), wherever applicable. 50 | 51 | print(find_g(10)) 52 | -------------------------------------------------------------------------------- /OOP in Python/Day 4/OOPR-Assgn-24.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-24 2 | #Start writing your code here 3 | 4 | class Apparel: 5 | counter=100 6 | def __init__(self,price,item_type): 7 | self.__price=price 8 | self.__item_type=item_type 9 | self.__item_id=None 10 | if self.__item_type=="Cotton": 11 | Apparel.counter+=1 12 | self.__item_id="C"+str(Apparel.counter) 13 | elif self.__item_type=="Silk": 14 | Apparel.counter+=1 15 | self.__item_id="S"+str(Apparel.counter) 16 | 17 | def calculate_price(self): 18 | self.__price=self.__price+self.__price*0.05 19 | 20 | def get_item_id(self): 21 | return self.__item_id 22 | 23 | def get_price(self): 24 | return self.__price 25 | 26 | def get_item_type(self): 27 | return self.__item_type 28 | 29 | def set_price(self,price): 30 | self.__price=price 31 | 32 | 33 | class Cotton(Apparel): 34 | def __init__(self,price,discount): 35 | Apparel.__init__(self,price,"Cotton") 36 | self.__discount=discount 37 | 38 | 39 | def calculate_price(self): 40 | Apparel.calculate_price(self) 41 | price=self.get_price() 42 | price = price - (price*(self.__discount)/100) 43 | price=price+price*0.05 44 | Apparel.set_price(self,price) 45 | 46 | def get_discount(self): 47 | return self.__discount 48 | 49 | class Silk(Apparel): 50 | def __init__(self,price): 51 | Apparel.__init__(self,price,"Silk") 52 | self.__points=0 53 | 54 | 55 | def calculate_price(self): 56 | Apparel.calculate_price(self) 57 | price=self.get_price() 58 | if price>10000: 59 | self.__points=10 60 | else: 61 | self.__points=3 62 | 63 | price = price * 1.10 64 | Apparel.set_price(self,price) 65 | def get_points(self): 66 | return self.__points 67 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 8/PF-Exer-36.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python program to perform the following operations on the given string using the various regular expression functions. 3 | flight_details="Good Evening, Welcome to British Airways. Your flight number is ba8004. Flight departure time is 16:45" 4 | 5 | 1. Find whether the flight service name, British Airways is present in the given string and if so, display it. 6 | 2. Find whether the flight details ends with the departure time, 16:45 and if so, display it. 7 | 3. Find whether the flight details starts with "Good" and if so, display it. 8 | 4. Find a word which starts with 'F' and having 6 characters in it, if so display it. 9 | 5. Search for a word which starts with "ba" followed by exactly 4 digits. If found, replace the two alphabets with the corresponding uppercase 10 | alphabets. 11 | For questions 1 to 4, if the searched pattern is not present, display "No Output" 12 | ''' 13 | 14 | 15 | #PF-Tryout 16 | import re 17 | 18 | flight_details="Good Evening, Welcome to British Airways. Your flight number is ba8004. Flight departure time is 16:45" 19 | 20 | #This function returns the values in the search result 21 | def printout(search_result): 22 | if(search_result!=None): 23 | return search_result.group() 24 | else: 25 | return "No Output" 26 | 27 | search_result = re.search(r"British Airways",flight_details) 28 | #Write your regular expression here for question 1 29 | #This will invoke the printout() and displays the search result values 30 | print(printout(search_result)) 31 | 32 | search_result = re.search(r"16:45$",flight_details) 33 | #Write your regular expression here for question 2 34 | print(printout(search_result)) 35 | 36 | search_result = re.search(r"^Good",flight_details) 37 | #Write your regular expression here for question 3 38 | print(printout(search_result)) 39 | 40 | search_result = re.search(r"F.....",flight_details) 41 | #Write your regular expression here for question 4 42 | print(printout(search_result)) 43 | 44 | print(re.sub(r"ba(\d{4})",r"BA\1",flight_details)) 45 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 8/PF-Assgn-56.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python program that accepts a text and displays a string which contains the word with the largest frequency in the text and the 3 | frequency itself separated by a space. 4 | 5 | Rules: 6 | The word should have the largest frequency. 7 | In case multiple words have the same frequency, then choose the word that has the maximum length. 8 | Assumptions: 9 | The text has no special characters other than space. 10 | The text would begin with a word and there will be only a single space between the words. 11 | Perform case insensitive string comparisons wherever necessary. 12 | ''' 13 | 14 | #PF-Assgn-56 15 | 16 | def max_frequency_word_counter(data): 17 | data=data.lower() 18 | word="" 19 | frequency=0 20 | raw=data.split() 21 | temp=[] 22 | l=[] 23 | cnt=[] 24 | length=[] 25 | for val in raw: 26 | if val not in temp: 27 | temp.append(val) 28 | for i in temp: 29 | c=raw.count(i) 30 | s1=str(i)+" "+str(c) 31 | cnt.append(c) 32 | l.append(s1) 33 | frequency=max(cnt) 34 | if cnt.count(frequency)>1: 35 | for i in range (0,len(cnt)): 36 | if cnt[i]==frequency: 37 | length.append(len(l[i])) 38 | m=max(length) 39 | i1=length.index(m) 40 | word=l[i1] 41 | print(word) 42 | else: 43 | num=str(frequency) 44 | for i in l: 45 | s=i.split() 46 | for val in s: 47 | if num in val: 48 | word=s[0] 49 | print(word,frequency) 50 | #start writing your code here 51 | #Populate the variables: word and frequency 52 | 53 | 54 | # Use the below given print statements to display the output 55 | # Also, do not modify them for verification to work 56 | 57 | 58 | 59 | #Provide different values for data and test your program. 60 | data="Work Like you do not need money, love like you have never been hurt, and dance like no one is watching" 61 | max_frequency_word_counter(data) 62 | -------------------------------------------------------------------------------- /OOP in Python/Day 2/OOPR-Assgn-11.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-11 2 | #Start writing your code here 3 | flower_list=['orchid','rose','jasmine'] 4 | level=[15,25,40] 5 | 6 | class Flower: 7 | def __init__(self): 8 | self.__flower_name=None 9 | self.__price_per_kg=None 10 | self.__stock_available=None 11 | 12 | def validate_flower(self): 13 | #print(self.__flower_name.lower()) 14 | if self.__flower_name.lower() in flower_list: 15 | return True 16 | else: 17 | return False 18 | 19 | def validate_stock(self,required_quantity): 20 | if self.validate_flower(): 21 | if self.__stock_available>=required_quantity: 22 | return True 23 | else: 24 | return False 25 | else: 26 | return False 27 | 28 | def sell_flower(self,required_quantity): 29 | if self.validate_flower() and self.validate_stock(required_quantity): 30 | self.__stock_available=self.__stock_available - required_quantity 31 | 32 | def check_level(self): 33 | if self.validate_flower(): 34 | flower_level=level[flower_list.index(self.__flower_name.lower())] 35 | if self.__stock_available85: 18 | self.__fees=courses[course_id]*0.75 19 | else: 20 | self.__fees=courses[course_id]*1.0 21 | return True 22 | return False 23 | 24 | def get_course_id(self): 25 | return self.__course_id 26 | 27 | def get_fees(self): 28 | return self.__fees 29 | 30 | def validate_marks(self): 31 | if self.__marks>=0 and self.__marks<=100: 32 | return True 33 | else: 34 | return False 35 | 36 | def validate_age(self): 37 | if self.__age>20: 38 | return True 39 | else: 40 | return False 41 | 42 | def check_qualification(self): 43 | if self.validate_marks() and self.validate_age(): 44 | if self.__marks>=65: 45 | return True 46 | return False 47 | 48 | def set_student_id(self,sid): 49 | global Student_id_counter 50 | self.__student_id=sid 51 | #Student_id_counter=Student_id_counter+1 52 | 53 | def get_student_id(self): 54 | return self.__student_id 55 | 56 | def set_marks(self,marks): 57 | self.__marks=marks 58 | 59 | def get_marks(self): 60 | return self.__marks 61 | 62 | def set_age(self,age): 63 | self.__age=age 64 | 65 | def get_age(self): 66 | return self.__age 67 | 68 | maddy=Student() 69 | maddy.set_student_id(1004) 70 | maddy.set_age(21) 71 | maddy.set_marks(65) 72 | if(maddy.check_qualification()): 73 | print("Student has qualified") 74 | if(maddy.choose_course(1002)): 75 | print("Course allocated") 76 | else: 77 | print("Invalid course id") 78 | else: 79 | print("Student has not qualified") 80 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Assgn-17.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-17 2 | #Start writing your code here 3 | 4 | class Customer: 5 | def __init__(self,customer_id,customer_name,address): 6 | self.__customer_id=customer_id 7 | self.__customer_name=customer_name 8 | self.__address=address 9 | 10 | def validate_customer_id(self): 11 | id=str(self.__customer_id) 12 | if len(id)==6: 13 | if id[0]=="1": 14 | return True 15 | return False 16 | 17 | def get_customer_id(self): 18 | return self.__customer_id 19 | 20 | def get_customer_name(self): 21 | return self.__customer_name 22 | 23 | def get_address(self): 24 | return self.__address 25 | 26 | 27 | class Freight: 28 | counter=198 29 | def __init__(self,recipient_customer,from_customer,weight,distance): 30 | self.__recipient_customer=recipient_customer 31 | self.__from_customer=from_customer 32 | self.__weight=weight 33 | self.__distance=distance 34 | self.__freight_id=Freight.counter + 2 35 | self.__freight_charge=None 36 | 37 | def validate_weight(self): 38 | if self.__weight%5==0: 39 | return True 40 | return False 41 | 42 | def validate_distance(self): 43 | if 500<=self.__distance<=5000: 44 | return True 45 | return False 46 | 47 | def forward_cargo(self): 48 | if Customer.validate_customer_id(self.__from_customer) and Customer.validate_customer_id(self.__recipient_customer) and self.validate_distance() and self.validate_weight(): 49 | 50 | Freight.counter += 2 51 | 52 | self.__freight_charge=self.__weight*150 + self.__distance*60 53 | 54 | else: 55 | self.__freight_charge=0 56 | 57 | def get_freight_charge(self): 58 | return self.__freight_charge 59 | 60 | def get_freight_id(self): 61 | return self.__freight_id 62 | 63 | def get_recipient_customer(self): 64 | return self.__recipient_customer 65 | 66 | def get_from_customer(self): 67 | return self.__from_customer 68 | 69 | def get_weight(self): 70 | return self.__distance 71 | 72 | def get_distance(self): 73 | return self.__distance 74 | -------------------------------------------------------------------------------- /OOP in Python/Day 5/OOPR-Exer-13.py: -------------------------------------------------------------------------------- 1 | #OOPR-Exer-13 2 | #Start writing your code here 3 | from abc import ABCMeta, abstractmethod 4 | 5 | class DirectToHomeService (metaclass=ABCMeta): 6 | __counter=101 7 | def __init__(self,consumer_name): 8 | self.__consumer_name=consumer_name 9 | self.__consumer_number=DirectToHomeService.__counter 10 | DirectToHomeService.__counter+=1 11 | 12 | def get_consumer_number(self): 13 | return self.__consumer_number 14 | 15 | def get_consumer_name(self): 16 | return self.__consumer_name 17 | 18 | @abstractmethod 19 | def calculate_monthly_rent(self): 20 | pass 21 | 22 | 23 | class BasePackage(DirectToHomeService): 24 | def __init__(self,consumer_name,base_pack_name,subscription_period): 25 | super().__init__(consumer_name) 26 | self.__base_pack_name=base_pack_name 27 | self.__subscription_period=subscription_period 28 | 29 | def get_base_pack_name(self): 30 | return self.__base_pack_name 31 | 32 | def get_subscription_period(self): 33 | return self.__subscription_period 34 | 35 | def validate_base_pack_name(self): 36 | base_pack=["Silver","Gold","Platinum"] 37 | if self.__base_pack_name in base_pack: 38 | return True 39 | else: 40 | self.__base_pack_name="Silver" 41 | print( "Base package name is incorrect, set to Silver") 42 | 43 | def calculate_monthly_rent(self): 44 | Base_Pack_Name=["Silver","Gold","Platinum"] 45 | Monthly_Rent=[350.00,440.00,560.00] 46 | discount=0 47 | final_rent=0 48 | if 1<=self.__subscription_period<=24: 49 | if self.validate_base_pack_name()==True: 50 | BP_index=Base_Pack_Name.index(self.__base_pack_name) 51 | rent=Monthly_Rent[BP_index] 52 | if self.__subscription_period>12: 53 | discount=rent 54 | final_rent=((rent*self.__subscription_period) - discount)/self.__subscription_period 55 | elif(self.__subscription_period>12): 56 | final_rent=((350*self.__subscription_period) - 350)/self.__subscription_period 57 | else: 58 | final_rent=(350*self.__subscription_period)/self.__subscription_period 59 | return final_rent 60 | else: 61 | return -1 62 | -------------------------------------------------------------------------------- /OOP in Python/Day 5/OOPR-Assgn-29.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-29 2 | #Start writing your code here 3 | from abc import ABCMeta, abstractmethod 4 | 5 | class Customer(metaclass=ABCMeta): 6 | def __init__(self,customer_name): 7 | self.__customer_name=customer_name 8 | self.bill_amount=None 9 | self.bill_id=None 10 | 11 | @abstractmethod 12 | def calculate_bill_amount(self): 13 | pass 14 | 15 | def get_customer_name(self): 16 | return self.__customer_name 17 | 18 | 19 | class OccasionalCustomer(Customer): 20 | __counter=1000 21 | def __init__(self,customer_name,distance_in_kms): 22 | super().__init__(customer_name) 23 | self.__distance_in_kms=distance_in_kms 24 | OccasionalCustomer.__counter+=1 25 | self.bill_id="O"+str(OccasionalCustomer.__counter) 26 | 27 | def validate_distance_in_kms(self): 28 | if 1<=self.__distance_in_kms<=5: 29 | return True 30 | else: 31 | return False 32 | 33 | def calculate_bill_amount(self): 34 | if self.validate_distance_in_kms() == True: 35 | if self.__distance_in_kms<3: 36 | bill=50+self.__distance_in_kms*5 37 | else: 38 | bill=50+self.__distance_in_kms*7.5 39 | 40 | Customer.bill_amount=bill 41 | return Customer.bill_amount 42 | else: 43 | Customer.bill_amount=-1 44 | return Customer.bill_amount 45 | 46 | def get_distance_in_kms(self): 47 | return self.__distance_in_kms 48 | 49 | class RegularCustomer(Customer): 50 | __counter=100 51 | def __init__(self,customer_name,no_of_tiffin): 52 | super().__init__(customer_name) 53 | self.__no_of_tiffin=no_of_tiffin 54 | RegularCustomer.__counter+=1 55 | self.bill_id="R"+str(RegularCustomer.__counter) 56 | 57 | def validate_no_of_tiffin(self): 58 | if 1<=self.__no_of_tiffin<=7: 59 | return True 60 | else: 61 | return False 62 | 63 | def calculate_bill_amount(self): 64 | if self.validate_no_of_tiffin() == True: 65 | bill = 50 * self.__no_of_tiffin * 7 66 | Customer.bill_amount=bill 67 | return Customer.bill_amount 68 | else: 69 | Customer.bill_amount=-1 70 | return Customer.bill_amount 71 | 72 | def get_no_of_tiffin(self): 73 | return self.__no_of_tiffin 74 | -------------------------------------------------------------------------------- /OOP in Python/Day 4/OOPR-Assgn-25.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-25 2 | #Start writing your code here 3 | 4 | class FruitInfo: 5 | __fruit_name_list=['Apple','Guava','Orange','Grape','Sweet Lime'] 6 | __fruit_price_list=[200,80,70,110,60] 7 | 8 | @staticmethod 9 | def get_fruit_price(fruit_name): 10 | if fruit_name in FruitInfo.__fruit_name_list: 11 | fruit_index=FruitInfo.__fruit_name_list.index(fruit_name) 12 | price_per_kg=FruitInfo.__fruit_price_list[fruit_index] 13 | return price_per_kg 14 | else: 15 | return -1 16 | 17 | @staticmethod 18 | def get_fruit_name_list(): 19 | return FruitInfo.__fruit_name_list 20 | @staticmethod 21 | def get_fruit_price_list(): 22 | return FruitInfo.__fruit_price_list 23 | 24 | class Purchase: 25 | __counter=101 26 | def __init__(self,customer,fruit_name,quantity): 27 | self.__customer=customer 28 | self.__fruit_name=fruit_name 29 | self.__quantity=quantity 30 | self.__purchase_id=None 31 | 32 | def calculate_price(self): 33 | price=FruitInfo.get_fruit_price(self.__fruit_name) 34 | if FruitInfo.get_fruit_price(self.__fruit_name) != -1: 35 | mx=FruitInfo.get_fruit_price_list() 36 | maximum=max(mx) 37 | minimum=min(mx) 38 | total_price=price*self.__quantity 39 | if price==maximum and self.__quantity>1: 40 | total_price*=0.98 41 | 42 | if price==minimum and self.__quantity>=5: 43 | total_price*=0.95 44 | 45 | if Customer.get_cust_type(self.__customer)=='wholesale': 46 | total_price*=0.90 47 | 48 | self.__purchase_id="P"+str(Purchase.__counter) 49 | Purchase.__counter+=1 50 | 51 | return total_price 52 | 53 | else: 54 | return -1 55 | 56 | def get_purchase_id(self): 57 | return self.__purchase_id 58 | 59 | def get_customer(self): 60 | return self.__customer 61 | 62 | def get_quantity(self): 63 | return self.__quantity 64 | 65 | 66 | class Customer: 67 | def __init__(self,customer_name,cust_type): 68 | self.__customer_name=customer_name 69 | self.__cust_type=cust_type 70 | 71 | def get_customer_name(self): 72 | return self.__customer_name 73 | 74 | def get_cust_type(self): 75 | return self.__cust_type 76 | 77 | 78 | c=Customer("Tom", "wholesale") 79 | p=Purchase(c,"Guava", 2) 80 | print(p.calculate_price()) 81 | #fruit_name-Guava,quantity-2 82 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Assgn-18.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-18 2 | #Start writing your code here 3 | 4 | class Bill: 5 | counter=1000 6 | def __init__(self): 7 | self.__bill_id=1000 8 | self.__bill_amount=0 9 | 10 | def generate_bill_amount(self,item_quantity,items): 11 | Bill.counter+=1 12 | self.__bill_amount=0 13 | self.__bill_id='B'+str(Bill.counter) 14 | tmp_dict=item_quantity 15 | a={} 16 | for item in tmp_dict: 17 | a[item.lower()]=tmp_dict[item] 18 | for prod,quan in a.items(): 19 | for item in items: 20 | if item.get_item_id().lower()==prod: 21 | self.__bill_amount+=quan*item.get_price_per_quantity() 22 | break 23 | 24 | def get_bill_id(self): 25 | return self.__bill_id 26 | 27 | def get_bill_amount(self): 28 | return self.__bill_amount 29 | 30 | class Customer: 31 | def __init__(self,customer_name): 32 | self.__customer_name=customer_name 33 | self.__payment_status=None 34 | 35 | def pays_bill(self,bill): 36 | self.__payment_status="Paid" 37 | 38 | print(self.__customer_name) 39 | print(bill.get_bill_id()) 40 | print(bill.get_bill_amount()) 41 | 42 | def get_customer_name(self): 43 | return self.__customer_name 44 | 45 | def get_payment_status(self): 46 | return self.__payment_status 47 | 48 | class Item: 49 | def __init__(self,item_id,description,price_per_quantity): 50 | self.__item_id=item_id 51 | self.__description=description 52 | self.__price_per_quantity=price_per_quantity 53 | 54 | 55 | def get_item_id(self): 56 | return self.__item_id 57 | 58 | def get_description(self): 59 | return self.__description 60 | 61 | def get_price_per_quantity(self): 62 | return self.__price_per_quantity 63 | 64 | 65 | item_quantity = {'Ir987':3, 'IR346':2, 'IR658':4, 'IR123':2} 66 | c=Customer("Sudarshan") 67 | i1=Item("IR987","Sunfeast Marie",100.0) 68 | i2=Item("ir658","Kellogs Oats",151.0) 69 | i3=Item("Ir346","Maggie Noodles",35.75) 70 | i4=Item("iR234","Kissan Jam",100.0) 71 | i5=Item("IR123","Nescafe",55.5) 72 | i6=Item("IR111","Milk",100.0) 73 | items=[i1,i2,i3,i4,i5,i6] 74 | b=Bill() 75 | b.generate_bill_amount(item_quantity,items) 76 | b.generate_bill_amount(item_quantity,items) 77 | b.generate_bill_amount(item_quantity,items) 78 | b.generate_bill_amount(item_quantity,items) 79 | b.generate_bill_amount(item_quantity,items) 80 | 81 | c.pays_bill(b) 82 | print(b.get_bill_id()) 83 | print(b.get_bill_amount()) 84 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 8/PF-Assgn-55.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Write a python program to help an airport manager to generate few statistics based on the ticket details available for a day. 3 | 4 | Go through the below program and complete it based on the comments mentioned in it. 5 | 6 | 7 | Note: Perform case sensitive string comparisons wherever necessary. 8 | 9 | ''' 10 | 11 | #PF-Assgn-55 12 | 13 | #Sample ticket list - ticket format: "flight_no:source:destination:ticket_no" 14 | #Note: flight_no has the following format - "airline_name followed by three digit number 15 | 16 | #Global variable 17 | ticket_list=["AI567:MUM:LON:014","AI077:MUM:LON:056", "BA896:MUM:LON:067", "SI267:MUM:SIN:145","AI077:MUM:CAN:060","SI267:BLR:MUM:148","AI567:CHE:SIN:015","AI077:MUM:SIN:050","AI077:MUM:LON:051","SI267:MUM:SIN:146"] 18 | 19 | def find_passengers_flight(airline_name="AI"): 20 | #This function finds and returns the number of passengers travelling in the specified airline. 21 | count=0 22 | for i in ticket_list: 23 | string_list=i.split(":") 24 | if(string_list[0].startswith(airline_name)): 25 | count+=1 26 | return count 27 | 28 | def find_passengers_destination(destination): 29 | #Write the logic to find and return the number of passengers traveling to the specified destination 30 | count=0 31 | 32 | for i in ticket_list: 33 | string_list=i.split(":") 34 | # for val in string_list: 35 | if(string_list[2]==destination): 36 | count+=1 37 | return count 38 | 39 | def find_passengers_per_flight(): 40 | '''Write the logic to find and return a list having number of passengers traveling per flight based on the details in the ticket_list 41 | In the list, details should be provided in the format: 42 | [flight_no:no_of_passengers, flight_no:no_of_passengers, etc.].''' 43 | 44 | l=[] 45 | temp=[] 46 | m=[] 47 | for i in ticket_list: 48 | string_list=i.split(":") 49 | l.append(string_list[0]) 50 | for i in l: 51 | if i not in temp: 52 | temp.append(i) 53 | for i in temp: 54 | s1=0 55 | s1=l.count(i) 56 | s2 = str(i)+":"+str(s1) 57 | m.append(s2) 58 | return m 59 | def sort_passenger_list(): 60 | #Write the logic to sort the list returned from find_passengers_per_flight() function in the descending order of number of passengers 61 | l=find_passengers_per_flight() 62 | temp=[] 63 | final=[] 64 | for i in l: 65 | s=i.split(":") 66 | temp.append(s[1]) 67 | temp.sort() 68 | sort=temp[::-1] 69 | for i in range(0,len(sort)): 70 | for val in l: 71 | s2=val.split(":") 72 | if sort[i] in s2: 73 | final.insert(i,val) 74 | return final 75 | #Provide different values for airline_name and destination and test your program. 76 | print(find_passengers_flight("AI")) 77 | print(find_passengers_destination("LON")) 78 | #find_passengers_per_flight() 79 | print(sort_passenger_list()) 80 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 5/PF-Assgn-39.py: -------------------------------------------------------------------------------- 1 | ''' 2 | A vendor at a food court is in the process of automating his order management system. 3 | The vendor serves the following menu – Veg Roll, Noodles, Fried Rice and Soup and also maintains the quantity available for each item. 4 | The customer can order any combination of items. The customer is provided the item if the requested quantity of item is available with the 5 | vendor. 6 | 7 | 8 | Write a python program which implements the following functions. 9 | place_order(*item_tuple): This function accepts the order placed by the customer. Consider it to be a variable length argument as each 10 | customer may have a different order. 11 | The function should check whether the items requested are present in the vendor’s menu and if so, it should check whether the requested 12 | quantity is available for each by invoking the check_quantity_available() method. 13 | 14 | 15 | The function should display appropriate messages for each item in the order for the below scenarios: 16 | 17 | 1. When the requested item is not available in vendor’s menu, display is not available 18 | 2. When the quantity requested by the customer is not available, display stock is over 19 | 3. When the requested quantity of the item is available with the vendor, display is available 20 | 21 | check_quantity_available(index,quantity_requested): This function should check whether the requested quantity of the specified item is 22 | available. If so, it should reduce the quantity requested from the quantity available for that item and return True. Otherwise, it should 23 | return False. 24 | ''' 25 | 26 | 27 | #PF-Assgn-39 28 | #This verification is based on string match. 29 | 30 | #Global variables 31 | menu=('Veg Roll','Noodles','Fried Rice','Soup') 32 | quantity_available=[2,200,3,0] 33 | 34 | '''This method accepts the item followed by the quantity required by a customer in the format item1, quantity_required, item2, quantity_required etc.''' 35 | def place_order(*item_tuple): 36 | item=[] 37 | quant=[] 38 | for i in range(0,len(item_tuple)): 39 | if i%2==0: 40 | item.append(item_tuple[i]) 41 | else: 42 | quant.append(item_tuple[i]) 43 | 44 | for i,j in enumerate(item): 45 | if j not in menu: 46 | print(j + " is not available") 47 | else: 48 | i1=menu.index(j) 49 | if check_quantity_available(i1,quant[i]): 50 | print (j + " is available") 51 | else: 52 | print(j + " stock is over") 53 | '''This method accepts the index position of the item requested by the customer in the quantity_available list, and the requested quantity of the item.''' 54 | def check_quantity_available(index,quantity_requested): 55 | if quantity_available[index]>=quantity_requested: 56 | return True 57 | else: 58 | return False 59 | #Provide different values for items ordered and test your program 60 | #place_order("Veg Roll",2,"Noodles",2) 61 | place_order("Fried Rice",2,"Soup",1) 62 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Assgn-16.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-16 2 | 3 | class Customer: 4 | def __init__(self,phone_no,name,age): 5 | self.phone_no=phone_no 6 | self.name=name 7 | self.age=age 8 | self.list_of_calls=None 9 | 10 | class CallDetail: 11 | def __init__(self,phone_no,called_no,duration): 12 | self.phone_no=phone_no 13 | self.called_no=called_no 14 | self.duration=duration 15 | 16 | class Util: 17 | def __init__(self): 18 | self.list_of_customer_calldetail_objects=None 19 | 20 | def parse_customer(self,list_of_customers,list_of_calls): 21 | self.list_of_customer_calldetail_objects=[] 22 | for customer in list_of_customers: 23 | customer.list_of_calls=[] 24 | for call in list_of_calls: 25 | if customer.phone_no==call.phone_no: 26 | customer.list_of_calls.append(call) 27 | self.list_of_customer_calldetail_objects.append(customer) 28 | 29 | cust1=Customer(9900009901,'cust1',23) 30 | cust2=Customer(9900009902,'cust2',24) 31 | cust3=Customer(9900009903,'cust3',25) 32 | list_of_customers=[cust1,cust2,cust3] 33 | 34 | call1=CallDetail(9900009901,8800123401,5) 35 | call2=CallDetail(9900009903,8800123402,10) 36 | call3=CallDetail(9900009902,8800123403,2) 37 | call4=CallDetail(9900009901,8800123404,8) 38 | call5=CallDetail(9900009901,8800123405,7) 39 | call6=CallDetail(9900009903,8800123406,9) 40 | call7=CallDetail(9900009903,8800123407,4) 41 | list_of_calls=[call1,call2,call3,call4,call5,call6,call7] 42 | 43 | Util().parse_customer(list_of_customers, list_of_calls) 44 | 45 | class Customer: 46 | def __init__(self,phone_no,name,age): 47 | self.phone_no=phone_no 48 | self.name=name 49 | self.age=age 50 | self.list_of_calls=None 51 | 52 | class CallDetail: 53 | def __init__(self,phone_no,called_no,duration): 54 | self.phone_no=phone_no 55 | self.called_no=called_no 56 | self.duration=duration 57 | 58 | class Util: 59 | def __init__(self): 60 | self.list_of_customer_calldetail_objects=None 61 | 62 | def parse_customer(self,list_of_customers,list_of_calls): 63 | self.list_of_customer_calldetail_objects=[] 64 | for customer in list_of_customers: 65 | customer.list_of_calls=[] 66 | for call in list_of_calls: 67 | if customer.phone_no==call.phone_no: 68 | customer.list_of_calls.append(call) 69 | self.list_of_customer_calldetail_objects.append(customer) 70 | 71 | cust1=Customer(9900009901,'cust1',23) 72 | cust2=Customer(9900009902,'cust2',24) 73 | cust3=Customer(9900009903,'cust3',25) 74 | list_of_customers=[cust1,cust2,cust3] 75 | 76 | call1=CallDetail(9900009901,8800123401,5) 77 | call2=CallDetail(9900009903,8800123402,10) 78 | call3=CallDetail(9900009902,8800123403,2) 79 | call4=CallDetail(9900009901,8800123404,8) 80 | call5=CallDetail(9900009901,8800123405,7) 81 | call6=CallDetail(9900009903,8800123406,9) 82 | call7=CallDetail(9900009903,8800123407,4) 83 | list_of_calls=[call1,call2,call3,call4,call5,call6,call7] 84 | 85 | Util().parse_customer(list_of_customers, list_of_calls) 86 | -------------------------------------------------------------------------------- /OOP in Python/Day 5/OOPR-Assgn-33.py: -------------------------------------------------------------------------------- 1 | #OOPR-Tryout 2 | #Start writing your code here 3 | 4 | class OverdrawException(Exception): 5 | pass 6 | 7 | class LimitReachedException(Exception): 8 | pass 9 | 10 | class Account: 11 | def __init__(self,account_type,balance,min_balance): 12 | self.__account_type=account_type 13 | self.__balance=balance 14 | self.__min_balance=min_balance 15 | 16 | def get_account_type(self): 17 | return self.__account_type 18 | 19 | def get_balance(self): 20 | return self.__balance 21 | 22 | def get_min_balance(self): 23 | return self.__min_balance 24 | 25 | def set_balance(self,balance): 26 | self.__balance=balance 27 | 28 | 29 | class Customer: 30 | def __init__(self,customer_id,customer_name,age,account): 31 | self.__customer_id=customer_id 32 | self.__customer_name=customer_name 33 | self.__age=age 34 | self.__account=account 35 | 36 | def withdraw(self,amount): 37 | balance=Account.get_balance(self.__account) 38 | min_balance=Account.get_min_balance(self.__account) 39 | new_balance = balance - amount 40 | if amount > balance: 41 | raise OverdrawException 42 | elif new_balance < min_balance: 43 | raise LimitReachedException 44 | 45 | Account.set_balance(self.__account,new_balance) 46 | 47 | def take_card(self): 48 | print("Take card out from the ATM") 49 | 50 | def get_customer_id(self): 51 | return self.__customer_id 52 | 53 | def get_customer_name(self): 54 | return self.__customer_name 55 | 56 | def get_age(self): 57 | return self.__age 58 | 59 | def get_account(self): 60 | return self.__account 61 | 62 | 63 | class PrivilegedCustomer(Customer): 64 | def __init__ (self,customer_id, customer_name, age, account, bonus_points): 65 | super().__init__ (customer_id, customer_name, age, account) 66 | self.__bonus_points=bonus_points 67 | 68 | def __increase_bonus(self): 69 | Account=self.get_account() 70 | balance = Account.get_balance() 71 | if balance>1000: 72 | self.__bonus_points+=10 73 | else: 74 | self.__bonus_points+=2 75 | 76 | def withdraw(self,amount): 77 | Customer.withdraw(self,amount) 78 | self.__increase_bonus() 79 | 80 | def get_bonus_points(self): 81 | return self.__bonus_points 82 | 83 | a = Account("Savings",1000,500) 84 | c = Customer("100","Gopal",43,a) 85 | p = PrivilegedCustomer("c101","Sudarshan",22,a,100) 86 | 87 | try: 88 | print("Customer Id: "+str(c.get_customer_id())) 89 | print("Customer Name: "+c.get_customer_name()) 90 | print("Age: "+str(c.get_age())) 91 | print("Account Type: "+a.get_account_type()) 92 | print("Account Balance: "+str(a.get_balance())) 93 | print("Account minimum: "+str(a.get_min_balance())) 94 | p.withdraw(400) 95 | print("Account Balance after withdraw: "+str(a.get_balance())) 96 | print("Bonus Points: "+str(p.get_bonus_points())) 97 | except OverdrawException: 98 | print("amount to be withdrawn is greater than account balance.") 99 | except LimitReachedException: 100 | print("balance amount is less than minimum account balance.") 101 | finally: 102 | c.take_card() 103 | 104 | -------------------------------------------------------------------------------- /OOP in Python/Day 5/OOPR-Assgn-34.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-34 2 | class Company: 3 | #Stores hike% based on job level. 4 | dict_hike={"A":5, "B":6, "C":10 , "D":11} 5 | #Consider incentive provided in all classes to be in Rupees(Rs). 6 | __c_incentive=5000 7 | def __init__(self,name): 8 | self.name=name 9 | @staticmethod 10 | def get_c_incentive(): 11 | return Company.__c_incentive 12 | class Employee: 13 | def __init__(self, emp_id,e_incentive, job_level,salary, performance_list): 14 | self.emp_id=emp_id 15 | self.__e_incentive=e_incentive 16 | self.__salary=salary 17 | self.__job_level=job_level 18 | self.__performance_list=performance_list 19 | def get_e_incentive(self): 20 | return self.__e_incentive 21 | def get_performance_list(self): 22 | return self.__performance_list 23 | def get_salary(self): 24 | return self.__salary 25 | def get_job_level(self): 26 | return self.__job_level 27 | def identify_performance_hike(self): 28 | return None 29 | def identify_job_level_hike(self): 30 | return None 31 | def identify_incentive(self): 32 | return None 33 | def update_salary(self,hike, incentive): 34 | self.__salary= (self.__salary+ self.__salary*hike/100) + incentive 35 | def calculate_salary(self): 36 | jl_hike=self.identify_job_level_hike() 37 | ex_hike=self.identify_performance_hike() 38 | if(jl_hike!=None): 39 | hike=jl_hike 40 | if(ex_hike!=None): 41 | hike+=ex_hike 42 | incentive=self.identify_incentive() 43 | self.update_salary(hike, incentive) 44 | return True 45 | else: 46 | return False 47 | #Implement the class here 48 | class PermanentEmployee(Employee): 49 | def __init__(self, emp_id,e_incentive, job_level,salary, performance_list,p_incentive): 50 | super().__init__(emp_id,e_incentive, job_level,salary, performance_list) 51 | self.__p_incentive=p_incentive 52 | 53 | 54 | def get_p_incentive(self): 55 | return self.__p_incentive 56 | 57 | def identify_performance_hike(self): 58 | performance_list=self.get_performance_list() 59 | if performance_list[4]==1 and performance_list[3]==1: 60 | hike=5 61 | elif performance_list[4]==1 and performance_list[3]==2 and performance_list[2]==1: 62 | hike=3 63 | else: 64 | hike = None 65 | return hike 66 | 67 | def identify_job_level_hike(self): 68 | job_level = Employee.get_job_level(self) 69 | if job_level in Company.dict_hike.keys(): 70 | job_hike=Company.dict_hike[job_level] 71 | return job_hike 72 | else: 73 | return None 74 | 75 | def identify_incentive(self): 76 | c_incentive=Company.get_c_incentive() 77 | e_incentive=Employee.get_e_incentive(self) 78 | incentive=e_incentive + self.__p_incentive + c_incentive 79 | return incentive 80 | 81 | def calculate_salary(self): 82 | jl_hike=self.identify_job_level_hike() 83 | ex_hike=self.identify_performance_hike() 84 | if(jl_hike!=None): 85 | hike=jl_hike 86 | if(ex_hike!=None): 87 | hike+=ex_hike 88 | incentive=self.identify_incentive() 89 | Employee.update_salary(self, hike, incentive) 90 | return True 91 | else: 92 | return False 93 | 94 | p = PermanentEmployee(2134,1000,"A",130000,[1, 2, 1, 1, 1],3000) 95 | -------------------------------------------------------------------------------- /Programming Fundamental Using Python/Day 2/PF-Assgn-20.py: -------------------------------------------------------------------------------- 1 | #PF-Assgn-20 2 | def calculate_loan(account_number,salary,account_balance,loan_type,loan_amount_expected,customer_emi_expected): 3 | eligible_loan_amount=0 4 | bank_emi_expected=0 5 | #eligible_loan_amount=0 6 | 7 | #Start writing your code here 8 | #Populate the variables: eligible_loan_amount and bank_emi_expected 9 | if 1000<=account_number<1999: 10 | if account_balance>=100000: 11 | if salary>25000 and loan_type=="Car": 12 | if loan_amount_expected<=500000 and customer_emi_expected<=36: 13 | eligible_loan_amount=500000 14 | bank_emi_expected=36 15 | print("Account number:", account_number) 16 | print("The customer can avail the amount of Rs.", eligible_loan_amount) 17 | print("Eligible EMIs :", bank_emi_expected) 18 | print("Requested loan amount:", loan_amount_expected) 19 | print("Requested EMI's:",customer_emi_expected) 20 | else: 21 | print("The customer is not eligible for the loan") 22 | elif salary>50000 and loan_type=="House": 23 | if loan_amount_expected<=6000000 and customer_emi_expected<=60: 24 | eligible_loan_amount=6000000 25 | bank_emi_expected=60 26 | print("Account number:", account_number) 27 | print("The customer can avail the amount of Rs.", eligible_loan_amount) 28 | print("Eligible EMIs :", bank_emi_expected) 29 | print("Requested loan amount:", loan_amount_expected) 30 | print("Requested EMI's:",customer_emi_expected) 31 | else: 32 | print("The customer is not eligible for the loan") 33 | elif salary>75000 and loan_type=="Business": 34 | if customer_emi_expected<=84 and loan_amount_expected<=7500000: 35 | eligible_loan_amount=7500000 36 | bank_emi_expected=84 37 | print("Account number:", account_number) 38 | print("The customer can avail the amount of Rs.", eligible_loan_amount) 39 | print("Eligible EMIs :", bank_emi_expected) 40 | print("Requested loan amount:", loan_amount_expected) 41 | print("Requested EMI's:",customer_emi_expected) 42 | else: 43 | print("The customer is not eligible for the loan") 44 | else: 45 | print("Invalid loan type or salary") 46 | else: 47 | print("Insufficient account balance") 48 | else: 49 | print("Invalid account number") 50 | 51 | #Use the below given print statements to display the output, in case of success 52 | #print("Account number:", account_number) 53 | #print("The customer can avail the amount of Rs.", eligible_loan_amount) 54 | #print("Eligible EMIs :", bank_emi_expected) 55 | #print("Requested loan amount:", loan_amount_expected) 56 | #print("Requested EMI's:",customer_emi_expected) 57 | 58 | #Use the below given print statements to display the output, in case of invalid data. 59 | #print("Insufficient account balance") 60 | #print("The customer is not eligible for the loan") 61 | #print("Invalid account number") 62 | #print("Invalid loan type or salary") 63 | # Also, do not modify the above print statements for verification to work 64 | 65 | 66 | #Test your code for different values and observe the results 67 | calculate_loan(1005,26000,255000,"Car1",300000,30) 68 | -------------------------------------------------------------------------------- /OOP in Python/Day 3/OOPR-Assgn-22.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-22 2 | class Multiplex: 3 | __list_movie_name=["movie1","movie2"] 4 | __list_total_tickets=[100,60] 5 | __list_last_seat_number=["M-10",None] 6 | __list_ticket_price=[150,200] 7 | 8 | def __init__(self): 9 | self.__seat_numbers=None 10 | self.__total_price=None 11 | 12 | def calculate_ticket_price(self,movie_index,number_of_tickets): 13 | self.__total_price= Multiplex.__list_ticket_price[movie_index]*number_of_tickets 14 | 15 | def check_seat_availability(self,movie_index,number_of_tickets): 16 | if(Multiplex.__list_total_tickets[movie_index]15: 75 | self.__food_coupon="Yes" 76 | 77 | def book_ticket(self): 78 | if Ticket.calculate_amount(self.__ticket,self.__list_of_games): 79 | Ticket.generate_ticket_id(self.__ticket) 80 | self.play_game() 81 | self.update_food_coupon() 82 | return True 83 | else: 84 | return False 85 | 86 | def get_name(self): 87 | return self.__name 88 | 89 | def get_list_of_games(self): 90 | return self.__list_of_games 91 | 92 | def get_ticket(self): 93 | return self.__ticket 94 | 95 | def get_points_earned(self): 96 | return self.__points_earned 97 | 98 | def get_food_coupon(self): 99 | return self.__food_coupon 100 | #Remove pass and implement class Customer here 101 | 102 | '''Represent customers and display all details of the customer, if he is able to book the ticket and play the game. Else, display appropriate error message ''' 103 | -------------------------------------------------------------------------------- /OOP in Python/Day 5/OOPR-Assgn-32.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-32 2 | #Start writing your code here 3 | from abc import ABCMeta,abstractmethod 4 | 5 | emp_qualification=["Bachelors","Masters"] 6 | graduate_job_band=["A","B","C"] 7 | lateral_job=["D","E","F"] 8 | bonus={"AGP":6500,"AGPT":8200,"AGDEV":11500} 9 | emp_incentive={"A":4,"B":6,"C":10,"D":13,"E":16,"F":20} 10 | 11 | class Employee(metaclass=ABCMeta): 12 | def __init__(self,job_band,employee_name,basic_salary,qualification): 13 | self.__job_band=job_band 14 | self.__employee_name=employee_name 15 | self.__basic_salary=basic_salary 16 | self.__qualification=qualification 17 | 18 | def get_employee_name(self): 19 | return self.__employee_name 20 | 21 | def get_job_band(self): 22 | return self.__job_band 23 | 24 | def get_basic_salary(self): 25 | return self.__basic_salary 26 | 27 | def get_qualification(self): 28 | return self.__qualification 29 | 30 | @abstractmethod 31 | def validate_job_band(self): 32 | pass 33 | 34 | @abstractmethod 35 | def calculate_gross_salary(self): 36 | pass 37 | 38 | def validate_basic_salary(self): 39 | if self.__basic_salary>3000: 40 | return True 41 | else: 42 | return False 43 | 44 | def validate_qualification(self): 45 | if self.__qualification in emp_qualification: 46 | return True 47 | else: 48 | return False 49 | 50 | 51 | class Graduate(Employee): 52 | def __init__(self,job_band,employee_name,basic_salary,qualification,cgpa): 53 | super().__init__(job_band,employee_name,basic_salary,qualification) 54 | self.__cgpa=cgpa 55 | 56 | def get_cgpa(self): 57 | return self.__cgpa 58 | 59 | def validate_job_band(self): 60 | band=Employee.get_job_band(self) 61 | if band in graduate_job_band: 62 | return True 63 | else: 64 | return False 65 | 66 | def calculate_gross_salary(self): 67 | if self.validate_basic_salary() == True and self.validate_qualification() == True and self.validate_job_band() == True: 68 | incentive=0 69 | tpi=0 70 | salary=Employee.get_basic_salary(self) 71 | band=Employee.get_job_band(self) 72 | incent=emp_incentive[band] 73 | incentive=incent/100 74 | 75 | if 4<= self.__cgpa <= 4.25: 76 | tpi=1000 77 | elif 4.26 <= self.__cgpa <= 4.5: 78 | tpi=1700 79 | elif 4.51 <= self.__cgpa <= 4.75: 80 | tpi=3200 81 | elif 4.76 <= self.__cgpa <= 5: 82 | tpi=5000 83 | 84 | gross_salary = salary + salary * incentive + tpi + salary * 0.12 85 | return gross_salary 86 | else: 87 | return -1 88 | 89 | 90 | class Lateral(Employee): 91 | def __init__(self,job_band,employee_name,basic_salary,qualification,skill_set): 92 | super().__init__(job_band,employee_name,basic_salary,qualification) 93 | self.__skill_set=skill_set 94 | 95 | def get_skill_set(self): 96 | return self.__skill_set 97 | 98 | def validate_job_band(self): 99 | band=Employee.get_job_band(self) 100 | if band in lateral_job: 101 | return True 102 | else: 103 | return False 104 | 105 | def calculate_gross_salary(self): 106 | if self.validate_basic_salary() == True and self.validate_qualification() == True and self.validate_job_band() == True: 107 | sme=0 108 | incentive=0 109 | band=Employee.get_job_band(self) 110 | salary=Employee.get_basic_salary(self) 111 | incent=emp_incentive[band] 112 | incentive=incent/100 113 | sme = bonus[self.__skill_set] 114 | 115 | gross_salary = salary + salary * incentive + sme + salary * 0.12 116 | return gross_salary 117 | else: 118 | return -1 119 | 120 | 121 | l=Lateral("D","Sarah",6500,"Masters","AGP") 122 | g=Graduate("B","Sarah",6500,"Masters",4.65) 123 | print(l.get_skill_set()) 124 | print(l.validate_job_band()) 125 | print(l.calculate_gross_salary()) 126 | print(g.calculate_gross_salary()) 127 | -------------------------------------------------------------------------------- /OOP in Python/Day 5/OOPR-Assgn-31.py: -------------------------------------------------------------------------------- 1 | #OOPR-Assgn-31 2 | import math 3 | from abc import ABCMeta, abstractmethod 4 | class Logistics(metaclass=ABCMeta): 5 | __counter=7001 6 | def __init__(self,start_reading,end_reading): 7 | self.__consumer_id=0 8 | self.__start_reading=start_reading 9 | self.__end_reading=end_reading 10 | def get_consumer_id(self): 11 | return self.__consumer_id 12 | def get_start_reading(self): 13 | return self.__start_reading 14 | def get_end_reading(self): 15 | return self.__end_reading 16 | def validate_meter_reading(self): 17 | if(self.__start_reading >= self.__end_reading): 18 | return False 19 | else: 20 | return True 21 | def generate_consumer_id(self): 22 | if not Logistics.__counter: 23 | Logistics.__counter=7001 24 | if not self.__consumer_id: 25 | self.__consumer_id = Logistics.__counter 26 | Logistics.__counter = Logistics.__counter + 1 27 | 28 | @abstractmethod 29 | def calculate_bill_amount(self): 30 | pass 31 | class PassengerLogistics(Logistics): 32 | __list_vehicle=["BMW","TOYOTA","FORD"] 33 | __list_minimum_charge=[3000,1500,1000] #these lists are storing vehicle type, minimum charge, rate per kilometer for first hundred and rate per kilometer for rest of distance 34 | __list_charge_for_hundred=[30,15,10] #there is a one to one correspondence 35 | __list_charge_after_hundred=[25,12,7] 36 | def __init__(self,vehicle_type,start_reading,end_reading): 37 | super().__init__(start_reading,end_reading) 38 | self.__vehicle_type=vehicle_type 39 | def get_vehicle_type(self): 40 | return self.__vehicle_type 41 | def validate_vehicle_type(self): 42 | for index in range(0,len(PassengerLogistics.__list_vehicle)): 43 | if(PassengerLogistics.__list_vehicle[index]==self.__vehicle_type): 44 | return index 45 | return -1 46 | def calculate_bill_amount(self): 47 | bill=0 48 | if self.validate_vehicle_type()>=0 and Logistics.validate_meter_reading(self)==True: 49 | Logistics.generate_consumer_id(self) 50 | total_distance=self.get_end_reading() - self.get_start_reading() 51 | v_index=PassengerLogistics.__list_vehicle.index(self.__vehicle_type) 52 | if total_distance<=100: 53 | bill=PassengerLogistics.__list_charge_for_hundred[v_index] * total_distance 54 | else: 55 | distance=total_distance-100 56 | bill = (PassengerLogistics.__list_charge_for_hundred[v_index] * 100) + (PassengerLogistics.__list_charge_after_hundred[v_index] * distance) 57 | 58 | if bill 1000 and self.__goods_weight<=3000): 90 | charge_per_kilometer=GoodsLogistics.__carrier_dict[self.__carrier_type] * 2 ** multiplier 91 | else: 92 | charge_per_kilometer=200 93 | bill_amount=total_distance*charge_per_kilometer 94 | bill_amount=bill_amount+(bill_amount*0.1)+2000 95 | return bill_amount 96 | else: 97 | return -1 98 | else: 99 | return -1 100 | passenger_logistic=PassengerLogistics("BMW",300,400) 101 | bill_amount=passenger_logistic.calculate_bill_amount() 102 | if(bill_amount==-1): 103 | print("Invalid vehicle type or meter reading ") 104 | else: 105 | print("Consumer id :",passenger_logistic.get_consumer_id()) 106 | print("Start reading :",passenger_logistic.get_start_reading()) 107 | print("End reading :",passenger_logistic.get_end_reading()) 108 | print("Total Amount :",bill_amount) 109 | print("------------------------------------------------------------") 110 | goods_logistic=GoodsLogistics("FORCE",3000,300,400) 111 | bill_amount=goods_logistic.calculate_bill_amount() 112 | if(bill_amount==-1): 113 | print("Invalid career type or meter reading ") 114 | else: 115 | print("Consumer id :",goods_logistic.get_consumer_id()) 116 | print("Goods weight :",goods_logistic.get_goods_weight()) 117 | print("Start reading :",goods_logistic.get_start_reading()) 118 | print("End reading :",goods_logistic.get_end_reading()) 119 | print("Total Amount :",bill_amount) 120 | --------------------------------------------------------------------------------