B.C.A. Sem-3
Database Management System
Course Code: LBC0302 | Course Title: Database Management System(3 Credits) |
Course Outcome: –
At the end of the course students will be able to: 1. Describe the fundamental elements of relational database management systems 2. Explain the basic concepts of relational data model, entity-relationship model, relational database design, relational algebra and SQL. 3. Design ER-models to represent simple database application scenarios 4. Convert the ER-model to relational tables, populate relational database and formulate SQL queries on data. 5. Improve the database design by normalization. 6. To appraise the basic issues of Transaction processing and Serializability. 7. Familiar with basic database storage structures and access techniques: file and page organizations, indexing methods including B tree, and hashing. Course Goal 1. To impart basic concepts of database management system, 2. To explain key skills of logical database design. 3. To facilitate students in learning SQL. 4. To impart basic concepts of relational algebra and conceptual database design 5. To explain transaction management concept 6. To explain database storage management Course Learning Outcomes · Understand and evaluate the role of database management systems in information technology applications within organizations. · Recognize and use logical design methods and tools for databases. · Develop sophisticated queries to extract information from large datasets · Understand the SQL data definition and SQL query languages. · Understand the transaction management concepts, backup and recovery and serializability |
|
*BTL- Bloom’s Taxonomy Level. 1- Understand, 2- Remember, 3- Apply, 4- Analyze, 5- Evaluate, 6- Create |
Course Contents
Sr. No | Unit No./ Unit description | Unit Outcome |
1 | Unit 1- Introduction to DBMS: File Systems versus DBMS, various view of data, data independence, instance and schema, data models, Database languages, Database administrator and users, data dictionary, overall system architecture. | This module has been designed as per BTL 1. |
2 | ER model: basic concepts, design issues, mapping constraint, keys, weak and strong entity sets, attributes, relationships, specialization, generalization and aggregation, reduction of ER schema to tables. | This module has been designed as per BTL 3,4 and 5. |
3 | Unit 3- Relational Algebra: domains, relations, relational database, various types of keys, candidate, primary, alternate and foreign keys, Codd’s rule, relational algebra with extended operations. | This module has been designed as per BTL 1&2. |
4 | Unit 4- Structured Query Language: Basic Structure ,Data types, operators, DDL, DML, DCL, TCL, Set Operations, Aggregate Functions, Null Values, SQL Clause. | This module has been designed as per BTL 3, BTL 4 and BTL 5 |
5 | Unit 5- View, sub-queries and joins: Keys, Sub queries, Views, Integrity: Domain constraints, Joined Relations | This module has been designed as per BTL 3, BTL 4 and BTL 5 |
6 | Unit 6- Functional Dependencies: basic definitions, trivial and non-trivial dependencies, closure set of dependencies and of attributes, irreducible set of dependencies, non-loss decomposition, FD diagram | This module has been designed as per BTL 4. |
7 | Unit 7- Introduction to normalization: first, second, third Normal forms, dependency preservation, BCNF, multivalued dependencies and fourth normal form, Join dependency and fifth normal form. | This module has been designed as per BTL 3, 4 & 5 . |
8 | Unit 8- Transaction Management: basic concepts, ACID properties, Transaction states, Concurrency problems, Concurrency Control, failure classification, Recovery System; Serializability and Locking techniques | This module has been designed as per BTL 2 &4. |
9 | Unit 9- Data Storage and Querying: Storage and File Structure, Indexing and Hashing, Query Processing, Query Optimization | This module has been designed as per BTL 1 & 2. |
10 | Unit 10- Database System Architectures: Distributed Databases, Parallel Databases, Data Warehousing and Data Mining | This module has been designed as per BTL 4&5. |
Text book References: –
Other References:
|
LABMANUAL
DATABASEMANAGEMENTSYSTEM LAB(LBC0321)
LISTOF EXPERIMENTS
S.No | NameoftheExperiment | PageNo |
1. | ImplementationofDDLcommandsofSQLwithsuitable examples
· Createtable · Altertable · DropTable |
|
2. | ImplementationofDMLcommandsofSQLwithsuitableexamples
· Insert · Update · Delete |
|
3. | Implementationofdifferenttypesoffunctionwithsuitableexamples
· Numberfunction · AggregateFunction · CharacterFunction · ConversionFunction · DateFunction |
|
4. | Implementationofdifferenttypesofoperators inSQL
· Arithmetic Operators · LogicalOperators · ComparisonOperator · SpecialOperator · SetOperation |
|
5. | ImplementationofdifferenttypesofJoins
· InnerJoin · OuterJoin · NaturalJoinetc.. |
|
6. | StudyandImplementationof
· GroupBy&having clause · Orderbyclause · Indexing |
7. | Study&Implementationof
· Subqueries · Views |
|
8 | Study&Implementationofdifferenttypes ofconstraints. | |
9 | Study&ImplementationofDatabaseBackup&Recoverycommands.Study&ImplementationofRollback,Commit,Savepoint. | |
10 | · CreatingDatabase/TableSpace
· ManagingUsers:CreateUser,DeleteUser · Managingroles:-Grant,Revoke. |
|
11 | Study&ImplementationofPL/SQL. | |
12 | Study&Implementation ofSQLTriggers. |
ExperimentNo:1
Title:ImplementationofDDLcommandsofSQLwithsuitableexamples
- Createtable
- Altertable
- DropTable
Objective:
Tounderstandthedifferentissues involvedinthedesignandimplementationofadatabasesystem
Tounderstandandusedatadefinitionlanguagetowritequeryfor adatabase
SQL(StructuredQuery Language):
StructuredQueryLanguageisadatabasecomputerlanguagedesignedformanaging data in relational database management systems (RDBMS), and originally basedupon Relational Algebra. Its scope includes data query and update, schema creation andmodification,anddataaccesscontrol.
SQL was one of the first languages for Edgar F. Codd’s relational model and became themostwidelyusedlanguagefor relationaldatabases.
- IBMdevelopedSQLinmidof1970’s.
- SQLusedbyIBM/DB2 andDS Database Systems.
- SQLadopted asstandard languageforRDBSbyASNIin1989.
DATATYPES:
- CHAR (Size): This data type is used to store character strings values offixed length.Thesizeinbracketsdeterminesthenumberofcharactersthecellcanhold.Themaximumnumberofcharacteris255characters.
- VARCHAR (Size) / VARCHAR2 (Size): This data type is used to store variable lengthalphanumericdata.Themaximumcharactercanholdis2000character.
- NUMBER (P, S): The NUMBER data type is used to store number (fixed or floatingpoint). Number of virtually any magnitude may be stored up to 38 digits of precision.Number as large as 9.99 * 10 124. The precision (p) determines the number of places tothe right of the decimal. If scale is omitted then the defaultis zero. If precision isomitted,valuesare stored withtheiroriginalprecisionuptothemaximumof38 digits.
- DATE: This data type is used to represent date and time. The standard format is DD-MM-YY as in 17-SEP-2009. To enter dates other than the standard format, use theappropriatefunctions.Datetimestoresdateinthe24-Hoursformat.Bydefaultthetime
inadatefieldis12:00:00am,ifnotimeportionisspecified.Thedefaultdateforadatefieldis thefirstdaythecurrentmonth.
- LONG: This data type is used to store variable length character strings containing up to2GB. Long data can be used to store arrays of binary data in ASCII format. LONGvalues cannotbe indexed, and thenormal character functions such as SUBSTR cannotbe applied.
- RAW: The RAW data type is used to store binary data, such as digitized picture orimage. Data loaded into columns of these data types are stored without any furtherconversion. RAW data type can have a maximum length of 255 bytes. LONG RAW datatype cancontainupto2GB.
SQLlanguageissub-dividedintoseverallanguageelements,including:
- Clauses, which are in some cases optional, constituent components of statements andqueries.
- Expressions,whichcanproduceeitherscalarvaluesortablesconsistingofcolumnsand
rowsof data.
- PredicateswhichspecifyconditionsthatcanbeevaluatedtoSQLthree-valuedlogic
(3VL)Booleantruthvaluesandwhichareusedtolimittheeffectsofstatementsand
queries,ortochangeprogramflow.
- Querieswhichretrievedatabased onspecificcriteria.
- Statementswhichmayhaveapersistenteffectonschemasanddata,orwhichmaycontroltransactions,programflow,connections,sessions,ordiagnostics.
- SQL statementsalsoincludethesemicolon(“;”)statementterminator.Thoughnot
requiredoneveryplatform,itisdefinedasastandard partoftheSQLgrammar.
- InsignificantwhitespaceisgenerallyignoredinSQLstatementsandqueries,makingit
easiertoformatSQLcodeforreadability.
TherearefivetypesofSQLstatements.Theyare:
- DATADEFINITION LANGUAGE(DDL)
- DATAMANIPULATIONLANGUAGE(DML)
- DATARETRIEVALLANGUAGE(DRL)
- TRANSATIONALCONTROLLANGUAGE (TCL)
- DATACONTROLLANGUAGE(DCL)
- DATA DEFINITION LANGUAGE (DDL):The Data Definition Language (DDL) isused to create and destroy databases and database objects. These commands will primarily beused by database administrators during the setup and removal phases of a database project.Let’s takea lookatthe structureandusage offourbasic DDLcommands:
- CREATE ALTER 3.DROP 4. RENAME
1. CREATE:
(a)CREATETABLE:Thisisusedtocreateanewrelation(table)
Syntax: CREATE TABLE
Example:
SQL>CREATETABLE Student(snoNUMBER(3), snameCHAR(10),classCHAR(5));
2. ALTER:
- ..ADD…:Thisisusedtoaddsomeextrafieldsintoexistingrelation.
Syntax:ALTERTABLErelation_nameADD(newfield_1data_type(size),newfield_2data_type(size),..);
Example:SQL>ALTERTABLEstdADD(AddressCHAR(10));
- ..MODIFY…:Thisisusedtochangethewidthaswellasdatatypeoffields ofexistingrelations.
Syntax:ALTERTABLErelation_nameMODIFY(field_1newdata_type(Size),field_2newdata_type(Size),…field_newdata_type(Size));
Example:SQL>ALTER TABLE student MODIFY(sname VARCHAR(10),classVARCHAR(5));
- .DROP….. Thisisusedtoremoveanyfieldofexistingrelations.
Syntax:ALTERTABLErelation_nameDROPCOLUMN(field_name);
Example:SQL>ALTERTABLEstudentDROPcolumn(sname);
- .RENAME…:Thisisusedtochangethenameof fieldsinexistingrelations.
Syntax:ALTERTABLErelation_nameRENAMECOLUMN(OLDfield_name)to(NEW field_name);
Example:SQL>ALTER TABLE studentRENAMECOLUMNsnametostu_name;
- DROPTABLE:Itpermanentlydeletestherecords inthetable.
Syntax:DROPTABLErelation_name;
Example:SQL>DROP TABLEstd;
- RENAME: Syntax: RENAME TABLE old_relation_name TO new_relation_name;Example:SQL>RENAMETABLEstdTOstd1;
LABPRACTICEASSIGNMENT:
- CreateatableEMPLOYEEwithfollowingschema:
(Emp_no,E_name,E_address,E_ph_no,Dept_no,Dept_name,Job_id,Salary)
- Addanewcolumn;HIREDATEtotheexistingrelation.
- Changethenameofcolumn/fieldEmp_notoE_no.
- Modifythecolumnwidthofthejob field ofemptable
ExperimentNo:2
Title :ImplementationofDMLcommandsofSQLwithsuitable examples
- Inserttable
- Updatetable
- DeleteTable
Objective:
Tounderstandthedifferentissuesinvolvedinthedesignandimplementationofadatabasesystem
Tounderstandandusedatamanipulationlanguagetoquery,update,and manageadatabase
Theory:
DATAMANIPULATIONLANGUAGE(DML):TheDataManipulationLanguage(DML) is used to retrieve, insert and modify database information. These commands will beused by all database users during the routine operation of the database. Let’s take a brief lookatthebasicDMLcommands:
1.INSERT 2.UPDATE 3. DELETE
- INSERTINTO: ThesearethreetypeofINSERTINTOquerieswhichareas
a) Insertingasinglerecord
Syntax:INSERTINTO
Example:SQL>INSERTINTOstudent(sno,sname,class,address)VALUES(1,’Ravi’,’M.Tech’,’Palakol’);
b) Insertingasinglerecord
Syntax:INSERTINTO
Example:SQL>INSERTINTOstudentVALUES(1,’Ravi’,’M.Tech’,’Palakol’);
c) Insertingallrecordsfromanotherrelation
Syntax:INSERTINTOrelation_name_1SELECTField_1,field_2,field_nFROMrelation_name_2WHEREfield_x=data;
Example:SQL>INSERTINTOstdSELECTsno,snameFROMstudentWHEREname=‘Ramu‘;
d) Insertingmultiplerecords
Syntax:INSERTINTOrelation_namefield_1,field_2,……… field_n)VALUES
(&data_1,&data_2,……. &data_n);
Example:SQL>INSERTINTOstudent(sno,sname,class,address)VALUES(&sno,’&sname’,’&class’,’&address’);
Entervalueforsno:101Entervaluefor name:RaviEnter value for class: M.TechEntervalueforname:Palakol
- UPDATE-SET-WHERE: Thisisusedtoupdatethecontentofarecord inarelation.
Syntax:SQL>UPDATErelationnameSETField_name1=data,field_name2=data,WHEREfield_name=data;
Example: SQL>UPDATEstudentSETsname=‘kumar’WHERE sno=1;
- DELETE-FROM:Thisisusedtodeletealltherecordsofarelationbutitwillretainthestructureofthatrelation.
- DELETE-FROM:Thisisusedtodeletealltherecordsofrelation.
Syntax: SQL>DELETEFROMrelation_name;
Example: SQL>DELETEFROMstd;
- DELETE-FROM-WHERE:
Syntax: SQL>DELETE FROMrelation_nameWHEREcondition;
Example: SQL>DELETEFROMstudentWHERE sno=2;
- TRUNCATE:Butstructurewillnotberemoved.
DifferencebetweenTruncate&Delete:–
- By using truncate command data will be removed permanently & will not get backwhere as by using delete command data will be removed temporally & get back byusingrollbackcommand.
- By using delete command data will be removed based on the condition where as byusingtruncate commandthereisnocondition.
- TruncateisaDDLcommand &delete isaDMLcommand.
Syntax: TRUNCATETABLE
Example TRUNCATETABLEstudent;
· ToRetrievedatafromoneormoretables.
- SELECTFROM:Todisplayallfields forallrecords.Syntax: SELECT*FROMrelation_name;Example: SQL>select*fromdept;
DEPTNO DNAME LOC
——– ———– ———-
10 ACCOUNTING NEWYORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
- SELECTFROM:Syntax: SELECT a set of fields FROM relation_name;Example: SQL>selectdeptno,dnamefromdept;
DEPTNO DNAME
10 ACCOUNTING
20 RESEARCH
30 SALES
- SELECT-FROM-WHERE:
Syntax: SELECTasetoffieldsFROMrelation_nameWHEREcondition;
Example: SQL> select * FROM dept WHERE deptno<=20;DEPTNO DNAME LOC ------ ----------- ------------ 10 ACCOUNTING NEWYORK 20 RESEARCH DALLAS
LABPRACTICEASSIGNMENT:
CreateatableEMPLOYEE with followingschema:
(Emp_no,E_name,E_address,E_ph_no,Dept_no,Dept_name,Job_id,Salary)
WriteSQLqueriesforfollowingquestion:
- Displaytherecordofeachemployeewhoworksin departmentD10.
- UpdatethecityofEmp_no-12withcurrentcityas Nagpur.
- Deletetheemail_id ofemployeeJames.
- Displaythecomplete recordofemployeesworkinginSALES Department.
ExperimentNo:3
Title:Implementationofdifferenttypesoffunctionswithsuitableexamples.
- NumberFunction
- AggregateFunction
- CharacterFunction
- ConversionFunction
- DateFunction
Objective:
NUMBERFUNCTION:
Abs(n):Selectabs(-15)fromdual;Exp(n): Selectexp(4)fromdual;Power(m,n):Select power(4,2)fromdual;Mod(m,n): Selectmod(10,3)fromdual;
Round(m,n): Select round(100.256,2) from dual;Trunc(m,n): ;Select trunc(100.256,2) from dual;Sqrt(m,n);Selectsqrt(16)fromdual;
Developaggregateplanstrategiestoassistwithsummarizationofseveraldataentries.
Aggregative operators: In addition to simply retrieving data, we often want to perform somecomputationorsummarization.SQLallowstheuseof arithmeticexpressions.Wenowconsider a powerful class of constructs for computing aggregate values such as MIN andSUM.
- Count: COUNT following by a column name returns the count of tuple in that column. IfDISTINCT keyword is used then it will return only the count of unique tuple in the column.Otherwise, it will return count of all the tuples (including duplicates) count (*) indicates allthetuples ofthecolumn.
Syntax:COUNT(Columnname)
Example:SELECTCOUNT(Sal)FROMemp;
- SUM:SUMfollowedbyacolumnname returnsthe sumofallthevaluesinthatcolumn.
Syntax:SUM(Columnname)
Example:SELECTSUM(Sal)Fromemp;
- AVG:
Syntax:AVG(n1,n2…)
Example:SelectAVG(10,15,30)FROMDUAL;
- MAX:
Syntax:MAX(Columnname)
Example:SELECTMAX(Sal)FROMemp;
SQL>select deptno,max(sal)fromempgroupbydeptno;
DEPTNO MAX(SAL)
10 | 5000 | |
20 | 3000 | |
30 | 2850 |
SQL>select deptno, max(sal)fromempgroupbydeptnohavingmax(sal)<3000;DEPTNO MAX(SAL)
30 2850
- MIN:
Syntax:MIN(Columnname)
Example:SELECTMIN(Sal) FROMemp;
SQL>selectdeptno,min(sal)fromempgroupbydeptnohavingmin(sal)>1000;DEPTNOMIN (SAL)
10 1300
CHARACTERFUNCTION:
initcap(char) : select initcap(“hello”) from dual;lower(char):select lower(‘HELLO’)fromdual;upper(char) :selectupper(‘hello’)fromdual;
ltrim(char,[set]):selectltrim(‘cseit’,‘cse’)fromdual;rtrim(char,[set]):selectrtrim(‘cseit’, ‘it’)fromdual;
replace(char,search):select replace(‘jackandjue’,‘j’,‘bl’)fromdual;
CONVERSIONFUNCTIONS:
To_char: TO_CHAR (number) converts n to a value of VARCHAR2 data type, using theoptional number format fmt. The value n can be of type NUMBER, BINARY_FLOAT, orBINARY_DOUBLE.
SQL>selectto_char(65,’RN’)fromdual;LXV
To_number:TO_NUMBERconvertsexprtoavalueofNUMBERdatatype.
SQL>Selectto_number(‘1234.64’)fromDual;1234.64
To_date:TO_DATE converts char of CHAR, VARCHAR2, NCHAR, orNVARCHAR2datatypetoavalueofDATEdatatype.
SQL>SELECTTO_DATE(‘January15,1989, 11:00A.M.’)FROMDUAL;TO_DATE
15-JAN-89
STRINGFUNCTIONS:
Concat:CONCATreturnschar1concatenatedwithchar2.Bothchar1 andchar2canbeanyofthedatatypes
SQL>SELECT CONCAT(‘ORACLE’,’CORPORATION’)FROM DUAL;ORACLECORPORATION
Lpad:LPADreturns expr1,left-paddedtolengthncharacterswiththesequenceofcharacters inexpr2.
SQL>SELECTLPAD(‘ORACLE’,15,’*’)FROMDUAL;
*********ORACLE
Rpad:RPADreturnsexpr1, right-paddedtolengthncharacterswithexpr2,replicatedasmanytimes as necessary.
SQL>SELECTRPAD(‘ORACLE’,15,’*’)FROMDUAL;
ORACLE*********
Ltrim:Returnsacharacterexpressionafterremoving leadingblanks.SQL>SELECTLTRIM(‘SSMITHSS’,’S’)FROMDUAL;
MITHSS
Rtrim:ReturnsacharacterstringaftertruncatingalltrailingblanksSQL>SELECTRTRIM(‘SSMITHSS’,’S’)FROMDUAL;
SSMITH
Lower:Returnsacharacterexpressionafterconvertinguppercasecharacterdatatolowercase.
SQL>SELECTLOWER(‘DBMS’)FROMDUAL;
dbms
Upper: Returns a character expression with lowercase character data converted to uppercaseSQL>SELECTUPPER(‘dbms’)FROMDUAL;
DBMS
Length:Returnsthenumberofcharacters,ratherthanthenumberofbytes,ofthegivenstringexpression,excludingtrailingblanks.
SQL>SELECTLENGTH(‘DATABASE’)FROMDUAL;8
Substr:Returnspartofacharacter,binary,text,orimageexpression.
SQL>SELECTSUBSTR(‘ABCDEFGHIJ’3,4)FROMDUAL;CDEF
Instr:TheINSTRfunctionssearchstring forsubstring. Thefunctionreturnsaninteger
indicatingthepositionofthecharacterinstringthatisthefirstcharacterofthisoccurrence.SQL>SELECT INSTR(‘CORPORATE FLOOR’,’OR’,3,2)FROMDUAL;
14
DATEFUNCTIONS:
Sysdate:
SQL>SELECTSYSDATEFROMDUAL;29-DEC-08
next_day:
SQL>SELECTNEXT_DAY(SYSDATE,’WED’)FROMDUAL;05-JAN-09
add_months:
SQL>SELECTADD_MONTHS(SYSDATE,2)FROMDUAL;28-FEB-09
last_day:
SQL>SELECTLAST_DAY(SYSDATE)FROMDUAL;31-DEC-08
months_between:
SQL>SELECTMONTHS_BETWEEN(SYSDATE,HIREDATE)FROMEMP;4
Least:
SQL>SELECTLEAST(’10-JAN-07′,’12-OCT-07′)FROM DUAL;10-JAN-07
Greatest:
SQL>SELECT GREATEST(’10-JAN-07′,’12-OCT-07′)FROM DUAL;10-JAN-07
Trunc:
SQL>SELECTTRUNC(SYSDATE,’DAY’)FROMDUAL;28-DEC-08
Round:
SQL>SELECT ROUND(SYSDATE,’DAY’)FROM DUAL;28-DEC-08
to_char:
SQL>selectto_char(sysdate,”dd\mm\yy”)fromdual;24-mar-05.
to_date:
SQL> select to date (sysdate, “dd\mm\yy”) from dual;24-mar-o5.
LABPRACTICEASSIGNMENT:
CreateatableEMPLOYEE with followingschema:
(Emp_no,E_name,E_address,E_ph_no,Dept_no,Dept_name,Job_id,Designation,Salary)
WriteSQLstatementsforthefollowingquery.
- ListtheE_no,E_name,Salaryofallemployees workingforMANAGER.
- .
- Listtheemployees alongwiththeirExperienceandDailySalary.
- Listtheemployeeswhoareeither‘CLERK’or‘ANALYST’.
- Listtheemployeeswhojoinedon1-MAY-81, 3-DEC-81,17-DEC-81,19-JAN-80.
- Listtheemployees whoareworkingfortheDeptno10or20.
- ListtheEnamesthosearestartingwith‘S’ .
- Dislaythenameas wellasthefirstfivecharactersofname(s)starting with‘H’
- Listalltheempsexcept‘PRESIDENT’&‘MGR”inascorder ofSalaries.
ExperimentNo:4
Title :ImplementationofdifferenttypesofoperatorsinSQL.
- Arithmetic Operator
- LogicalOperator
- ComparisionOperator
- SpecialOperator
- SetOperator
Objective:
To learndifferenttypes ofoperator.
Theory:
ARIHMETICOPERATORS:
(+):Addition-Addsvaluesoneitherside oftheoperator.
(-):Subtraction- Subtractsrighthandoperandfromlefthandoperand.(*):Multiplication – Multiplies values on either side of the operator .(/):Division-Divideslefthand operand byrighthand operand .
(^):Power-raisetopowerof.
(%):Modulus- Divideslefthandoperandbyrighthandoperandand returnsremainder.
LOGICALOPERATORS:
AND:TheANDoperatorallowstheexistenceofmultipleconditionsinanSQLstatement’sWHEREclause.
OR:TheORoperatorisusedtocombinemultipleconditionsinanSQLstatement’sWHEREclause.
NOT:TheNOToperatorreversesthemeaningofthelogicaloperatorwithwhichitisused.Eg:NOTEXISTS,NOTBETWEEN,NOTIN,etc.Thisisa negateoperator.
COMPARISIONOPERATORS:
(=):Checksifthevaluesoftwooperandsare equalornot,ifyesthenconditionbecomestrue.
(!=):Checksifthevaluesoftwooperandsareequalornot,ifvaluesarenotequalthenconditionbecomes true.
(<>):Checksifthevaluesoftwooperandsareequalornot,ifvaluesarenotequalthenconditionbecomes true.
(>):Checksifthevalueofleftoperandisgreaterthanthevalueofrightoperand,ifyesthenconditionbecomes true
(<):Checksifthevalueofleftoperandislessthanthevalueofrightoperand,ifyesthenconditionbecomes true.
(>=):Checksifthevalueofleftoperandisgreaterthanorequaltothe valueofrightoperand,ifyes thenconditionbecomes true.
(<=):Checksifthevalueofleftoperandislessthan orequaltothevalueofrightoperand,ifyesthenconditionbecomes true.
SPECIALOPERATOR:
BETWEEN:TheBETWEENoperatorisusedtosearchforvaluesthatarewithinasetofvalues,giventheminimumvalueandthemaximumvalue.
ISNULL:TheNULLoperatorisusedtocompareavaluewithaNULLattributevalue.
ALL:TheALLoperator isusedtocomparea valuetoallvaluesinanothervalueset
ANY:TheANYoperatorisusedtocompareavaluetoanyapplicablevalueinthelistaccordingtothecondition.
LIKE:TheLIKEoperatorisusedtocompareavaluetosimilarvaluesusingwildcardoperators.Itallowstousepercentsign(%)andunderscore(_)tomatchagivenstringpattern.
IN: The IN operator is used to compare a value to a list of literal values that have beenspecified.
EXIST:TheEXISTSoperatorisusedtosearchforthepresenceofarowinaspecifiedtablethatmeets certaincriteria.
SETOPERATORS:
TheSetoperatorcombinestheresultof2queriesintoasingleresult.The followingaretheoperators:
- Union
- Unionall
- Intersect
- Minus
Union:Returns alldistinctrowsselectedbyboththequeries
Unionall:Returns allrows selectedbyeither queryincluding theduplicates.
Intersect:Returns rows selectedthatarecommontobothqueries.
Minus:Returnsalldistinct rowsselected bythefirstqueryand arenotbythesecond
LABPRACTICEASSIGNMENT:
- Display allthe deptnumbers availablewiththedeptandemptablesavoiding duplicates.
- Displayallthedept numbersavailableinempandnotindepttablesandviceversa.
ExperimentNo:5
Title:ImplementationofdifferenttypesofJoins
- InnerJoin
- OuterJoin
- .etc
Objective:
Toimplementdifferenttypesofjoins
Theory:
TheSQLJoinsclauseisusedtocombinerecordsfromtwoormoretablesina
database. A JOIN isa means for combining fields from two tables by using values commonto each.The join is actually performed by the ‘where’ clause which combines specified rowsoftables.
Syntax:
SELECTcolumn1,column2,column3…FROMtable_name1,table_name2
WHEREtable_name1.columnname=table_name2.columnname;
Types ofJoins:
- SimpleJoin
- SelfJoin
- OuterJoin
SimpleJoin:
Itisthemostcommontypeofjoin.Itretrievestherowsfrom2tableshavingacommoncolumnandisfurtherclassifiedinto
Equi-join:
Ajoin,whichisbasedonequalities,iscalledequi-join.
Example:
Select *fromitem,custwhereitem.id=cust.id;
In the above statement, item-id = cust-id performs the join statement. It retrieves rowsfromboththe tablesprovidedtheybothhave the sameidasspecifiedbythewhere clause.Sincethewhereclauseusesthecomparisonoperator(=)toperformajoin,itissaidto be
equijoin.Itcombinesthematchedrowsoftables.Itcanbeusedasfollows:
- To updaterecords inthetargettable.
NonEqui-join:
Itspecifiestherelationshipbetweencolumnsbelongingtodifferenttablesbymakinguseofrelational operatorsotherthan’=’.
Example:
Select*fromitem,custwhereitem.id Joiningofatabletoitselfisknown asself-join.Itjoinsonerowinatabletoanother. It cancompareeachrowofthetabletoitselfand alsowithotherrowsofthesametable. Example: select*fromempx,empywherex.salary>=(selectavg(salary)fromx.empwherex.deptno=y.deptno); Itextendstheresultofasimplejoin.Anouter joinreturnsalltherowsreturnedbysimplejoin as well as those rows from one table that do not match any row from the table. Thesymbol(+)represents outerjoin. Considerthefollowingschema:Sailors (sid, sname, rating, age)Boats (bid, bname, color)Reserves(sid,bid,day(date)) Title:Study&Implementationof Tolearntheconceptofgroup functions Syntax: SELECTFROMGROUPBY; Example:SQL>SELECTEMPNO,SUM(SALARY) FROMEMPGROUPBYEMPNO; GROUP BY-HAVING : The HAVING clause was added to SQL because the WHEREkeywordcouldnotbeusedwithaggregatefunctions. TheHAVINGclausemustfollowtheGROUP BYclauseinaqueryandmustalsoprecedetheORDERBYclauseifused. Syntax: SELECT column_name, aggregate_function(column_name) FROM table_nameWHEREcolumn_nameoperatorvalue GROUPBYcolumn_name HAVINGaggregate_function(column_name) operatorvalue; Example:SELECTEmployees.LastName,COUNT(Orders.OrderID)ASNumberOfOrdersFROM(Orders INNERJOINEmployees ONOrders.EmployeeID=Employees.EmployeeID)GROUPBYLastNameHAVINGCOUNT(Orders.OrderID)>10; JOIN using GROUP BY: This query is used to display a set of fields from two relations bymatching a common field in them and also group the corresponding records for each andeveryvalueofa specifiedkey(s)whiledisplaying. Syntax: SELECT SQL>SELECTempno,SUM(SALARY)FROMemp,deptWHEREemp.deptno=20GROUP BY empno; Syntax: SELECTFROMORDER BY; Example:SQL>SELECTempno,ename,jobFROMempORDERBYjob; JOINusingORDERBY:Thisquery isusedtodisplay asetoffieldsfromtworelationsbymatching acommonfieldintheminanorderedmannerbasedonsomefields. Syntax:SELECT Example:SQL>SELECTempno,ename,job,dnameFROMemp,deptWHEREemp.deptno= 20ORDERBY job; fromtables. Anindexprovidestwobenefits: Syntax: CREATEINDEXon(attrib1,attrib2….attribn); Example: CREATE INDEXid1 onemp(empno,dept_no); Createarelationandimplement thefollowingqueries. Title:Study&Implementationof SUBQUERIES: The query within another is known as a sub query. A statementcontainingsubqueryiscalledparentstatement.Therowsreturnedbysub queryare usedbytheparentstatementorinotherwordsAsubqueryisaSELECTstatementthatisembeddedin aclauseofanotherSELECT statement Youcanplacethe subqueryinanumberofSQLclauses: Subqueriescanalsoreturnmorethanonevalue.Suchresultsshouldbemadeusealongwiththeoperators inandany. Heremorethanonesubqueryisused.Thesemultiplesubqueriesarecombinedbymeans of‘and’&‘or’keywords. AsubqueryisevaluatedoncefortheentireparentstatementwhereasacorrelatedSubqueryis evaluatedonceperrowprocessedbytheparentstatement. VIEW:InSQL,a viewisavirtualtable basedontheresult-setofanSQLstatement. Aviewcontainsrowsandcolumns,justlikearealtable.Thefieldsinaviewarefieldsfromoneormorerealtablesinthedatabase. YoucanaddSQLfunctions,WHERE,andJOINstatementstoaviewandpresentthedataasifthedatawerecomingfromonesingletable. Aviewisavirtualtable,whichconsistsofasetofcolumnsfromoneormoretables.Itissimilartoatablebutitdoesnotstorein thedatabase.Viewisaquerystoredasanobject. Syntax: CREATEVIEWASSELECTFROMrelation_nameWHERE(Condition) SQL>CREATEVIEWemployeeASSELECTempno,ename,jobFROMEMPWHEREjob=‘clerk’; SQL> Viewcreated. CREATEVIEW[Current Product List]ASSELECTProductID,ProductName FROMProducts WHEREDiscontinued=No; UPDATING AVIEW:Aviewcanupdated byusingthefollowingsyntax: Syntax:CREATEORREPLACE VIEWview_nameASSELECTcolumn_name(s) FROM table_nameWHEREcondition DROPPINGA VIEW:AviewcandeletedwiththeDROP VIEWcommand. Syntax:DROPVIEW; Considerthefollowingschema:Sailors (sid, sname, rating, age)Boats (bid, bname, color)Reserves(sid,bid,day(date)) Title : •Study&Implementation ofdifferenttypes ofconstraints Topracticeand implement constraints Theory: Constraints are used to specify rules for the data in a table. If there is any violation betweenthe constraint and the data action, the action is aborted by the constraint. It can be specifiedwhen the table is created (using CREATE TABLE statement) or after the table is created(usingALTERTABLEstatement). CREATETABLETable_Name(column_namedata_type(size) NOTNULL, ); CREATETABLEstudent(snoNUMBER(3)NOTNULL,nameCHAR(10)); CREATETABLETable_Name(column_name data_type(size)UNIQUE,….); CREATETABLEstudent(snoNUMBER(3)UNIQUE,nameCHAR(10)); CREATE TABLE Table_Name(column_name data_type(size) CHECK(logicalexpression),….); CREATE TABLE student (sno NUMBER (3), name CHAR(10),classCHAR(5),CHECK(classIN(‘CSE’,’CAD’,’VLSI’)); CREATETABLETable_Name(column_namedata_type(size) PRIMARYKEY, ….); CREATE TABLE faculty (fcode NUMBER(3) PRIMARY KEY, fname CHAR(10)); Syntax:CREATETABLETable_Name(column_namedata_type(size) FOREIGNKEY(column_name)REFERENCEStable_name); CREATETABLEsubject(scodeNUMBER(3)PRIMARYKEY,subname CHAR(10),fcodeNUMBER(3),FOREIGNKEY(fcode)REFERENCEfaculty); Syntax: ALTERTABLETable_NameADDPRIMARYKEY(column_name); Example: ALTER TABLE student ADD PRIMARY KEY (sno);(Or) Syntax: ALTERTABLEtable_nameADDCONSTRAINTconstraint_name PRIMARYKEY(colname) Example: ALTERTABLEstudent ADDCONSTRAINTSN PRIMARYKEY(SNO) Syntax: ALTERTABLETable_NameDROPconstraint_name; Example: ALTERTABLE student DROPPRIMARYKEY; (or) Syntax: ALTERTABLEstudentDROPCONSTRAINTconstraint_name; Example: ALTERTABLEstudentDROPCONSTRAINTSN; CREATETABLETable_Name(col_name1,col_name2,col_name3DEFAULT‘’); Example: CREATE TABLE student(sno NUMBER(3) UNIQUE,name CHAR(10),addressVARCHAR(20)DEFAULT‘Aurangabad’); EMPNONUMBER(6) ENAMEVARCHAR2(20) JOBVARCHAR2 (10) DEPTNONUMBER(3) SALNUMBER(7,2) AllowNULLforallcolumnsexceptenameandjob. Tounderstandtheconceptofadministrativecommands A transaction is a logical unit of work. All changes made to the database can bereferred to as a transaction. Transaction changes can be made permanent to the database onlyiftheyarecommittedatransactionbeginswithanexecutableSQLstatement&endsexplicitlywitheitherrollbackorcommitstatement. Syntax:SQL>COMMIT; Example:SQL>COMMIT; Syntax: SQL>SAVEPOINTID; Example: SQL>SAVE POINTxyz; backatransactiontoasavepointsothattheSQLstatementsafterthesavepointareroleback. Syntax: ROLLBACK(currenttransactioncanberoleback)ROLLBACKtosavepointID; Example: SQL>ROLLBACK; SQL>ROLLBACKTO SAVEPOINTxyz; Title:CreatingDatabase/TableSpace Tounderstandtheconceptofadministrativecommands DATABASE is collection of coherent data.Tocreate databasewehave: Syntax: CREATEDATABASEExample: CREATEDATABASEmy_db; The oracle database consists of one or more logical storage units called tablespaces. Eachtablespace in an Oracle database consists of one or more files called datafiles, which arephysicalstructuresthatconfirmtotheoperatingsysteminwhichOracleis running. Syntax: CREATE DATAFILE’C:\oraclexe\app\oracle\product\10.2.0\server\ TheDBAcreatesuserbyexecutingCREATEUSERstatement. Theuserissomeonewhoconnectstothedatabaseifenoughprivilegeisgranted. SQL>CREATEUSER — (nameofusertobe created) IDENTIFIEDBY– (specifiesthattheuser must loginwiththispassword) SQL> usercreated Eg:createuserJamesidentifiedbybob; (Theuserdoesnothaveprivilegeatthistime,ithastobegranted.Theseprivilegesdeterminewhatusercandoatdatabaselevel.) AprivilegeisarighttoexecuteanSQLstatementortoaccessanother user’sobject.InOracle,therearetwotypesofprivileges Eg:CreateSession,Create Table,Createuser etc.. (Aftercreatingtheuser,DBAgrantspecificsystemprivilegesto user) TheDBAusestheGRANT statementtoallocatesystemprivilegestootheruser. SQL> GRANT privilege [privilege….…]TO USER; SQL>Grantsucceeded Eg:Grantcreatesession,createtable, createviewtoJames; Objectprivilegesvaryfromobjecttoobject.Anowner hasallprivilegeorspecificprivilegesonobject. SQL>GRANTobject_priv[(column)]ON object TO user; SQL>GRANT select, insert ON emp TO James;SQL>GRANTselect,update(e_name,e_address) ONempTOJames; TheDBAcreatesanaccountandinitializesapasswordfor everyuser.YoucanchangepasswordbyusingALTERUSERstatement. Alter USER IDENTIFIEDBY Eg: ALTER USER JamesIDENTIFIEDBYsam REVOKEstatementisusedtoremoveprivilegesgrantedtootherusers.Theprivilegesyouspecifyarerevokedfromtheusers. REVOKE [privilege.. …]ONobject FROMuser FROMJames A role is a named group of related privileges that can be granted to user.In other words, roleisapredefined collectionofprevileges thataregroupedtogether,thusprivilegesareeasier toassignuser. SQL>Createrolecustom; SQL> Grant create table, create view TO custom;SQL>Grantselect,insertONempTOcustom; Eg:GrantcustomtoJames,Steve; TheDCLlanguage isusedfor controllingtheaccesstothetableandhencesecuring thedatabase.DCLisusedtoprovidecertainprivileges toaparticularuser.Privileges arerights tobeallocated. Theprivilegecommandsarenamely,GrantandRevoke Grant Grant|Allon *Commit *Rollback*savepoint Asinglerowfunctionorscalarfunctionreturnsonlyonevalueforeveryrowqueriesintable.Singlerowfunctioncanappearinaselectcommandandcanalsobeincludedinawhereclause.Thesinglerowfunctioncanbebroadlyclassifiedas, *CharacterFunction initcap(char);lower (char);upper(char);ltrim(char,[set]);rtrim(char,[set]); Aviewisalogicaltablebasedonatableoranotherview.Aviewcontainsnodataofitsownbutis likeawindowthroughwhichdatafromtablescanbeviewedorchanged. 1)Union2)Intersectoperation3)Theexcept operation(minus) AsubQueriesisaselect-from-whereexpressionthatisnestedwithinanotherQueries. A common use of sub Queries is to perform tests for set membership, make setcomparisonsand determinesetcardinalityOuterJoin:
LABPRACTICEASSIGNMENT:
ExperimentNo:6
Objective:
Theory:
Example:
LABPRACTICEASSIGNMENT:
ExperimentNo:7
Objective:
Theory:
Types
2. Multiplequeries
3. Correlatedsubquery
Example:
Example:
LABPRACTICEASSIGNMENT:
Writesubquerystatementforthefollowingqueries.
ExperimentNo:8
Objective:
CONSTRAINTS:
Syntax:
Example:
Syntax:
Example:
Syntax:
Example:
Syntax:
Example:
Example:
Definingintegrityconstraintsinthealtertable command:
Droppingintegrityconstraintsinthealtertablecommand:
Syntax:
LABPRACTICEASSIGNMENT:
ExperimentNo:9
Title:
Objective:
Theory:
LABPRACTICEASSIGNMENT:
ExperimentNo:10
Objective:
Theory:
TABLESPACE:
Syntax:
PRIVILEGES:
GRANT:
Syntax:
CHANGEPASSWORD:
Syntax:
REVOKE:
Syntax:
Eg:
ROLE:
LABPRACTICEASSIGNMENT:
VIVA-VOCE
Course Code: LBC0304 | Course Title: Discrete Mathematics (3 Credits) |
Course Objectives: – Ø Understand fundamental concepts in sets, relations, functions, logic, and graph theory.Ø Apply discrete mathematical techniques to solve basic problems in computer science.Ø Gain foundational knowledge to pursue further studies in computer science. |
Course Contents
Unit | Unit Description | Learning Outcome |
1 | Introduction to Sets and Relations: Basics of set theory, types of sets, Venn diagrams, operations on sets, relations – definition, types of relations, properties of relations. | This module has been designed as per BTL 1. |
2 | Functions: Definition of functions, types of functions (one-to-one, onto, bijective), operations on functions, inverse functions, practical examples. | This module has been designed as per BTL 2. |
3 | Basic Counting Principles: Counting principles, basic permutation and combination, simple applications of counting principles in problem-solving. | This module has been designed as per BTL 2 & 3. |
4 | Logic and Propositional Calculus: Introduction to logic, statements and propositions, logical connectives, truth tables, tautology, contradiction, logical equivalence. | This module has been designed as per BTL 2 & 3. |
5 | Predicate Logic: Basics of predicate logic, quantifiers, well-formed formulas, simple examples and applications of predicate logic. | This module has been designed as per BTL 2 & 3. |
6 | Introduction to Graph Theory: Basics of graph theory, types of graphs, representation of graphs, simple examples of graph problems. | This module has been designed as per BTL 2 & 3. |
7 | Trees in Graph Theory: Definition and properties of trees, binary trees, spanning trees, applications of trees in computer science. | This module has been designed as per BTL 3 & 4. |
8 | Introduction to Algebraic Structures: Basics of algebraic structures, introduction to groups, subgroups, simple properties of groups with examples. | This module has been designed as per BTL 3 & 4. |
9 | Recurrence Relations: Introduction to recurrence relations, basic methods of solving linear recurrence relations, simple examples. | This module has been designed as per BTL 3 & 4. |
10 | Applications of Discrete Mathematics in Computer Science: Simple applications of discrete mathematics in algorithm analysis, cryptography, network design, and other areas of computer science. | This module has been designed as per BTL 4 & 5. |
Textbooks:
Reference Books:
|
(Bloom’s Taxonomy: BT level 1: Remembering; BT level 2: Understanding; BT level 3: Applying; BT level 4: Analyzing; BT level 5: Evaluating; BT level 6: Creating)
(Bloom’s Taxonomy: BT level 1: Remembering; BT level 2: Understanding; BT level 3: Applying; BT level 4: Analyzing; BT level 5: Evaluating; BT level 6: Creating)
Course Code: LBC0303 | Course Title: Python Programming (3 Credits) | |
Course Objectives: –
Ø Understand the basics of Python programming and apply them to solve simple problems. Ø Implement control structures and functions to manage the flow of programs. Ø Utilize Python data structures effectively. Ø Handle files and exceptions proficiently in Python. Ø Apply object-oriented programming principles to Python programming. |
||
Unit | Unit Description | Learning Outcome |
1 | Introduction to Python: Overview of Python programming, history, features, and setting up the Python environment. Basic syntax, interactive mode, script mode, and basic data types. | This module has been designed as per BTL 1. |
2 | Control Structures and Functions: Conditional statements, loops (for, while), break, continue, pass statements, and functions – defining, calling, arguments, recursion, and lambda functions. | This module has been designed as per BTL 2. |
3 | Data Structures in Python: Lists, tuples, sets, dictionaries – operations, methods, and applications. List comprehensions and dictionary comprehensions. | This module has been designed as per BTL 2 & 3. |
4 | Modules and Packages: Importing modules, exploring standard libraries, creating and using packages, and virtual environments. | This module has been designed as per BTL 3. |
5 | File Handling: Reading and writing files, working with CSV files, handling file exceptions, and using context managers. | This module has been designed as per BTL 3 & 4. |
6 | Error and Exception Handling: Understanding exceptions, try, except, else, and finally blocks, raising exceptions, and custom exceptions. | This module has been designed as per BTL 3 & 4. |
7 | Object-Oriented Programming: Classes, objects, inheritance, polymorphism, encapsulation, and abstraction. Working with constructors and destructors. | This module has been designed as per BTL 4. |
8 | Advanced Data Structures: Introduction to stacks, queues, linked lists, and their implementation in Python. | This module has been designed as per BTL 4 & 5. |
9 | Database Interaction: Connecting to databases using Python, executing SQL queries, and handling transactions. | This module has been designed as per BTL 3 & 4. |
10 | Introduction to GUI Programming: Basics of Tkinter, creating simple GUIs, and handling events. | This module has been designed as per BTL 3. |
Textbooks:
Reference Books:
|
Bachelor of Computer Applications
BCA: – LBC0322
Python Programming Practical
CENTRE FOR ONLINE AND DISTANCE EDUCATION (CODE)
Mody University of Science and Technology
Lakshmangarh
Syllabus
Program | Bachelor of Computer Applications |
Semester | III |
CourseTitle | Python Programming Practical |
Course Code | LBC0322 |
CourseCredits | 02 |
Course Type | Core Practical Course |
- Course Summary
This course provides an introduction to programming and the Python language. Students are introduced to core programming concepts like data structures, conditionals, loops, variables, and functions. This course includes an overview of the various tools available for writing and running Python, and gets students coding quickly. It also provides hands-on coding exercises using commonly used data structures, writing custom functions, and reading and writing to files.
This manual typically contains practical/Lab Sessions related to Programming with Python covering various aspects in order to enhance subject understanding. Students are advised to thoroughly go through this manual rather than only topic mentioned in the syllabus as practical aspects are the key to understanding and conceptual visualization of theoretical aspects covered in the books.
Also, this course is designed to review the concepts of Searching and Sorting techniques, studied in previous semester. Good Luck for your Enjoyable Laboratory Sessions.
Key Objectives
- To be able to introduce core programming basics and various Operators of Python programming language. Learn basic programming constructs –data types, decision structures, control structures in python
- To demonstrate about Python data structures like Lists, Tuples, Sets and dictionaries. Learn to use in-built data structures in python – Lists, Tuples, Dictionary and File handling.
- To understand about Functions, Modules and Regular Expressions in Python Programming.
- List of Experiments:
S.NO | Name of the Experiment |
1 | c) a) Demonstrate the working of following functions in Python.
i) id( ) ii) type( ) iii) range( ) b) Write a program to read Employee data from the keyboard and print that data. |
2 | b) a) Demonstrate the following Conditional statements in Python with suitable examples.
i) if statement ii) if else statement iii) if – elif – else statement b) Write a Python program to print the following Pattern: * * * * * * * * * * * * * * * c) Write a Python program to display the sum of first ‘n’ numbers using while loop. |
3 | a) Demonstrate the different ways of creating list objects with suitable example programs.
b) Demonstrate the following functions/methods which operates on lists in Python with suitable examples: i) list( ) ii) len( ) iii) count( ) iv) index ( ) v) append( ) vi) insert( ) vii) extend() viii) remove( ) ix) pop( ) x) reverse( ) xi) sort( ) xii) copy( ) xiii) clear( ) c) Demonstrate the following with suitable example programs: i) List slicing ii) List Comprehensions Note: perform all the above operations on tuple, set and dictionary. |
4 | a) Write a Python program to find the maximum number of a list of numbers.
b) Write a Python program to check whether a number is prime or not. |
5 | a) Write a function to check whether the given number is even or odd.
b) Write a function to find factorial of a given number. c) Write a Python program to return multiple values at a time using a return statement. |
6 | a) Write a program to create a lambda function to find square of given number.
b) Write a program to create a Lambda function to find sum of 2 given numbers.c) Write a program to create a Lambda Function to find biggest of given values. d) Program to filter only even numbers from the list by using filter() function. e) For every element present in the list, perform double and generate new list of doubles. |
7 | Write a Python program to enter name and percentage marks in a dictionary
and display information on the screen. |
8 | a) Write a Python program to implement Linear search technique.
b) Write a Python program to implement Binary search technique. |
9 | a) Write a Python program to implement selection sort.
b) Write a Python program to implement bubble sort. c) Write a Python program to implement merge sort. d) Write a Python program to implement quick sort. |
10 | a) Write a Python program to perform read and write operations on a file.
b) Write a Python program to copy the contents of one file to another file. c) Write a Python program to print each line of a file in reverse order. d) Write a Python program to compute the number of characters, words and lines in a file. |
11 | Demonstrate about python modules:
a) Create a module and then use it in your program. b) Include in-built python modules in your program. |
Table 1.1 List of experiments
- Course Resources
- Essential Reading
- Course Self-Learning Material.
- Learning Python, Mark Lutz, Orielly, 3 Edition 2007.
- Python Programming: A Modern Approach, Vamsi Kurama, Pearson, 2017.
- Recommended Reading
- Think Python, 2 Edition, 2017 Allen Downey, Green Tea Press
- Core Python Programming, 2016 W.Chun, Pearson.
- Introduction to Python, 2015 Kenneth A. Lambert, Cengages.
- Mark Lutz, Learning Python, O’Reilly Media, 5th Edition, 2013.
- Allen B. Downey, Think Python: How to Think Like a Computer Scientist, O’Reilly Media, 2nd Edition, 2015.
- Mark Pilgrim, Dive into Python,
- Martin C. Brown, Python: The Complete Reference
- Websites
- Essential Reading
- Other Electronic Resources
- Course Video Lectures on LMS
Sample Programs
EXPERIMENT-1
- Demonstrate the working of following functions in Python.
- id( ) ii) type( ) iii) range( )
Solution:
- id() function:
The id() function returns identity (unique integer) of an object.
The syntax of id() is:
id(object)
As we can see the function accepts a single parameter and is used to return the identity of an object. This identity has to be unique and constant for this object during the lifetime.
Two objects with non-overlapping lifetimes may have the same id() value. If we relate this to C, then they are actually the memory address, here in Python it is the unique id. The output is the identity of the object passed.
This is random but when running in the same program, it generates unique and same identity.
Program 1:
print(‘id of 5 =’,id(5)) a = 5
print(‘id of a =’,id(a)) b = a
print(‘id of b =’,id(b)) c = 5.0
print(‘id of c =’,id(c))
Output:
id of 5 = 140737105207824
id of a = 140737105207824
id of b = 140737105207824
id of c = 2497999538800
Program 2:
s = “CSE”
print(id(s))
s2 = “CSE”
print(id(s2))
print(id(s)==id(s2))
Output:
2497999585904
2497999585904
True
Program 3:
# Use in Lists
list1 = [“Python”, “Java”, “C++”]
print(id(list1[0]))
print(id(list1[2]))
# This returns false
print(id(list1[0])==id(list1[2]))
Output:
2497932653936
2497999588144
True
- The ‘type()’ function:
- Python have a built-in method called as type which generally come in handy while figuring out the type of variable used in the program in the runtime.
- The type function returns the datatype of any arbitrary object.
- type() takes anything and returns its data type. Integers, strings, lists, dictionaries, tuples, functions, classes, modules, even types are acceptable.
- type() can take a variable and return its datatype.
Program:
print(type(5))
print(type(5.0))
print(type(‘5’))
print(type(“5”))
print(type([]))
print(type(()))
print(type({}))
print(type({a,}))
Outptut:
- range():
range() function is used to generate sequence of numbers.
Program 1:
r = range(10)
print(type(r))
print(r)
for i in r:
print(i)
for i in r:
print(i,end = ‘ ‘)
for i in r:
print(i,end = ‘\t ‘)
Output:
range(0, 10)
0
1
2
3
4
5
6
7
8
9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
Program 2:
r = range(-25,10)
print(type(r))
print(r)
for i in r:
print(i,end = ‘ ‘)
Output:
range(-25, 10)
-25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7
– 6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9
Program 3:
r = range(1,21,2)
for i in r:
print(i,end = ‘ ‘)
p = range(21,1,-5)
for i in p:
print(i,end = ‘ ‘)
Output:
1 3 5 7 9 11 13 15 17 19
21 16 11 6
Program 4:
r = range(10,20)
print(r[0])
print(r[-1])
r1 = r[1:5]
print(r1)
for i in r1:
print(i)
r[1] = 3445
Output:
10
19
range(11, 15)
11
12
13
14
————————————————————————–
–
TypeError Traceback (most recent call las t)
in
- for i in r1:
- print(i)
—-> 8 r[1] = 3445
TypeError: ‘range’ object does not support item assignment
- Write a program to read Employee data from the keyboard and print that data.
Program:
eno=int(input(“Enter Employee No:”))
ename=input(“Enter Employee Name:”)
esal=float(input(“Enter Employee Salary:”))
eaddr=input(“Enter Employee Address:”)
married=bool(input(“Employee Married ?[True|False]:”))
print(“Please Confirm your provided Information”)
print(“Employee No :”,eno)
print(“Employee Name :”,ename) print(“Employee Salary :”,esal)
print(“Employee Address :”,eaddr)
print(“Employee Married ? :”,married)
Output:
Enter Employee No:11111
Enter Employee Name:Karthikeya
Enter Employee Salary:100000
Enter Employee Address:Nandyal
Employee Married ?[True|False]:T
Please Confirm your provided Information
Employee No : 11111
Employee Name : Karthikeya
Employee Salary : 100000.0
Employee Address : Nandyal
Employee Married ? : True
Experiment 2:
f) Demonstrate the following Conditional statements in Python with suitable examples.
- if statement ii) if else statement iii) if – elif – else statement
Program:
number=input(“Enter a number:”)
if number > 0:
print(“It is a positive number”)
elif number < 0: print("It is a negative number") else : print("It is Zero") Output:
Enter a number:-5
It is a negative number
- b) Write a Python program to print the following Pattern:
*
* *
* * *
* * * *
* * * * *
Program:
n=int(input(“Enter the number of rows:”))
for i in range(1,n+1):
for j in range(1,i+1):
print(“*”,end=” “)
print()
Output:
Enter the number of rows:5
*
* *
* * *
* * * *
* * * * *
c) Write a Python program to display the sum of first ‘n’ numbers using while loop.
Program:
n=int(input(“Enter number:”))
sum=0
i=1
while i<=n: sum=sum+i i=i+1 print("The sum of first",n,"numbers is :",sum) Output:
Enter number: 10
The sum of first 10 numbers is: 55
Experiment 3
- Demonstrate the different ways of creating list objects with suitable example
- Demonstrate the following functions/methods which operates on lists in Python with suitable examples:
- i) list( ) ii) len( ) iii) count( ) iv) index ( ) v) append( ) vi) insert( ) vii) extend() viii) remove( ) ix) pop( ) x) reverse( ) xi) sort( ) xii) copy( )
xiii) clear( )
- Demonstrate the following with suitable example programs:
- List slicing
- List Comprehensions
a) Demonstrate the different ways of creating list objects with suitable example programs.
If we want to represent a group of individual objects as a single entity where insertion order is preserved and duplicates are allowed, then we should go for List.
- Insertion order preserved.
- Duplicate objects are allowed
- Heterogeneous objects are allowed.
- List is dynamic because based on our requirement we can increase the size and decrease the size.
- In List the elements will be placed within square brackets and with comma seperator.
- We can differentiate duplicate elements by using index and we can preserve insertion order by using index.Hence index will play very important role.
- Python supports both positive and negative indexes. +ve index means from left to right where as negative index means right to left.
Creation of List Objects:
Program:
list=[] # empty list created
list = [10,20,30,40] # list with elements created
print(list)
print(type(list))
list=(input(“Enter List:”)) # Entire input is considered as string
print(list)
print(type(list))
Output:
[] [10, 20, 30, 40]
Enter List: 10,20,30,40
10,20,30,40
- i) list():
Program:
l=list(range(0,10,2))
print(l)
- ii) len():
print(len(l))
iii) count():It returns the number of occurrences of specified item in the list.
Program:
n=[1,2,2,2,2,3,3]
print(n.count(1))
print(n.count(2))
print(n.count(3))
print(n.count(4))
Output:
1
4
2
0
- iv) index(): It returns the index of first occurrence of the specified item.
print(n.index(1))
print(n.index(2))
print(n.index(3))
Output:
0
1
5
- v) append(): Write a Python Program to add all elements to list upto 100 which are divisible by 10.
Program:
list=[]
for i in range(101):
if i%10==0:
list.append(i)
print(list)
Output:
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
- vi) insert():
Program:
n=[1,2,3,4,5]
n.insert(1,888)
n.insert(10,777)
n.insert(-10,999)
print(n)
print(n)
print(n.index(777))
print(n.index(999))
Output:
[1, 888, 2, 3, 4, 5] [999, 1, 2, 3, 4, 5, 777]
6
0
Note:
- If the specified index is greater than max index then element will be inserted at last position.
- If the specified index is smaller than min index then element will be inserted at first position.
vii) extend():
Program:
list1=[“Chicken”,”Mutton”,”Fish”]
list2=[“RC”,”KF”,”FO”]
list1.extend(list2)
list3 = list1 + list2
print(list1)
print(list2)
print(list3)
Output:
[‘Chicken’, ‘Mutton’, ‘Fish’, ‘RC’, ‘KF’, ‘FO’] [‘RC’, ‘KF’, ‘FO’] [‘Chicken’, ‘Mutton’, ‘Fish’, ‘RC’, ‘KF’, ‘FO’]
viii) remove():
- We can use this function to remove specified item from the list.
- If the item present multiple times then only first occurrence will be removed.
Program:
l1= [10,20,30,40,50,60,70]
x = int(input(‘Enter the element to be removed : ‘))
if x in l1:
l1.remove(x)
print(‘Element removed Successfully ‘) print(l1)
else:
print(‘Specified element is not available ‘)
Output:
Enter the element to be removed: 10
Element removed successfully
[20, 30, 40, 50, 60, 70]- ix) pop():
- It removes and returns the last element of the list.
- This is only function which manipulates list and returns some element.
We can use pop() function in following two ways:
- pop(index) ==> To remove and return element present at specified index.
- pop() ==> To remove and return last element of the list.
Program:
n=[10,20,30,40,50,60]
print(n.pop()) #60
print(n.pop(1)) #20
print(n.pop(10)) # IndexError: pop index out of range
Output:
60
20
- x) reverse() and sort():
Program:
n=[10,20,30,40]
n.reverse()
print(n)
n.sort()
print(n)
Output:
[40, 30, 20, 10] [10, 20, 30, 40]
- i) List slicing:
Syntax:
list2= list1[start:stop:step]
- start ==>it indicates the index where slice has to start default value is 0
- stop ===>It indicates the index where slice has to end default value is max allowed index of list ie length of the list
- step ==>increment value (step default value is 1)
Program:
n=[1,2,3,4,5,6,7,8,9,10]
print(n[2:7:2]) #3,5,7
print(n[4::2]) # 5,7,9
print(n[3:7]) #4,5,6,7
print(n[8:2:-2]) # 9,7,5
print(n[4:100]) # 5,6,7,8,9,10
- ii) List Comprehensions:
It is very easy and compact way of creating list objects from any iterable objects(like list,tuple,dictionary,range etc) based on some condition.
Syntax:
list=[expression for item in list if condition]
Consider an example, if you want to store squares of numbers form 1 to 10 in a list,
Program 1:
l1=[ ]
for x in range(1,11):
l1.append(x*x)
print(l1)
Output:
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
Program 2: Using List Comprehension
l1 = [x*x for x in range(1,21)]
l2 = [x for x in l1 if x % 2 == 0]
print(l1)
print(l2)
Output:
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400] [4, 16, 36, 64, 100, 144, 196, 256, 324, 400]
Experiment 4: a) Write a Python program to find the maximum number of a list of numbers.
Program:
n=int(input(“Enter the list size:”))
a=[]
for i in range(n):
num=int(input(“Enter the number”))
a.append(num)
print (a)
max=a[0]
for i in range(n):
if(maxOutput:
Enter the list size:5
Enter the number33
Enter the number77
Enter the number221
Enter the number5
Enter the number7
[33, 77, 221, 5, 7]maximum number in the list is : 221
- b) Write a Python program to check whether a number is prime or not.
Program:
num = int(input(“Enter a number: “))
if num == 0 or num == 1:
print(num, “is not a prime number”)
elif num > 1:
# check for factors
for i in range(2,num):
if (num % i) == 0:
print(num,”is not a prime number”)
print(i,”times”,num//i,”is”,num)
break
else:
print(num,”is a prime number”)
# if input number is less than
# or equal to 1, it is not prime
else:
print(num,”is not a prime number”)
Experiment 5: a) Write a function to check whether the given number is even or odd.
Program:
def even_odd(num):
if num%2==0:
print(num,”is Even Number”)
else:
print(num,”is Odd Number”)
even_odd(10)
even_odd(15)
Outptut:
10 is Even Number
15 is Odd Number
- b) Write a function to find factorial of a given number.
Program:
def fact(num):
result=1
while num>=1:
result=result*num
num=num-1
return result
for i in range(1,5):
print(“The Factorial of”,i,”is :”,fact(i))
Output:
The Factorial of 1 is : 1
The Factorial of 2 is : 2
The Factorial of 3 is : 6
The Factorial of 4 is : 24
- c) Write a Python program to return multiple values at a time using a return statement.
Program:
def calc(a,b):
sum = a + b
sub = a – b
mul = a * b
div = a / b
return sum,sub,mul,div
a,b,c,d = calc(100,50) # Positional arguments
print(a,b,c,d)
Output:
150 50 5000 2.0
Experiment 6: a) Write a program to create a lambda function to find square of given number.
Program:
s=lambda n:n*n
print(“The Square of 4 is :”,s(4))
print(“The Square of 5 is :”,s(5))
Output:
The Square of 4 is : 16
The Square of 5 is : 25
b)Write a program to create a Lambda function to find sum of 2 given numbers.
Program:
s=lambda a,b:a+b
print(“The Sum of 10,20 is:”,s(10,20))
print(“The Sum of 100,200 is:”,s(100,200))
Output:
The Sum of 10, 20 is: 30
The Sum of 100, 200 is: 300
c)Write a program to create a Lambda Function to find biggest of given values.
Program:
s=lambda a,b:a if a>b else b
print(“The Biggest of 10,20 is:”,s(10,20))
print(“The Biggest of 100,200 is:”,s(100,200))
Output:
The Biggest of 10, 20 is: 20
The Biggest of 100, 200 is: 200
Lambda Function:
- Lambda Function internally returns expression value and we are not required to write return statement explicitly.
- Sometimes we can pass a function as argument to another function. In such cases lambda functions are best choice.
- We can use lambda functions very commonly with filter(),map() and reduce() functions,because these functions expect function as argument.
- filter() function:
- We can use filter() function to filter values from the given sequence based on some condition.
- For example, we have 20 numbers and if we want to retrieve only even numbers from them.
Syntax:
filter(function,sequence)
Where,
- function argument is responsible to perform conditional check.
- sequence can be list or tuple or string.
- d) Program to filter only even numbers from the list by using filter() function.
Without lambda Function:
Program:
def isEven(x):
if x%2==0:
return True
else:
return False
l=[0,5,10,15,20,25,30]
l1=list(filter(isEven,l)) print(l1)
Output: [0, 10, 20, 30]
With lambda Function:
Program:
l=[0,5,10,15,20,25,30]
l1=list(filter(lambda x:x%2==0,l))
print(l1)
l2=list(filter(lambda x:x%2!=0,l))
print(l2)
Output: [0, 10, 20, 30] [5, 15, 25]
- map() function:
- For every element present in the given sequence,apply some functionality and generate new element with the required modification. For this requirement we should go for map() function.
- The function can be applied on each element of sequence and generates new sequence.
Syntax:
map(function,sequence)
- e) For every element present in the list, perform double and generate new list of doubles.
Without lambda:
Program:
l=[1,2,3,4,5]
def doubleIt(x):
return 2*x
l1=list(map(doubleIt,l))
print(l1)
Output: [2, 4, 6, 8, 10]
With lambda:
Program:
l=[1,2,3,4,5]
l1=list(map(lambda x:2*x,l))
print(l1)
Find square of given numbers using map() function.
Program:
l=[1,2,3,4,5]
l1=list(map(lambda x:x*x,l))
print(l1)
Output: [1, 4, 9, 16, 25]
Experiment 7: Write a Python program to enter name and percentage marks in a dictionary
and display information on the screen.
Program:
rec={}
n=int(input(“Enter number of students: “))
i=1
while i <= n: name=input("Enter Student Name: ") marks=input("Enter % of Marks of Student: ") rec[name]=marks i=i+1 print("Name of Student","\t","% of Marks") for x in rec: print("\t",x,"\t",rec[x]) # x ===> key rec[x] =====> value
Output:
Enter number of students: 3
Enter Student Name: Kavita
Enter % of Marks of Student: 98
Enter Student Name: Suresh
Enter % of Marks of Student: 97
Enter Student Name: Sourav
Enter % of Marks of Student: 34
Name of Student % of Marks
Kavita 98
Suresh 97
Sourav 34
Experiment 8: a) Write a Python program to implement Linear search technique.
Program:
n=int(input(“Enter the number of elements in the array :”))
i=0
flag = 0
a=[i for i in range(n)]
for i in range(0,n):
a[i]=int(input(“Enter the {} element of the array :”.format(i+1)))
for i in range(0,n):
print (a[i])
key=int(input(“Enter the Key element to be searched”))
for i in range(0,n):
if a[i]==key:
print (“Key element found at”,i+1,’Position’)
flag = 1
break
if flag == 0:
print(“Key element not found !!!”)
Output:
Enter the number of elements in the array: 3
Enter the 1 element of the array: 39
Enter the 2 element of the array: 33
Enter the 3 element of the array: 28
39
33
38
Enter the Key element to be searched 33
Key element found at 1 Position
- b) Write a Python program to implement Binary search technique.
Program:
def binary_search(a,n,key):
low=0
high=n-1
while(low<=high): mid=int((low+high)/2) if(key==a[mid]):
return mid
elif(key high=mid-1
else:
low=mid+1
return -1
n=int(input(“Enter the number of elements : “))
a=[i for i in range(n)]
for i in range(0,n):
a[i]=int(input(“Enter the {} element of the array :”.format(i+1))) k=int(input(“Enter the key element to be searched :”))
position=binary_search(a,n,k)
if(position!=-1):
print (“Key element found at “,(position))
else:
print (“Key element not found !!!”)
Output:
Enter the number of elements: 5
Enter the 1 element of the array: 23
Enter the 2 element of the array: 45
Enter the 3 element of the array: 67
Enter the 4 element of the array: 79
Enter the 5 element of the array: 90
Enter the key element to be searched: 79
Key element found at 3
Experiment 9: a) Write a Python program to implement selection sort.
Program:
def selectionSort(a):
for i in range(len(a)):
least=i
for k in range(i+1,len(a)):
if a[k] least=k
temp=a[least]
a[least]=a[i]
a[i]=temp
a=[50,30,10,20,40,70,60]
print (“Original list”,a)
selectionSort(a) # Calling to the function
print(“Selection Sort:”,a)
Output:
Original list [50, 30, 10, 20, 40, 70, 60]
Selection Sort: [10, 20, 30, 40, 50, 60, 70]
- b) Write a Python program to implement bubble sort.
Program:
a = list(map(int,input(“Enter list Elements: “).split()))
print(“Before sorting the elements in the list are: “,a)
for i in range(0,len(a)-1,1):
for j in range(0,len(a)-1-i,1):
if(a[j]>a[j+1]):
temp = a[j]
a[j] = a[j+1]
a[j+1]= temp
print(“After sorting the elements in the list are: “,a)
Output:
Enter list Elements: 2 3 11 55 33 -6
Before sorting the elements in the list are: [2, 3, 11, 55, 33, -6]
After sorting the elements in the list are: [-6, 2, 3, 11, 33, 55]
What does list(map(int,input().split())) do in python?
Let’s break it down:
- input() gets user input and returns a string, e.g. “1 2 3 4 5”
- input().split() splits that input on whitespaces, e.g. [“1”, “2”, “3”, …]
- int() converts a string to a integer, e.g. “1” -> 1
- map(fn, sequence) applies the function fn to each element in the sequence, e.g. fn(sequence[0]), fn(sequence[1]), …
- map(int, input().split()) applies int to each string element in the input, e.g. [“1”, “2”, “3”, …] -> int(“1”), int(“2”), …
- list() turns any iterator/generator to a list, e.g. int(“1”), int(“2”), … => [1, 2, 3, …]
- c) Python Program to Implement Merge Sort Technique
Program:
def mergeSort(a):
if len(a)>1:
mid = len(a)//2
left= a[:mid]
right=a[mid:]
mergeSort(left)
mergeSort(right)
i = 0
j = 0
k = 0
while i i += 1 else: a[k]=right[j]
j += 1 k += 1 while i i += 1 k += 1 while j j += 1 k += 1 a = list(map(int,input(“Enter list Elements: “).split())) print(“Before sorting the elements in the list are: “,a) mergeSort(a) print(“After sorting the elements in the list are: “,a) Output: Enter list Elements: 65 76 23 98 22 11 22 Before sorting the elements in the list are: [65, 76, 23, 98, 22, 11, 22]
After sorting the elements in the list are: [11, 22, 22, 23, 65, 76, 98]
Program: def partition(a, low, high): i = (low – 1) pivot = a[high]
for j in range(low, high): if a[j] < = pivot:
i = i+1
temp = a[i]
a[i] = a[j]
a[j] = temp
temp = a[i+1]
a[i+1] = a[high]
a[high] = temp
return i+1
def = quickSort(a, low, high)
if low < high:
pi = partition(a, low, high)
quickSort(a, low, pi -1)
quickSort(a, pi+1, high)
a = list(map(int,input("Enter list Elements: ").split()))
print("Before sorting the elements in the list are: ",a)
quickSort(a, 0, len(a)-1)
print("After sorting the elements in the list are: ",a)
Output:
Enter list Elements: 3 1 8 2 0 4 9 7
Before sorting the elements in the list are: [3, 1, 8, 2, 0, 4, 9, 7]
After sorting the elements in the list are: [0, 1, 2, 3, 4, 7, 8, 9]
Experiment 10: a) Write a Python program to perform read and write operations on a file. Program: filename =input(“Enter the file name : “) f1=open(filename,’w’) f1.write(‘Computer science Engineering\n‘) f1.write(‘Elecronics and Communication Engineering\n‘) f1.write(‘Civil Engineering\n‘) f1.close() f2=open(filename,’r’) data=f2.read() print(data) f2.close() Output: Enter the file name : CRS Computer science Engineering Elecronics and Communication Engineering Civil Engineering Program: filename1 = input(“Enter the file name 1: “) f1 = open(filename1,’w’) f1.write(‘Computer science Engineering\n‘) f1.write(‘Elecronics and Communication Engineering\n‘) f1.write(‘Civil Engineering\n‘) f1.close() f2 = open(filename,’r’) data1 = f2.read() print(data) f2.close() filename2 = input(“Enter the file name 2: “) f3 = open(filename2,’w’) f3.write(data1) f3.close() f3 = open(filename2,’r’) data2 = f3.read() print(data2) f3.close() Output: Enter the file name 1: Pyhton Enter the file name 2: c++ Computer science Engineering Elecronics and Communication Engineering Civil Engineering Program: filename = input(“Enter a file name : “) f1 = open(filename,’w’) f1.write(‘Computer science Engineering\n‘) f1.write(‘Elecronics and Communication Engineering\n‘) f1.write(‘Civil Engineering\n‘) f1.close() f1 = open(filename,’r’) data = f1.readlines() print(data) for i in data: print(i[::-1]) f1.close() Output: Enter a file name : CSE gnireenignE ecneics retupmoC gnireenignE noitacinummoC dna scinorcelE gnireenignE liviC Program: filename = input(“Enter a file name : “) c = 0 w = 0 l = 0 f1 = open(filename,’w’) f1.write(‘Computer science Engineering\n‘) f1.write(‘Elecronics and Communication Engineering\n‘) f1.write(‘Civil Engineering\n‘) f1.close() f2 = open(filename,’r’) data = f2.readlines() print(data) for i in data: c = c + len(i) w = w + len(i.split()) l = l + 1 f2.close() print(‘The number of Characters are :’, c) print(‘The number of Words are :’, w) print(‘The number of Lines are :’, l) Output: Enter a file name : LBC0303 The number of Characters are: 88 The number of Words are : 9 The number of Lines are : 3 Experiment 11: a) Create a module and then use it in your program. Let us create a module. Type the following and save it as arithOps.py. # Python Module addition def add(a, b): result = a + b return result def sub(a, b): result = a – b return result def mul(a, b): result = a * b return result def div(a, b): result = a / b return result Now create a new file and save it by mod.py import arithOps print(arithOps.sub(120, 20)) Output: 100 Import with renaming: import arithOps as ap print(ap.add(10,23)) Output: 33 Import specific function from arithOps import mul print(mul(3, 8)) Output: 24 Program: import math # use math.pi to get value of pi print(“The value of pi is”, math.pi) Output: The value of pi is 3.141592653589793 Program: from math import sqrt, factorial print(sqrt(16)) print(factorial(6)) Output: 4 720 Experiments for Practice:
#Expt.No.
Problem Definition
1
WAP to compute the GCD of two numbers using python.
2
WAP To find square root of number.
3
WAP To sort list of elements using insertion sort.
4
Write a Python program to get the Fibonacci series between 0 to 50.
5
Write a Python program to create a tuple with different data types and add an item in a tuple.
6
WAP in python to create a module having functions to calculate perimeter and area of different shapes and then import this module in your another program.
Course Code: LBC0301 | Course Title: System Analysis and Design (3 Credits) |
Course Outcome: –
· Learn object-oriented analysis and design, including UML diagrams (class, use case, activity) and system prototyping/testing, with a focus on implementation strategies and ongoing maintenance. Course Goal The goal of this course is to equip students with the skills to analyze, design, and implement systems using SDLC, conduct feasibility studies, gather and analyze requirements, apply system design principles, and manage system development and maintenance effectively. Course Learning Outcomes Upon completing this course, students will be able to analyze and design systems using the System Development Life Cycle (SDLC), conduct feasibility studies, gather and analyze requirements, apply system design principles, model system functions using DFDs, implement object-oriented design with UML diagrams, develop and test prototypes, manage system implementation and maintenance, and apply project management techniques to system development. |
|
*BTL- Bloom’s Taxonomy Level. 1- Understand, 2- Remember, 3- Apply, 4- Analyze, 5- Evaluate, 6- Create |
Course Contents
Sr. No | Unit No./ Unit description | Unit Outcome |
1 | Unit 1- Introduction to System Analysis and Design: System, System Components and Characteristics, System Analysis, System Design , System Analyst,- Role of System Analyst, Task of System Analyst | This module has been designed as per BTL 1 & 2. |
2 | Unit 2- System Development Life Cycle (SDLC): Phases of SDLC: Planning, Analysis, Design, Work breakdown structure organization , Implementation, Maintenance, Models of SDLC: Waterfall, Agile, Iterative, Spiral, RAD Model, Extreme Programming, | This module has been designed as per BTL 3&5. |
3 | Unit 3- Feasibility Analysis: Types of Feasibility: Technical, Operational, Economic, and Schedule Feasibility Study Process and Documentation , Cost-Benefit Analysis and Risk Management, Implement Quality Control, Project Management Deliverables. | This module has been designed as per BTL 3&4. |
4 | Unit 4- Requirements Gathering and Analysis: Techniques for Gathering Requirements: Interviews, Surveys, Observation, Prototyping, Functional vs. Non-Functional Requirements, Roles of business analysts, Build prototypes, Questionnaire, Structured walkthroughs. | This module has been designed as per BTL 3 & 6. |
5 | Unit 5- System Design Basics: Principles of Good System Design, Designing Input, Output, and Process Specifications, Data Modelling: ER Diagrams and Relational Database Design | This module has been designed as per BTL 3 & 6. |
6 | Unit 6- Functional Modelling and DFDs: Functional Requirements, Functional Modelling Techniques- DFDs , Logical and Physical Data Flow Diagrams | This module has been designed as per BTL 3 &6. |
7 | Unit 7- Object-Oriented System Analysis and Design: Basics of Object-Oriented Design (OOD), UML Diagrams: Class Diagram, Object Diagram, Component Diagram, Use Case Diagram, Activity Diagram | This module has been designed as per BTL 3. |
8 | Unit 8- System Prototyping and Testing: Types of Prototyping: Evolutionary, Incremental & Throwaway, Developing and Evaluating Prototypes, Types of System Testing: Unit, Integration, System, User Acceptance | This module has been designed as per BTL 3&4. |
9 | Unit 9- Implementation and Maintenance: System Implementation Strategies: Direct Cutover, Parallel, Phased, Transition to Maintenance and Ongoing System Support, Change Management and Version Control | This module has been designed as per BTL 3&4. |
10 | Unit 10- Project Management in System Development: Role of Project Managers in System Analysis, Project Planning and Scheduling (Gantt Charts, PERT), Quality Assurance | This module has been designed as per BTL 4&5. |
Text book References: –
1. “Analysis and Design of Information Systems” : Senn, TMH. 2. System Analysis and Design : Howryskiewycz, PHI. 3. “System Analysis and Design” : Awad. 4. “Software Engineering A practitioners Approach” : Roger S. Pressman TMH. 5. “System Analysis and Design Methods : “Whitten, Bentley. 6. “Analysis and Design of Information Systems” : Rajaraman, PHI. |